Saturday, August 22, 2009

dorkbot09v7

// just type here
// and click "submit" when done

// ms it will take snap back
int snapTime = 1200;

// time we start snapping
int startSnapTime;

// last rotation position
float lastRotate = 0.0;

int pmouseX = 0;


void setup(){
  size (300,300);
  startSnapTime = millis();
  pmouseX = mouseX;
  strokeWeight(10.0);
  strokeJoin(BEVEL);
  stroke(153);
}
  
void draw()
{
  //erase bg slightly...
  fill(20,30,40,20);
  rect(0,0,width,height);


  int dmouse = mouseX - pmouseX;

  pmouseX = mouseX;


  if (abs(dmouse) > 0)
  {
    // reset start snap time
    startSnapTime = millis();

    lastRotate = map(mouseX, 0, width, 0.0, TWO_PI);
    
    pushMatrix();
    translate(width/2, height/2);
    rotate(lastRotate);
    ellipse(0,0,100+mouseX/4,100);
    popMatrix();
  }
  else
  {
     float timeDiff = millis() - startSnapTime;
     if (timeDiff > snapTime) timeDiff = snapTime;
     pushMatrix();
      translate(width/2, height/2);
      rotate((float)timeDiff/(float)snapTime *lastRotate);
    int r = map(timeDiff, 0, snapTime, 0, 255);
    
    int pulse = ceil(255.0*(0.5 + sin(millis())*0.5));
    

    fill(r, 50, 120, 30);
    ellipse(0,0,100+mouseX/4,100);
    popMatrix();
  }
}

info info

submitted by: evanraskob
views: 2025
monkey noises!!!!

treeThis sketch has a parent
Tags: dorkbot

comments comment

loading loading...

 

Add a comment: