Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Re : animation pausing

$
0
0
  1. class Blip{
  2.   float x, y;
  3.   int redness;
  4.   Blip(float x, float y){
  5.     this.x=x;
  6.     this.y=y;
  7.     redness=0;
  8.   }
  9.   void draw(){
  10.     if( redness < 256 ) redness+=5;
  11.     fill(redness, 0, 0);
  12.     ellipse(x,y,10,10);
  13.   }
  14. }

  15. ArrayList blips = new ArrayList();
  16. float lastX, lastY;

  17. void setup(){
  18.   size(400,400);
  19.   smooth();
  20.   noStroke();
  21.   lastX = width / 2.0;
  22.   lastY = height / 2.0;
  23.   ellipseMode(CENTER);
  24. }

  25. void draw(){
  26.   background(0);
  27.   for( int i = 0; i < blips.size(); i++ ){
  28.     Blip temp = (Blip) blips.get(i);
  29.     temp.draw();
  30.   }
  31. }

  32. void mouseClicked(){
  33.   lastX = (lastX + mouseX) / 2.0;
  34.   lastY = (lastY + mouseY) / 2.0;
  35.     blips.add( new Blip( lastX, lastY ) );
  36. }

Viewing all articles
Browse latest Browse all 1768

Trending Articles