Skip to content

Instantly share code, notes, and snippets.

@cwervo
Created October 12, 2017 03:19
Show Gist options
  • Save cwervo/5e1cb594905561b0a4301d3f3c6130c5 to your computer and use it in GitHub Desktop.
Save cwervo/5e1cb594905561b0a4301d3f3c6130c5 to your computer and use it in GitHub Desktop.
A little circle fractal in Lua!
-- Written with LÖVE2D 0.10.2 (Super Toast)
local height = love.graphics.getHeight( )
local width = love.graphics.getWidth( )
local t = 0
love.graphics.setColor(255, 255, 255)
love.graphics.setLineWidth(1)
function drawCircle(mode, x, y, r)
love.graphics.setColor(180, 60, 180)
love.graphics.circle("line", x, y, r)
if r > 0.01 then
local xModifier = r * 1.25
local yModifier = math.tan(t / 2)
drawCircle(mode, x + xModifier, y + yModifier, r / 2)
drawCircle(mode, x - yModifier, y - yModifier, r / 2)
end
end
function love.draw()
t = love.timer.getTime()
love.graphics.translate(width/4, height/2)
-- love.graphics.setLineWidth(math.sin(t * 1.5) * 5)
drawCircle("line", 0, 0, width / 5)
end
@cwervo
Copy link
Author

cwervo commented Oct 12, 2017

Output:

giphy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment