Digital Bauhaus Vorkurs/Projekte/Form und Raum/Code1a: Difference between revisions

From Medien Wiki
(Created page with " == Gedrehte Form == float seg = 0; void setup() { size(800, 800); smooth(); frameRate(5); } void draw() { background(0); for (int i = 0; i<=360; i++) { maleSegm...")
(No difference)

Revision as of 21:45, 14 January 2011

Gedrehte Form

float seg = 0;

void setup() {

 size(800, 800);
 smooth();
 frameRate(5);

}

void draw() {

 background(0);
 for (int i = 0; i<=360; i++) {
   maleSegmente(300,400,400,90+i);
 }

}

void maleSegmente(int r,float x,float y, float grad) {

 float segmente = 0;
 segmente = 3 + seg;
 float angleStep = 360/segmente;
 beginShape();
 vertex(x, y); 
 for (float angle=0; angle<=360; angle+=angleStep) {
   float vx = x + cos(radians(angle-grad))*r;
   float vy = y + sin(radians(angle-grad))*r;
   vertex(vx, vy);
   vertex(x,y);
   vertex(vx,vy);
 }
 vertex(x + cos(radians(360-grad))*r, y + sin(radians(360-grad))*r);
 endShape();

}

void keyReleased() {

 if (key == CODED) {
   if (keyCode == UP) {
     seg += 1;
   } else if (keyCode == DOWN) {
     if (seg >= 1) {
       seg -= 1;
     }
   } 
 }

}