Open damian0815 opened 12 years ago
wow that was really long.
"it doesn't look like i'm doing anything wrong. i expect it to work, and when it doesn't i become confused and angry"
I think this applies to all programming ...
something has fundamentally changed about ofPath or there is a bug right now that is keeping me from drawing non-filled ofPaths -- but the question is relevant and needs to be looked into to create a more natural API i think.
#include "ofMain.h"
class ofApp : public ofBaseApp {
public:
void setup() {
}
void draw() {
ofBackground(0);
ofPath path;
path.moveTo( 100, 100 );
path.lineTo( 150, 100 );
path.curveTo( 200, 150 );
path.lineTo( 200, 200 );
path.setColor(ofColor::white);
// path.setFilled(false);
path.draw();
}
};
int main() {
ofSetupOpenGL(300, 300, OF_WINDOW);
ofRunApp(new ofApp());
}
as per email discussion beginning http://dev.openframeworks.cc/htdig.cgi/of-dev-openframeworks.cc/2012-April/004332.html
i'd like to propose a couple of changes to the way ofPath works around handling Catmull-Rom and Bezier segments.
i'm calling this code:
when i read this i'm visualizing a horizontal line segment and a vertical line segment with a curve smoothly connecting them, something like this (no.1):
or at least (though less desirable), this (no.2):
what i actually get is this (no.3)
whether it's a bug or not, i think no.3 is wrong. i asked for a curve! where's my curve? also why is my 3rd point being completely ignored?
possible objections to this line of thinking (aka, what Arturo said):
(there's an analogous case here for bezierTo: if i'm coming out of or joining to a straight line segment or another curve i would like an option for my bezier handles to be calculated automatically; similarly it'd be nice to have an option to automatically mirror a previous bezier segment's handle for the first control point to bezierTo, in order to avoid making a corner.)
so, what is the correct behaviour with this code?
to me, it's something like no.1, a horizontal line segment and a vertical line segment with a curve smoothly connecting them.
does anyone else expect something different?
if not, let's make ofPath work this way!
notes:
source to generate no.3:
for image no.1 substitute:
(there are other viable locations for the bezier control handles here, but i like the way this one looks. it's easy to calculate mathematically: cast a ray from [1] in the same direction as the [0]->[1] line segment, and find the point along the ray at (say) 1/3 of the distance between [1] and [2]; this is your first control point. do something similar for the second control point.)
image no.2 is generated by
this is pretty ugly code and unfortunately it creates corners at points[1] and points[2] which isn't correct in my opinion.