Looks better:
Code:void draw() {
println(currentAngle);
float xcFirst = GetXPosition(0);
float ycFirst = GetYPosition(0);
float xc = 0, yc = 0;
pg.beginDraw();
pg.background(0);
pg.fill(#FF0000);
pg.ellipse(xcFirst, ycFirst, 8, 8);
pg.stroke(255);
pg.fill(100, 255, 255, 100);
pg.beginShape();
pg.vertex(xcFirst, ycFirst);
pg.curveVertex(xcFirst, ycFirst);
pg.curveVertex(xcFirst, ycFirst);
for (int angle = ANGLE_STEP; angle < currentAngle; angle += ANGLE_STEP) {
xc = GetXPosition(angle);
yc = GetYPosition(angle);
pg.curveVertex(xc, yc);
}
pg.curveVertex(xcFirst, ycFirst);
pg.endShape();
pg.fill(#FFFF00);
pg.ellipse(xc, yc, 8, 8);
pg.endDraw();
image(pg, 0, 0);
if (currentAngle < 361)
currentAngle += ANGLE_STEP;
}
so the code you look for should be:
Code:PGraphics pg;
int ANGLE_STEP = 36;
void setup() {
frameRate(60);
background(0);
size(800, 600);
pg = createGraphics(800, 600, P3D);
}
void draw() {
float xcFirst = GetXPosition(0);
float ycFirst = GetYPosition(0);
float xc = 0, yc = 0;
pg.beginDraw();
pg.background(0);
pg.stroke(255);
pg.fill(100, 255, 255, 100);
pg.beginShape();
pg.vertex(xcFirst, ycFirst);
pg.curveVertex(xcFirst, ycFirst);
pg.curveVertex(xcFirst, ycFirst);
for (int angle = ANGLE_STEP; angle < 361; angle += ANGLE_STEP) {
xc = GetXPosition(angle);
yc = GetYPosition(angle);
pg.curveVertex(xc, yc);
}
pg.curveVertex(xcFirst, ycFirst);
pg.vertex(xcFirst, ycFirst);
pg.endShape();
pg.endDraw();
image(pg, 0, 0);
}
float GetXPosition(float angle)
{
return cos(radians(angle)) * random(90, 100) + width/2;
}
float GetYPosition(float angle)
{
return sin(radians(angle)) * random(90, 100) + height/2;
}
although the end of loop isn't very nice.