703
edits
(Created page with " == Springende Formen == == Segmente ==") |
|||
Line 3: | Line 3: | ||
== Segmente == | == Segmente == | ||
<source lang="Java">class Segmente { | |||
float x; // X-Position | |||
float y; // Y-Position | |||
int seg; // Segmentzähler | |||
int r; // Radius | |||
float g; // Richtung | |||
boolean mouseOver; //Maus über dem Objekt | |||
boolean visible; //Objekt sichtbar | |||
int h,s,b,a; // Farbe HSB und Alpha | |||
float vx,vy; //Geschwindigkeit | |||
Segmente() { | |||
println("Segmente erstellt!"); | |||
} | |||
void maleSegmente() { | |||
fill(h,s,b,a); | |||
maleSegmente(seg,r,g,x,y); | |||
} | |||
void maleSegmente(int seg,int r,float g,float x,float y) { | |||
float segmentzahl = 3 + (float)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> |
edits