Created
June 8, 2018 19:34
-
-
Save broerjuang/1f529417fc785d13f6a52d2701825630 to your computer and use it in GitHub Desktop.
simple fractal 1
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
open Reprocessing; | |
let width = 640; | |
let height = 360; | |
let rec drawRec = (~x, ~y, ~dimension, env) => { | |
Draw.stroke(Constants.black, env); | |
Draw.strokeWeight(1, env); | |
Draw.noFill(env); | |
Draw.rect(~pos=(x, y), ~width=dimension, ~height=dimension, env); | |
if (dimension > 5) { | |
drawRec(~x=x + dimension, ~y, ~dimension=dimension / 2, env); | |
drawRec(~x=x - dimension, ~y, ~dimension=dimension / 2, env); | |
drawRec(~x, ~y=y + dimension, ~dimension=dimension / 2, env); | |
}; | |
}; | |
let setup = env => Env.size(~width, ~height, env); | |
let draw = (_, env) => { | |
Draw.background(Constants.white, env); | |
drawRec(~x=width / 2, ~y=height / 2, ~dimension=150, env); | |
}; | |
run(~setup, ~draw, ()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Simple Fractal