(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...") |
|||
Line 2: | Line 2: | ||
== Bauhaus Formen == | == Bauhaus Formen == | ||
float seg = 0; //Segmentzähler | <source lang="Java">float seg = 0; //Segmentzähler | ||
void setup() { | void setup() { | ||
Line 13: | Line 13: | ||
background(0); | background(0); | ||
fill(255,255,0); | fill(255,255,0); | ||
maleSegmente(100, | maleSegmente(100,mouseX,mouseY,0,90); | ||
fill(255,0,0); | fill(255,0,0); | ||
maleSegmente(100, | maleSegmente(100,mouseX*2,mouseY*2,1,45); | ||
fill(0,0,255); | fill(0,0,255); | ||
maleSegmente(80, | maleSegmente(80,mouseY,mouseX,40,90); | ||
} | } | ||
Line 47: | Line 47: | ||
} | } | ||
} | } | ||
</source> |
Revision as of 21:09, 14 January 2011
Bauhaus Formen
float seg = 0; //Segmentzähler
void setup() {
size(800, 800);
smooth();
noStroke();
}
void draw() {
background(0);
fill(255,255,0);
maleSegmente(100,mouseX,mouseY,0,90);
fill(255,0,0);
maleSegmente(100,mouseX*2,mouseY*2,1,45);
fill(0,0,255);
maleSegmente(80,mouseY,mouseX,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;
}
}
}
}