# Draw an arc of a RING.

Hi there!

I’m trying to draw an arc of a RING, not a circle. In processing this is easy done with the arc() function that have an Mode where you can choose the type of arc. But i can’t find it in OF. Maybe there another way to do this.

Can anyone help me with this?
thanks
JF

ofPolyLine and ofPath have a similar function to processing…

``````

ofPolyline curve;
curve.draw();

``````

Or you can code it manually…

``````

vector<ofPoint> testApp::getArcPoints(ofVec2f centre, float radiusX, float radiusY, float startAngle, float endAngle, int arcResolution) {
int index = 0;
vector<ofPoint> points(resizeTo);
points[index].x = cos(i) * radiusX + centre.x;
points[index].y = sin(i) * radiusY + centre.y;
index++;
}
return points;
}

``````
1 Like

Hi trentbrooks!

But the that will draw an arc of circle, i want to draw an arc of a ring(Like a slice of a donut).
Do you know if this is possible? is there any function to that in OF?

cheers
dot

Try this :

``````

ofPath curve;
ofPoint p(ofGetWindowWidth() / 2, ofGetWindowHeight() / 2);
curve.arc(p, 300, 300, 0, 210);
curve.arcNegative(p, 200, 200, 210, 0);
curve.close();
curve.setArcResolution(60);
ofColor c(255, 0,0);
curve.setFillColor(c);
curve.setFilled(true);
curve.draw();

``````
3 Likes