Skip to content

Instantly share code, notes, and snippets.

@sebnozzi
Last active March 6, 2023 17:03
Show Gist options
  • Save sebnozzi/2d3a945fdec71532b20cdcac242e275e to your computer and use it in GitHub Desktop.
Save sebnozzi/2d3a945fdec71532b20cdcac242e275e to your computer and use it in GitHub Desktop.
Plasma Effect - Mini Micro
canvasWidth = 50
canvasHeight = 50
scale = 10
speed = 0.2
colorToRgb = function(value)
return color.rgb(255,
255 * cos(value * pi),
255 * sin(value * pi))
end function
calcPlasmaValue = function(x, y, t)
size = canvasWidth / 20
result = 0
result = result + sin(x/size+t)
result = result + sin((y/size+t)/2.0)
result = result + sin((x/size+y/size+t)/2.0)
cx = x/size/10+0.8*sin(t/4)
cy = y/size/10+0.8*cos(t/3)
result = result + sin(sqrt(100*(cx*cx+cy*cy+1))+t)
return result
end function
t = 0.0
updateLoop = function(target)
while true
globals.t = (t + speed)
for x in range(0, canvasWidth - 1)
for y in range(0, canvasHeight - 1)
plasmaValue = calcPlasmaValue(x, y, t)
rgb = colorToRgb(plasmaValue)
target.setPixel x, y, rgb
end for
end for
yield
end while
end function
initCanvas = function()
clear
gfx.scale = [scale,scale]
return gfx
end function
displayTarget = initCanvas
updateLoop displayTarget
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment