• fullscreen
  • dot_the_spot.pde
  • PImage img;
    int s=512, minSize = 2;
    int steps = 5;
    
    dot mom;
    
    void setup() {
      size(s,s);
      img = loadImage("spot.jpg");
      img.resize(s,s);
      smooth(); noStroke();
      mom = new dot(s/2,s/2,s,s/2,s/2,s);
    }
    
    void draw() {
      background(0); 
      mom.draw();
    }
    
    void mouseMoved() {
      mom.interact();
    }
    
    class dot {
    
      boolean alife = true;  
      int x0, y0, d0, x, y, d;
      color c0, c;
      float t;
        
      dot[] kids;
    
      dot(int _x0, int _y0, int _d0, int _x, int _y, int _d) {
        x0=_x0; y0=_y0; d0=_d0; x=_x; y=_y; d =_d;  
        c = img.get(x,y); c0 = img.get(x0,y0);
      }
      
      void draw() {
        t = constrain(t + 1f/steps ,0,1);
        if(alife) { 
          float xt = lerp(x0, x, t), yt = lerp(y0, y, t), dt = lerp(d0, d, t); 
          color ct = lerpColor(c0, c, t);
          fill(ct); ellipse(xt,yt,dt,dt); 
        }
        else for(int i=0; i<4; i++) kids[i].draw();
      }
    
      void interact() {
        if(alife) { if (t==1 && d>minSize) giveBirth(); }
        else kids[(mouseX-x<0?2:0) + (mouseY-y<0?1:0)].interact();
      }
      
      void giveBirth() {
        int e = d/4, f = d/2;
        kids = new dot[] {
          new dot(x,y,d,x+e,y+e,f), new dot(x,y,d,x+e,y-e,f), 
          new dot(x,y,d,x-e,y+e,f), new dot(x,y,d,x-e,y-e,f)
        };
        alife = false;
      } 
    }
    
    

    code

    tweaks (0)

    about this sketch

    This sketch is running as Java applet, exported from Processing.

    license

    advertisement

    bitcraft
    hehe. good one.
    dotlassie
    6 Oct 2009
    Wow, it the 5000th sketch!
    Callum Rogers
    6 Oct 2009
    This is a really, really good sketch. Code isn't too long, either.
    Rob Costin
    7 Oct 2009
    finally, a Freudian function
    Jean-no
    7 Oct 2009
    freudian indeed, with an array called "mom" !
    Jean-no
    7 Oct 2009
    Note : the painting to find is Gustave Courbet's artwork.
    Starkes
    8 Oct 2009
    nice. the processing version works better.

    the original: http://www.cesmes.fi/
    bitcraft
    11 Oct 2009
    Of course it works better - it's powered by open source :-))
    But thanks for the flash link - I will add it to the credits!
    sam ng
    13 Oct 2009
    Cool!
    sam ng
    13 Oct 2009
    Cool!
    Fight With Dogma
    15 Nov 2009
    Master piece
    Barbara R
    3 Dec 2009
    I somehow feel like making fun about how the dots melt under the soft stroke of the cursor and about the influence of subconsciousness XD
    Sami
    18 Jun 2010
    not sure if want :)
    You need to login/register to comment.