(Created page with " == Objektorientiertes Gestaltungsprogramm == == Segmente ==") |
|||
Line 3: | Line 3: | ||
== Segmente == | == Segmente == | ||
<source lang="Java">class Segmente { | |||
float x; // X-Position | |||
float y; // Y-Position | |||
float seg; // Segmentzähler | |||
int r; // Radius | |||
float g; // Richtung | |||
boolean mouseOver; //Maus über dem Objekt | |||
boolean visibel; //Objekt sichtbar | |||
int h,s,b; // Farbe HSB | |||
Segmente() { | |||
println("Segmente erstellt!"); | |||
} | |||
void maleSegmente() { | |||
fill(h,s,b); | |||
maleSegmente(seg,r,g,x,y); | |||
} | |||
void maleSegmente(float seg,int r,float g,float x,float y) { | |||
float segmentzahl = 3 + seg; | |||
float angleStep = 360/segmentzahl; | |||
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(); | |||
} | |||
} | |||
</source> |
Revision as of 10:33, 23 January 2011
Objektorientiertes Gestaltungsprogramm
Segmente
class Segmente {
float x; // X-Position
float y; // Y-Position
float seg; // Segmentzähler
int r; // Radius
float g; // Richtung
boolean mouseOver; //Maus über dem Objekt
boolean visibel; //Objekt sichtbar
int h,s,b; // Farbe HSB
Segmente() {
println("Segmente erstellt!");
}
void maleSegmente() {
fill(h,s,b);
maleSegmente(seg,r,g,x,y);
}
void maleSegmente(float seg,int r,float g,float x,float y) {
float segmentzahl = 3 + seg;
float angleStep = 360/segmentzahl;
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();
}
}