Howdy, Stranger!

We are about to switch to a new forum software. Until then we have removed the registration on this forum.

How to control the interpolation of an ellipse?

How does processing determine how many segments an ellipse or stroke is made of? Is there a way to increase or decrease the amount of sides an ellipse has?

• In 3D this would be sphereDetail for a sphere...

• iirc, the ellipse method chooses this for you, based on the size of the ellipse (more segments for bigger ellipses)

see the accuracy variable here:

https://github.com/processing/processing/blob/f434d2c2303c8d03e265e14972b652c595e6cdf7/core/src/processing/opengl/PGraphicsOpenGL.java#L8756

• So, if I were to use scale(); I'd be able to see the individual lines?

• try it. it's 10 lines of code.

• 3 lines. and apparently no.

``````size(1000, 1000);
scale(100);
ellipse(5, 5, 4, 4);
``````
• edited April 2018

If you make an ellipse yourself with beginShape, endShape and a for-loop, you can define the number of sides.

``````size(200, 200);
int sides = 10;
float cx = width * 0.5;
float cy = height * 0.5;
float w = width * 0.5;
float h = height * 0.25;
beginShape(POLYGON);
for(int i = 0; i < sides; ++i) {
float theta = TWO_PI * i / float(sides);
vertex(cx + w * cos(theta), cy + h * sin(theta));
}
endShape(CLOSE);
``````

For line segments

``````size(200, 200);
strokeWeight(2);
int detail = 3;
float startx = width * 0.25;
float starty = height * 0.25;
float stopx = width * 0.75;
float stopy = height * 0.75;
float prevx, prevy, currx = startx, curry = starty;
for(int i = 0; i < detail + 1; ++i) {
prevx = currx;
prevy = curry;
float step = i / float(detail);
currx = lerp(startx, stopx, step);
curry = lerp(starty, stopy, step);
stroke(lerpColor(0xffff0000, 0xff0000ff, (i - 1) / float(detail - 1), HSB));
line(prevx, prevy, currx, curry);
}
``````

I don't know about your first question, but I'm guessing it depends on the underlying renderer that Processing uses; the default is based on the AWT library. See the source code for more.