Basicprogramming(.org) > Code and examples
Another hypnotic animation.
Peter:
This is my contribution in BaCon, using animated GIF (256 colors):
--- Code: ---INCLUDE canvas-gd
OPTION VARTYPE double
DEF FN distance(x1, y1, x2, y2) = POW( ( POW((x1 - x2),2)+POW((y1 - y2), 2) ), .5 )
WINDOW("hypnotic", 256, 256)
sh=HEIGHT
sw=WIDTH
SUB generate_frame
tm = TIMER
dr = RANDOM(256) : dg = RANDOM(256) : db = RANDOM(256)
FOR y = 0 TO sh
FOR x = 0 TO sw
vl = SIN(distance(x + tm, y, 128, 128) / 8)
vl = vl + SIN(distance(x, y, 64, 64) / 8)
vl = vl + SIN(distance(x, y + tm / 7, 192, 64) / 7)
vl = vl + SIN(distance(x, y, 192, 100) / 8)
clr = 256 / (1 + ABS(vl))
r = ABS(clr - dr) : g = ABS(clr - dg) : b = ABS(clr - db)
INK(r, g, b, 255)
PIXEL(x, y)
NEXT
NEXT
ENDSUB
FRAMES(40)
CALLBACK(400, generate_frame)
WAITKEY
--- End code ---
Navigation
[0] Message Index
[*] Previous page
Go to full version