What is the most efficient way of creating coloured semi circles?

I am currently attempting to create a replication of this image in Open Frameworks:

I have figured out how to trace over several shapes with the ofBeginShape function, however I am stuck on the curved sections. I know how to do it in processing but it seems a bit more complicated in Open Frameworks. I have attempted to draw 1 semi circle shape so far using this code:

It has produced this result:

I would like to know if there is a more efficient way of doing this, I also need to know how to change the colour of the shape and improve its resolution. Any advice would be appreciated!

Hey @Harryw12345, ofBeginShape() is probably a fine way of drawing. There are other ways. For example, you could use an ofPolyline and curveTo(). To address the issues with ofBeginShape(), I would try the following things from the ofGraphics section of the Graphics page of the documentation:


  1. ofSetCurveResolution() to increase the resolution of the curve
  2. ofSetColor() to change the color before drawing with ofBeginShape()
  3. ofFill() and ofNoFill() to change whether the shape is filled or not


I managed to draw the semi circles with the ofPath function. below is an example of my code:

I am still stuck on getting the colours right, as well as getting them to blend alphas. I have tried using the ofSetColor function but that hasnt worked, at the moment I can only get it to be between white and black. Below is an example of the output:

If you want to fill with a color (instead of shades of gray), try using an ofColor with 3 (or 4) unsigned chars (values from 0 to 255):

ofColor color;
color = ofColor(255, 0, 0) // RGB red
color = ofColor(255, 0, 0, 100); // RGBA translucent red

// then use it
ofPath curve;

Also, try using an ofColor with ofSetColor, instead of 4 args:

ofColor nextColor;
nextColor = ofColor(0, 0, 255); // blue

// or make a color and use it in 1 statement
ofSetColor(ofColor(0, 0, 255));

Have a look at the ofColor section of the Types page of the documentation for more details (different kinds of colors and ways to create and modify them). There are also a bunch of predefined colors.

Also, oF has an extensive set of examples that come with it. So have a look at the ones in the “graphics” folder; in particular the /examples/graphics/blendingExample and …/colorExample might be helpful.

Also, the forum has a way to post code with the </> symbol, where you can copy/paste and edit code from your project as needed.

Hope this helps!

ofPath only allows you to have a single color per path.you can still use a color with transparency but might not be what you are looking for.
look at this ofBook chapter. It is a bit more complex but will give you a lot more control over how you draw any shape.