Skip to content

Instantly share code, notes, and snippets.

@Yonaba
Created June 29, 2011 13:59
Show Gist options
  • Save Yonaba/1053880 to your computer and use it in GitHub Desktop.
Save Yonaba/1053880 to your computer and use it in GitHub Desktop.
Sierpinski Triangle
-- Creates an image
-- uses LuaPlayer as Framework
local image = Image.createEmpty(480,272)
local white = Color.new(255,255,255)
--Fractal Size
local size = 480
--Draws Fractal
local m = {}
m[math.floor(size/2)] = true
for i = 1, size do
n = {}
for j = 1, size do
if m[j] then
image:pixel(j, i, white)
n[j+1] = not n[j+1]
n[j-1] = not n[j-1]
end
end
m = n
end
--Draws Fractal
while true do
screen:clear()
screen:blit(0,0,image)
screen.waitVblankStart()
screen.flip()
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment