Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --@name Triangle Sierpinski
- --@author
- if CLIENT then
- local size = 1024
- local Ax = size/2
- local Ay = 0
- local Bx = 0
- local By = size-1
- local Cx = size-1
- local Cy = size-1
- local x, y = size/2, 0
- local scl = 1024 / size
- render.createRenderTarget("fractal")
- local function quotaCheck(n)
- return math.max(quotaAverage(), quotaUsed()) < quotaMax() * n
- end
- function load()
- hook.add("render","",function()
- while quotaCheck(0.05) do
- render.selectRenderTarget("fractal")
- local h = math.random(3)
- if h == 1 then
- x = math.lerp(0.5,x,Ax)
- y = math.lerp(0.5,y,Ay)
- elseif h == 2 then
- x = math.lerp(0.5,x,Bx)
- y = math.lerp(0.5,y,By)
- elseif h == 3 then
- x = math.lerp(0.5,x,Cx)
- y = math.lerp(0.5,y,Cy)
- end
- render.setColor(Color(((x+y)/size)*360,1,1):hsvToRGB())
- render.drawRectFast(math.round(x)*scl, math.round(y)*scl, scl, scl)
- render.selectRenderTarget(nil)
- end
- render.setColor(Color(255,255,255))
- render.setRenderTargetTexture("fractal")
- render.drawTexturedRect(0,0,512,512)
- end)
- end
- load()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement