My partial circle looks weird

I’ve pasted the code below. the end result is broken partial circle (with correct angle and position), and the color is always white. it looks like i went into mspaint and used the spraycan. I assume it’s something to do with the circle resolution.

    ofSetColor(ofColor::fromHex(0x876765));
    ofPath path;
    path.setCircleResolution(360);
    //path.setCurveResolution(255);
    ofPoint startPoint(moon.GetDrawPoint());
    startPoint.x -= sin(180 - m_fFirstBound) * m_radius;
    startPoint.y += cos(180 - m_fFirstBound) * m_radius;
    path.moveTo(startPoint);
    path.arc(moon.GetDrawPoint(), m_radius, m_radius, m_fFirstBound - 90, m_fSecondBound - 90);
    path.setFilled(false);
    path.setStrokeWidth(7);
    path.draw();

its the stroke width: small but thick lines don’t get placed together correlcty (google for line caps and joins).

You can workaround this by making a shape comprised of 2 arcs (inner & outer); finally filling the shape with a color.

Eg:

		ofPath p;
	p.setArcResolution(100);
	p.arc(0,0,circleRadiusOuter-7,circleRadiusOuter-7, 0, 360.*percentage);
	p.arcNegative(0,0,circleRadiusOuter,circleRadiusOuter, 360.*percentage, 0);
	p.close();
	p.setFilled(true);
	p.setUseShapeColor(true);
	p.setColor(ofColor(0,153,0,255));
	p.setFillColor(ofColor(0,153,0,255));
	p.setStrokeColor(ofColor(0,153,0,255));
2 Likes

cheers mate, works lovely.