Nice effect! I had a look at the source (K+ for that). It looks to me like you are calculating all the sums every frame and reloading the background. It runs very fast already, but one way of making it quicker is instead of using an image buffer for the lens graphic, do exactly what you're doing now, but instead of reading the pixel from the back buffer store the background_x, background_y values.
So, put these values in a 2d array:
Local background_x:Float = Cos(direction) * distance
Local background_y:Float = Sin(direction) * distance
This array becomes an 'offsets' buffer.
offsets(pixel_x, pixel_y).x = background_x
offsets(pixel_x, pixel_y).y = background_y
You do this just once at the start.
We probably need to set an array of bytes to say if the pixel is in or out of the circle
If distance <= radius
hasOffset(pixel_x, pixel_y)=1
else
hasOffset(pixel_x, pixel_y)=0
end if
Now, to do the lens effect really fast with no sums, run through your offsets buffer
for pixel_y = 0 to radius*2
for pixel_x = 0 to radius*2
if hasOffset(pixel_x, pixel_y)=1 then
background_x = x + offsets(pixel_x, pixel_y).x
background_y = y + offsets(pixel_x, pixel_y).y
pix = get_pixel(background_x, background_y)
set_pixel(x+pixel_x-radius, y+pixel_y-radius, pix)
end if
next
next
If you combine that with only loading the background at the start too it should go like lightning!
Jim