Add ofPolyline to ofPath


#1

I’m converting someone’s oF 9 code to 10 and they’re appending a polyline to a path by :

path.getOutline().push_back(poly);

but this no longer works as getOutline returns a const ofPolylines object. Is there another way to do it?

thanks!

Seb


#2

Hi,
You can add the polyline points one by one:

path.moveTo( polyline[0] );
for( size_t i = 1; i < polyline.size(); ++i ) path.lineTo( polyline[ int(i) ] );

If the path is not empty, you have to call path.newSubPath() first:

path.newSubPath();
path.moveTo( polyline[0] );
for( size_t i = 1; i < polyline.size(); ++i ) path.lineTo( polyline[ int(i) ] );

#3

thanks for that, I was kinda hoping there’d be a less manual way but that works :slight_smile:


#4

Perhaps, but never found it ! :smiley: