> show canvas only <


/* built with Studio Sketchpad: 
 *   https://sketchpad.cc
 * 
 * observe the evolution of this sketch: 
 *   https://studio.sketchpad.cc/sp/pad/view/ro.B9c6xlp0N87/rev.1971
 * 
 * authors: 
 *   
 *   
 *   
 *   
 *   
 *   Mike Kamermans
 *   
 *   annasob
 *   
 *   
 *   
 *   
 *   
 *   
 *   lonnen
 *   

 * license (unless otherwise specified): 
 *   creative commons attribution-share alike 3.0 license.
 *   https://creativecommons.org/licenses/by-sa/3.0/ 
 */ 



/*
  Animated mandelbrot in 211 characters. Can this be made even smaller..?
  The challenge was to write something cool in 140 characters... I failed!
  - Mike "Pomax" Kamermans
  http://processingjs.nihongoresources.com
  
  it turns out: yes it can be made a lot smaller! lonnen, potch and
  no_wait_yes managed to apply some "well what if we abandon normal
  math and compress the hell out of the logic?" and managed to 
  come up with http://studio.sketchpad.cc/rB48bUnOBu ... see it to
  believe it! =)
*/
d=1;a=100;X r(x){return-1+x/a}X f(x){return a+x*a}X draw(){x=0;while(x++<a){y=0;while(y++<a){u=r(x);v=r(y);p=q=i=0;do{m=p*p;n=q*q;t=m-n+u;q=2*p*q+v;p=t}while(m+n<=4&&i++<255)stroke(~i<<d);point(f(u),f(v))}}d++}
/*
    how it works:
    
    // exploiting number overflow to get colors
    d=1;
    
    // shortcut for default width/height
    a=100;
    
    // mandelbrot requires scaling to [-1,1] domains
    // this is the most char-needing code at this point
    // note: no closing semicolon (ncsc)
    X r(x){return-1+x/a}
    X f(x){return a+x*a}
    
    // shorten draw return type
    X draw(){
        // start the mandelbrot loop. This
        // is nicely documented on wikipedia
        x=0;
        while(x++<a){    // if only vars were '0' on first use!
            y=0;
            while(y++<a){
                u=r(x); // scale 'x'
                v=r(y); // scale 'y'
                p=q=i=0; // i = iteration counter
                do{
                    // We fake complex numbers here
                    m=p*p;
                    n=q*q;
                    t=m-n+u;
                    q=2*p*q+v;
                    p=t // (ncsc)
                } while(m+n<=4 && i++<255) // (ncsc)

                // set up coloring by inverting
                // the iteration counter, and then
                // bitshifting it by 'd' bits.
                stroke(~i<<d);

                // draw the recolored, transformed point
                point(f(u),f(v)) // (ncsc)
            }
        }
        // increase the color shift. because we don't
        // wrap (that would take more to write), this
        // animation goes black once d reaches 20ish
        d++ // (ncsc)
    }
*/