Fun with sine and cosine

Posted by Nikolaus Gradwohl Fri, 24 Oct 2008 04:22:00 GMT

I just played a bit with sine and cosine and got a very nice picture. the code takes some time to run, so i post a pregenerated image this time.

float r;
void setup() {
  size(600,600);
  smooth();
  r = max( width/2, height/2) * 0.8;
  noLoop();
}
void draw() {
  background(0);
  stroke( 255, 2 );
  strokeWeight(2);
  lines( 4 );
  filter( BLUR, 4 );
  stroke( 255, 6 );
  strokeWeight(1);
  lines( 2);
}

void lines( float factor ) {
  for ( int j = 0; j < 360 * 10 * factor; j++ ) {
    float i = j/factor;
    line( width/2 - r * cos( radians( i / 2.1 )), 
          height/2 - r * sin( radians( i  )),
          width/2 - r * sin( radians ( i / 1.01  )),
          height/2 - r * cos( radians( 180 - i ))
    );
  }
}

Tags ,  | 1 comment

Tweet This! submit to reddit Digg!

Comments

  1. wizzarde said 2 days later:

    Jau, that is realy beautifull!

(leave url/email »)

   Comment Markup Help Preview comment