//qSinus Color Wave Demo
//by Rick Companje
//www.companje.nl
//18-11-2007

void setup() {
  size(500,300);
  colorMode(HSB,1);
  background(0);
  smooth();
}

void draw() {
  fill(0,0,0,.1);
  noStroke();
  rect(0,0,width,height);
  
  beginShape();
  for (float x=-PI; x<PI; x+=.1) {
    float sinX = 1.2732395*x + (0.4052847*x*x) * (x<0?1:-1);    
    float mx = float(mouseX)/width;
    float my = float(mouseY)/height;
    stroke(mx,1,1,sinX);
    if (!mousePressed) fill(mx,1,1,sinX); else noFill();
    vertex(width/2+(x/TWO_PI*width)*(2*mx-1), height/2+(sinX*height/2)*(2*my-1));
  }
  endShape();
}

void keyPressed() {
  saveFrame("sine-####.png");
}