Press escape to exit fullscreen

{{sketch.instructions}}

CC {{sketch.licenseObject.short}}

Archived Sketch

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

View Source Code

Capture Screenshot

Sierpinski

{{$t('general.by')}}
// 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; }
We recovered an unsaved version of this sketch. Please review your changes below.

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

  • {{co.title}}
    {{$t('sketch.mode-pjs')}} {{$t('general.learnMore')}}
    Select mode or a template
    {{liveCodeLink}}
    • {{l.url.substr(l.url.lastIndexOf('/') + 1)}}
    {{$t('sketch.layoutDescription')}}

    {{k.category}}
    {{k.label}}
    {{k.description}}

    {{$t('sketch.seeMoreShortcuts')}}

    Versions are only kept for 7 days.
    Join Plus+ to keep versions indefinitely!

    {{$t('general.joinPlus')}}


    {{$t('sketch.versionsSummarized')}}