Created
October 12, 2017 03:19
-
-
Save cwervo/5e1cb594905561b0a4301d3f3c6130c5 to your computer and use it in GitHub Desktop.
A little circle fractal in Lua!
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
-- 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output: