No edit summary |
|||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== | == Bauhaus Formen == | ||
<source lang="Java"> | <source lang="Java" highlight="12,14,16"> | ||
float seg = 0; //Segmentzähler | float seg = 0; //Segmentzähler | ||
Latest revision as of 17:59, 23 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;
}
}
}
}