Categories
Uncategorized

Processing: Circle Square

Circle Square

I decided to draw a circle, but wanted to use a square to do it. Or at least that’s the explanation I’ll give…

See it in action here!

I really just wanted to play with rotating an object a bit more. Obviously this is 2D rotation… The 3D stuff I still find a bit more complex, but should be able to show something in that arena soon.

/*
 * 20110511.pde
 */

float a = 0;
int s = 255;

void setup() {
  size(800, 600);
  frameRate(30);
  background(0);
  strokeWeight(1);
  noFill();
}

void draw() {

  float c = cos(a);
  translate(width/2, height/2);
  rotate(c);
  rectMode(CENTER);
  stroke(0,s,0);
  rect(0, 0, 350, 350);
  
  a = a + 0.1;
  
  if (s < 1) {
   s = 255; 
  }
  
  s = s - 1;
    
}