Problem when trying to create two separate arcs

Hi everyone! I am new to OF and, in my exercise, I try to create two arcs side by side by using ofPath. However, I have problems with creating the second one.

My code for the first one is:

ofPath path;

float startAngle = 110;

float endAngle = -110;

float radius = 45;

    path.arc (550, 285, radius, radius, startAngle, endAngle);

    path.setCircleResolution (100);

    path.setStrokeWidth (2);

    path.setColor ((130, 116, 81));

    path.setFilled ( **false** );

    path.draw ();

The problem is the second arc . I want its radius to be a bit smaller, and I would also like to change the start and end angle - and of course I want a different X and Y. However, I get the error while trying to create this (in the picture). The answer is probably very simple, has anyone have suggestions?

Adding { :s leads to errors.

Also, “path.setColor ((130, 116, 81));” is not giving me the brown shade that I want, I think it just creates the first value 130 = grey.

Many thanks if you can help!


Ok an update; this does not create errors, but the first arc is now forming a closed shape I don’t wish to get:

Hi @juss,

I think it appear to be that your path has been defined twice.
Same for the startAngle, endAngle, and radius.

You can either :
solution 1 : name them differently,
solution 2 : just not re-declare them, and simply overwrite their values.
solution 3 : create a function in which they would live, and call its parameters as many times as you want.

solution 1 implementation :

ofPath path1, path2;
float startAngle1, startAngle2;
float endAngle1, endAngle2;
float radius1, radius2;

path1.arc(550, 285, radius1, radius1, startAngle1, endAngle1);
// [...] rest of the code with the names corresponding to path1
path2.arc(550, 285, radius2, radius2, startAngle2, endAngle2);
// [...] rest of the code with the names corresponding to path2

solution2 implementation :

// after the first path.draw();
startAngle = 110;
// [...] etc

solution 3 :
in ofApp.h :

in ofApp.cpp :

ofPath path;
path.arc(position.x, position.y, radius, radius, startAngle, endAngle);
//[...] resolution set, stroweight, color, filling and draw.

Hope thius helps.



1 Like

yes you called the path.close() method which will close the path you are using.

Hi @pierre_tardif00, I tried solution 1 and it worked instantly! Many many thanks for your help and detailed instructions, it all makes sense now :slight_smile:

1 Like