Skip to content

Instantly share code, notes, and snippets.

@broerjuang
Created June 8, 2018 19:34
Show Gist options
  • Save broerjuang/1f529417fc785d13f6a52d2701825630 to your computer and use it in GitHub Desktop.
Save broerjuang/1f529417fc785d13f6a52d2701825630 to your computer and use it in GitHub Desktop.
simple fractal 1
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, ());
@broerjuang
Copy link
Author

Simple Fractal

screen shot 2018-06-09 at 2 10 27 am

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