|
Post by johnno56 on Jan 23, 2024 18:23:08 GMT -6
This is NOT mine. It is a conversion of a graphics demo by Bplus (QB64pe), had a few minutes to spare... voila!
It will continue to run until ESC... The colour changes after each "cycle".
xmax = 600 ymax = 600 title$ = "Animated String Art" center_x = windowpos_centered center_y = windowpos_centered WindowOpen(1,title$,center_x,center_y,xmax,ymax,WindowMode(1,0,0,0,0),1) SetWindowAutoClose(1, 0) CanvasOpen(1,xmax,ymax,0,0,xmax,ymax,0) ClearCanvas
randomize(timer)
Dim a1, a2, cx, cy, r, s
r = ymax / 2 cx = xmax / 2 cy = ymax / 2 n = 250 s = 360 / n
red = 175 green = 255 blue = 255
pi = 3.141592654
Function d2r(angle) return angle * (pi / 180) End Function
t = 1
do setColor(rgb(0, 0, 0)) RectFill(0, 0, xmax, ymax) 'setColor(rgb(red, green, blue)) Circle(cx - 1, cy, r) for i = 1 to n a1 = s * i a2 = s * i * t setColor(rgb(red, green, blue)) line(cx + sin(d2r(a1)) * r, cy + cos(d2r(a1)) * r, cx + sin(d2r(a2)) * r, cy + cos(d2r(a2)) * r) next
t = t + 0.0125 if t >= 50 then t = 1 red = 32 + rand(223) green = 32 + rand(223) blue = 32 + rand(223) end if if key(27) then exit do end if if Not WindowExists(1) Or WindowEvent_Close(1) Then end end if update() loop
|
|
|
Post by n00b on Jan 24, 2024 12:51:34 GMT -6
This is a pretty cool demo. One improvement you could probably make is taking out the d2r() function and just using the built-in radians function. Its implemented in C++ so its going to perform a lot faster. You wouldn't really notice it unless you disabled VSync though.
|
|
|
Post by johnno56 on Jan 24, 2024 13:26:38 GMT -6
Cool... I have updated my copy accordingly... and it still runs... lol
|
|