openframeworks / openframeworks/openFrameworks

ofDrawCurve() does not draw a curve from the first point (x1,y1)

Open
#7,044 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
10.4k
Forks
2.6k
Avg merge
1d 21h
Merged PRs (30d)
9

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the ofDrawCurve() entry point shown in the issue and inspect how getPath().curveTo() handles its first point. Compare the existing sequence with the proposed moveTo(x1,y1) sequence, and check related path-drawing tests if available. Done means confirming the intended behavior and ensuring the curve begins at (x1,y1) without introducing regressions.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.