Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Round caps/joins detail level #19

Tharit opened this Issue Oct 5, 2012 · 1 comment


None yet
2 participants

Tharit commented Oct 5, 2012

I'm opening this as an issue because I think my implementation might not yet be optimal..

The basic approach of calculation the number of steps by the circumference of the arc is fine.

But finding good approximizations for the detail level is difficult, and there is no real "right" way :)

What could be improved though:
#1 using ceilf instead of MAX(1, ... )
#2 adding the angle back into the calculation. For angles >= 90°, there should be at least 4 steps, to avoid triangular caps.
#3 agreeing on a suitable level of detail. I have observed various line widths and think one step for 5 pixels is okay, but thats just my opinion.

I think something like this might be much more "round" for small lines while adding only marginally more triangles.

int numSteps = ceilf( (angle2 * width2 * pxScale) / 5.0f );

if(numSteps==1) {

// avoid "triangular" look
if(fabsf(angle2)>M_PI_4*3 && numSteps==3) {

phoboslab commented Oct 5, 2012

EJPath's - (void)arcX:... actually could use some treatment too. It's currently always using 48 segments for a full circle, defined with EJ_PATH_STEPS_FOR_CIRCLE. To be honest, I'm not good at math and this seemed like a good solution :F

@phoboslab phoboslab closed this Jan 16, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment