Digital Bauhaus Vorkurs/Projekte/Form und Raum/Code3

From Medien Wiki
< Digital Bauhaus Vorkurs‎ | Projekte‎ | Form und Raum
Revision as of 21:06, 14 January 2011 by Anni (talk | contribs) (Created page with " == Bauhaus Formen == float seg = 0; //Segmentzähler void setup() { size(800, 800); smooth(); noStroke(); } void draw() { background(0); fill(255,255,0); maleSegm...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Bauhaus Formen

float seg = 0; //Segmentzähler

void setup() {

 size(800, 800);
 smooth();
 noStroke();

}

void draw() {

 background(0);
 fill(255,255,0);
 maleSegmente(100,200,200,0,90);
 fill(255,0,0);
 maleSegmente(100,200,400,1,45);
 fill(0,0,255);
 maleSegmente(80,200,600,40,90);

}

void maleSegmente(int r,float x,float y, float s, float g) {

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

}

void keyReleased() {

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

}