Daily Creative Coding

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

ヘノンアトラクター

/**
* Henon Attractor
*
* @author aa_debdeb
* @date 2016/01/27
*/

float alpha = 1.4;
float beta = 0.3;

float x, y;

void setup(){
  size(500, 500);
  smooth();
  frameRate(360);
  background(0);

  x = map(random(1), 0, 1, -0.1, 0.1);
  y = map(random(1), 0, 1, -0.1, 0.1);

}

void draw(){
  stroke(255, 69, 0);
  translate(width / 2, height / 2);
  float nextX = 1 - alpha * sq(x) + y;
  float nextY = beta * x;
  x = nextX;
  y = nextY;
  float sx = map(x, -1.5, 1.5, -250, 250);
  float sy = map(y, -0.5, 0.5, -250, 250);
  point(sx, sy);
}