# Bubble Universe

**URL:** <https://forum.clockworkpi.com/t/bubble-universe/19907>\
**Category:** PicoCalc\
**Tags:** demo\
**Created:** [September 29, 2025, 8:11am UTC](https://forum.clockworkpi.com/t/bubble-universe/19907 "2025-09-29T08:11:16Z")\
**Posts on this page:** 4\
**Page:** 2

<div class="post-metadata">

**Author:** ![maple](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/maple/32/12677_2.png) [@maple](https://forum.clockworkpi.com/u/maple)\
**Post date:** [November 1, 2025, 7:26pm UTC](https://forum.clockworkpi.com/t/bubble-universe/19907/21 "2025-11-01T19:26:19Z")

</div>

i figured caching sine values would speed it up, but i hadn’t bothered to think of a good way to do it in lua until now :]

[https://img.maple.pet/i/bvl.mp4](https://img.maple.pet/i/bvl.mp4)

```lua
local w = 320
local w2 = w/2
local rad = 70
local n = 50
local nc = 100
local step=2
local r = math.pi*2/n
local x,y,t = 0,0,0
local u,v,px,py

local res = 100

sint = {}
for i = 1, math.floor(math.pi*2*res) do
	sint[i] = math.sin(i/res)
end

function fsin(i)
	return sint[(math.floor(i*res)%#sint)+1]
end

function fcos(i)
	return sint[((math.floor((math.pi/2-i)*res))%#sint)+1]
end

draw.enableBuffer(2)
while true do
	if keys.getState(keys.esc) then break end
	draw.clear()
	for i = 0, n-1 do
		for c = 0, nc-1, step do
			u = fsin(i+y)+fsin(r*i+x)
			v = fcos(i+y)+fcos(r*i+x)
			x = u + t
			y = v
			px = u * rad + w2
			py = y * rad + w2
			draw.point(px, py, 
				colors.fromRGB(math.floor(63+i/n*192),
					math.floor(63+c/nc*192),168))
		end
	end
	t=t+0.03
	draw.blitBuffer()
end
draw.enableBuffer(false)

```

---

<div class="post-metadata">

**Author:** ![tabemann](https://avatars.discourse-cdn.com/v4/letter/t/df705f/32.png) [@tabemann](https://forum.clockworkpi.com/u/tabemann)\
**Post date:** [November 1, 2025, 7:49pm UTC](https://forum.clockworkpi.com/t/bubble-universe/19907/22 "2025-11-01T19:49:53Z")

</div>

You can do what I do and define a lookup table for only 0 through pi/2 radians, and preprocess your inputs to compute approximate sines and cosines based on this restricted range. With this you can get away with using either a smaller or a higher-resolution look-up table.

---

<div class="post-metadata">

**Author:** ![maple](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/maple/32/12677_2.png) [@maple](https://forum.clockworkpi.com/u/maple)\
**Post date:** [November 1, 2025, 7:56pm UTC](https://forum.clockworkpi.com/t/bubble-universe/19907/23 "2025-11-01T19:56:15Z")

</div>

yes, that’s how the `res` value works, the lookup functions scale the inputs with that as well :]

---

<div class="post-metadata">

**Author:** ![Neusse](https://avatars.discourse-cdn.com/v4/letter/n/da6949/32.png) [@Neusse](https://forum.clockworkpi.com/u/Neusse)\
**Post date:** [June 19, 2026, 8:31pm UTC](https://forum.clockworkpi.com/t/bubble-universe/19907/24 "2026-06-19T20:31:10Z")

</div>

@pelrun I love this thing. Now that I have my Luckfox Lyra installed I messed with getting this going. There is enough memory for a proper framebuffer and I implimented it in python. It renders at about 40 FPS.

really cool when it is going fast.

[Previous page](https://forum.clockworkpi.com/t/bubble-universe/19907.md?page=1)
