Created
June 29, 2011 13:59
-
-
Save Yonaba/1053880 to your computer and use it in GitHub Desktop.
Sierpinski Triangle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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