openFrameworks
openFrameworks copied to clipboard
ofDrawCurve() does not draw a curve from the first point (x1,y1)
I was goofing around with ofDrawCurve() in relation to this forum thread when I realized that the point from which the curve is drawn is slightly offset from the x1, y1 arguments of the function. The amount of offset varies with the position of the control points.
This is the existing function:
void ofDrawCurve(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3){ ofGetCurrentRenderer()->getPath().clear(); ofGetCurrentRenderer()->getPath().curveTo(x0,y0); ofGetCurrentRenderer()->getPath().curveTo(x1,y1); ofGetCurrentRenderer()->getPath().curveTo(x2,y2); ofGetCurrentRenderer()->getPath().curveTo(x3,y3); ofGetCurrentRenderer()->draw(ofGetCurrentRenderer()->getPath());//.draw(); }
The curve is drawn from the first point (x1, y1) without an offset if a .moveTo() step is added:
void ofDrawCurve(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3){ ofGetCurrentRenderer()->getPath().clear(); ofGetCurrentRenderer()->getPath().moveTo(x1,y1); ofGetCurrentRenderer()->getPath().curveTo(x0,y0); ofGetCurrentRenderer()->getPath().curveTo(x1,y1); ofGetCurrentRenderer()->getPath().curveTo(x2,y2); ofGetCurrentRenderer()->getPath().curveTo(x3,y3); ofGetCurrentRenderer()->draw(ofGetCurrentRenderer()->getPath());//.draw(); }
I'm not sure if this is the correct way to fix it, or if the existing behavior is intentional.