|
Post by aurel on Nov 21, 2022 12:59:17 GMT -6
|
|
|
Post by Tomaaz on Nov 21, 2022 14:59:18 GMT -6
This is a very nice effect. I've slightly changed the way the colours are set. The whole thing is a bit more colourful with higher contrast as well. And I've changed t = t + 0.025 to t = t + 0.01 what makes the animation smoother. This is SmallBASIC + Raylib version:
import raylib as rl
const n = 200 const r = 6.283185307179586 / 235 const l = 255 / n const mw = 512 const mh = 512 const hw = mw / 2 const hh = mh / 2 x = y = v = t = 0
rl.InitWindow(mw, mh, "Bubble Universe") rl.SetTargetFPS(60) while !rl.WindowShouldClose() rl.BeginDrawing() rl.ClearBackground([0, 0, 0, 255]) for i = 0 to n for j = 0 to n u = sin(i + v) + sin(r * i + x) v = cos(i + v) + cos (r * i + x) x = u + t rl.DrawPixel(hw + u * hw * 0.4, hh + v * hh * 0.4, [floor((200 - i) * l), floor(j * l), floor (i * l), 255]) next next t = t + 0.01 rl.EndDrawing() wend
|
|
|
Post by Tomaaz on Nov 21, 2022 15:40:28 GMT -6
And this version is playing with alpha channel. The final animation is more dynamic and 3D-like:
import raylib as rl
const n = 200 const r = 6.283185307179586 / 235 const l = 255 / n const mw = 512 const mh = 512 const hw = mw / 2 const hh = mh / 2 x = y = v = t = 0 k = 255 randomize
rl.InitWindow(mw, mh, "Bubble Universe") rl.SetTargetFPS(60) while !rl.WindowShouldClose() rl.BeginDrawing() rl.ClearBackground([0, 0, 0, 255]) for i = 0 to n for j = 0 to n u = sin(i + v) + sin(r * i + x) v = cos(i + v) + cos (r * i + x) x = u + t rl.DrawPixel(hw + u * hw * 0.4, hh + v * hh * 0.4, [floor((200 - i) * l), floor(j * l), floor (i * l), k]) next k = 92 + floor(rnd() * 164) next t = t + 0.01 rl.EndDrawing() wend
|
|