< Previous | Contents | Next >

Process Scatter

The Scatter function iterates through each output pixel and gets a source pixel based on the value red and blue channels shifting the position. The color channels return a float value between 0 and 1 and the Amplitude will control the strength of the effect. The output image is called avg.


print ("Scatter")

for y=0,img.Height-1 do for x=0,img.Width-1 do

img:GetPixel(x,y, sp)

xt = x - Amp * 5 * ( sp.R - 0.5) yt = y - Amp * 5 * ( sp.B - 0.5) if xt < 0 then

xt =0 end

if xt > img.Width-1 then xt =img.Width-1 end

if yt < 0 then

yt =0 end

if yt > img.Height-1 then yt =img.Height-1 end


img:GetPixel(xt,yt, sp) dp.R = sp.R

dp.G = sp.G dp.B = sp.B dp.A = sp.A

avg:SetPixel(x,y, dp)

end

end