Archived Sketch

This sketch is created with an older version of Processing,
and doesn't work on browsers anymore.

View Source Code

Click record or press 'R'
to start/stop recording (max. 10 secs)

Click capture
to take a screenshot


Sierpinski

// Hover mouse horizontally to change depth WIDTH = 700; X_MIN = 0; X_MAX = 1; Y_MIN = 0; Y_MAX = 1; RATIO = AUTO; MOUSE_MOVE = true; int sierpinski(u, v, w, h, depth, maxdepth) { int val = ((int)(u/w * 3) % 2) * ((int)(v/h * 3) % 2); if(val==0 && depth<maxdepth) { return sierpinski((u*3 % w)/3, (v*3 % h)/3, w/3, h/3, depth+1, maxdepth); } else return val; } color rgb(x, y) { return color(sierpinski(x,y,X_SPAN,Y_SPAN, 1, maxdepth) * 255); } int maxdepth = -1; bool preDraw(t) { int d = (int)(mouseX/width*6) +1; bool doit = maxdepth!=d; maxdepth = d; return doit; }

Sierpinski

// Hover mouse horizontally to change depth WIDTH = 700; X_MIN = 0; X_MAX = 1; Y_MIN = 0; Y_MAX = 1; RATIO = AUTO; MOUSE_MOVE = true; int sierpinski(u, v, w, h, depth, maxdepth) { int val = ((int)(u/w * 3) % 2) * ((int)(v/h * 3) % 2); if(val==0 && depth<maxdepth) { return sierpinski((u*3 % w)/3, (v*3 % h)/3, w/3, h/3, depth+1, maxdepth); } else return val; } color rgb(x, y) { return color(sierpinski(x,y,X_SPAN,Y_SPAN, 1, maxdepth) * 255); } int maxdepth = -1; bool preDraw(t) { int d = (int)(mouseX/width*6) +1; bool doit = maxdepth!=d; maxdepth = d; return doit; }
e.g. "mouse, keyboard"
e.g. "visualization, fractal, mouse"
learn more about Creative Commons

As a Plus+ Member feature, this source code is hidden by the owner.