Daily Creative Coding

元「30 min. Processing」。毎日、Creative Codingします。

反復しながら線を描く

/**
* line repeat
*
* @author aa_debdeb
* @date 2016/12/10
*/

void keyPressed(){
  saveFrame("images/image.jpg");
}

float RADIUS = 200;
float speed1, speed2, speed3;
color c1 = color(255, 100, 100);
color c2 = color(255);

void setup(){
  size(500, 500);
  mousePressed();
}

void draw(){
  float x = map(sin(frameCount * speed1), -1, 1, -RADIUS, RADIUS);
  float r = map(abs(x), 0, RADIUS, RADIUS, 0);
  translate(width / 2 + x, height / 2);
  rotate(frameCount * speed2);
  stroke(lerpColor(c1, c2, map(sin(frameCount * speed3), -1, 1, 0, 1)), 100);
  line(0, 0, r, 0);
}

void mousePressed(){
  background(0, 0, 100);  
  speed1 = random(0.005, 0.03);
  speed2 = random(0.005, 0.03);
  speed3 = random(0.005, 0.03);
}
f:id:aa_debdeb:20161207071732j:plain