PROCESSING | Sketch Interactivo 3

PROCESSING | Sketch Interactivo 3



float x;
float y;
float a;
float aDelta = 1;
float g;
float gDelta = 0.4;
float h;
float hDelta = 0.4;
float easing = 0.05;

void setup() {
  size(640, 640);
  frameRate(60);
  background(51);
  noStroke();  
}

void draw() { 

  float targetX = mouseX;
  float dx = targetX - x;
  x += dx * easing;
  
  float targetY = mouseY;
  float dy = targetY - y;
  y += dy * easing;
  
  ellipse(x, y, g, h);
  g = g + gDelta;
  h = h + hDelta;
  fill(a);
   a = a + aDelta;
  
  if(a > 255 || a < 0) {
    aDelta = -aDelta;
  }
  
  if(g > 60 || g < 0) {
    gDelta = -gDelta;
  }
  
  if(h > 60 || h < 0) {
    hDelta = -hDelta;
  }
  
  if(mousePressed) {
  a = random(255);
  }
}

 void keyPressed(){
 background(51);
 }

0 comentarios:

Publicar un comentario