Ellipse on circle, why is there an extra?
in
Programming Questions
•
1 year ago
Hello!
I have numPoints set to 1 but when the program runs there are two ellipses. Why is this happening?
Thanks!
- float x, y, radius, angle;
- int numPoints;
- void setup() {
- size(500,500,P3D);
- background(255);
- fill(0);
- smooth();
- radius = 100;
- numPoints = 1;
- angle = TWO_PI/numPoints;
- }
- void draw() {
- background(255);
- pushMatrix();
- translate(width/2,height/2);
- noFill();
- strokeWeight(2);
- stroke(200);
- ellipse(0,0,radius*2,radius*2);
- for (int i = 0; i <= numPoints;i++) {
- noStroke();
- fill(255,0,0);
- x = sin(angle*i)*radius;
- y = cos(angle*i)*radius;
- rotate(radians(frameCount));
- ellipse(x,y,15,15);
- }
- popMatrix();
- }
1