Thanks @Jack I threw out the color subroutines and threw up my own coloring scheme LOL
Code: (Select All)
' QB64 translation of JavaScript inversion effect
' Original: https://codepen.io/yukulele/pen/qEEvrmO
' *** BIG MOD BY BPLUS ***
' Set up graphics screen (640x480, 32-bit color)
Dim Shared w As Integer, h As Integer
Dim Shared zoom As Single, zoomFactor As Single
Dim Shared r As Single, r2 As Single
Dim Shared imageHandle As Long
w = 640
h = 480
zoom = 1
zoomFactor = 0
r = 250
r2 = r * r
Screen _NewImage(w, h, 12)
imageHandle = _NewImage(w, h, 32)
'_Dest imageHandle
' Main loop
Do
_Limit 60 ' Approximate 60 FPS
Drawit
'_PutImage , imageHandle, 0 ' Copy image to screen
HandleInput
_Display
Loop Until _KeyDown(27) ' Exit on ESC
Sub Drawit
Dim x As Integer, y As Integer
Dim x0 As Single, y0 As Single, x2 As Single
Dim f As Single, x1 As Single, y1 As Single
Dim cx As Single, cy As Single, hue As Single
Dim rgb(2) As Integer
Dim c As Single
Dim now As Single
now = Timer(.01)
c = 10 * zoom
For x = 0 To w - 1
x0 = x - w / 2
x2 = x0 * x0
For y = 0 To h / 2
y0 = y - h / 2
f = r2 / (x2 + y0 * y0)
x1 = x0 * f
y1 = y0 * f
cx = Cos(now + x1 / c / 16)
cy = Cos(y1 / c / 16)
hue = Int((cx - cy) * 16) / 16
' Set pixels (top half)
PSet (x, y), hue
' Mirror to bottom half
PSet (x, h - y - 1), hue
Next
Next
End Sub
Sub HandleInput
Dim k As Long
While _MouseInput: Wend ' Clear mouse buffer
k = _KeyHit
If k = 18432 Then ' + key for zoom in
zoomFactor = zoomFactor + 10
zoom = 1.0005 ^ zoomFactor
ElseIf k = 20480 Then ' - key for zoom out
zoomFactor = zoomFactor - 10
zoom = 1.0005 ^ zoomFactor
End If
_Title "up arrow = zoom out, down arrow zoom in, zoom =" + Str$(zoom)
End Sub
b = b + ...