(Created page with " == Mehrere Formen == float seg = 0; //Segmentzähler void setup() { size(600, 600); smooth(); noStroke(); } void draw() { background(0); for (float i=0; i<=400; i+=...") |
|||
(5 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== Gedrehte Formen == | |||
== | <source lang="Java" highlight="11">float seg = 0; | ||
float seg = 0; | |||
void setup() { | void setup() { | ||
size( | size(800, 800); | ||
smooth(); | smooth(); | ||
frameRate(5); | |||
} | } | ||
void draw() { | void draw() { | ||
background(0); | background(0); | ||
for ( | for (int i = 0; i<=360; i++) { | ||
maleSegmente( | maleSegmente(300,400,400,i); | ||
} | } | ||
} | } | ||
void maleSegmente(int r,float x,float y) { | void maleSegmente(int r,float x,float y, float grad) { | ||
float segmente = 0; | float segmente = 0; | ||
segmente = 3 + seg; | segmente = 3 + seg; | ||
Line 27: | Line 24: | ||
vertex(x, y); | vertex(x, y); | ||
for (float angle=0; angle<=360; angle+=angleStep) { | for (float angle=0; angle<=360; angle+=angleStep) { | ||
float vx = x + cos(radians(angle- | float vx = x + cos(radians(angle-grad))*r; | ||
float vy = y + sin(radians(angle- | float vy = y + sin(radians(angle-grad))*r; | ||
vertex(vx, vy); | vertex(vx, vy); | ||
vertex(x,y); | |||
vertex(vx,vy); | |||
} | } | ||
vertex(x + cos(radians( | vertex(x + cos(radians(360-grad))*r, y + sin(radians(360-grad))*r); | ||
endShape(); | endShape(); | ||
} | } | ||
void | void keyReleased() { | ||
if (key == CODED) { | if (key == CODED) { | ||
if (keyCode == UP) { | if (keyCode == UP) { | ||
Line 46: | Line 45: | ||
} | } | ||
} | } | ||
</source> |
Latest revision as of 17:55, 23 January 2011
Gedrehte Formen
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,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;
}
}
}
}