Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Quadratic Bézier paths #34

Merged
merged 3 commits into from May 14, 2015
Merged

Conversation

dbworku
Copy link
Contributor

@dbworku dbworku commented May 8, 2015

Adds support for:

  • Quadratic Bézier (Q,q)
  • Smooth quadratic Bézier (T,t)

SVG 1.1: Quadratic Bezier Commands

Note: NSBezierPath doesn't support adding quadratic curves. The approximation using the cubic bezier function should be very accurate unless the path is scaled extremely large.

Adds support for:
Q,q = Quadratic Bézier
T,t = Smooth quadratic Bézier
@arielelkin
Copy link
Collaborator

Hey @dbworku , thanks for this pull request.

I tested it with a couple of SVGs with q and t, it works fine :)

Question: why did you do those modifications to appendSVGMCommand and appendSVGCCommand?

Cheers

Ariel

@dbworku
Copy link
Contributor Author

dbworku commented May 11, 2015

@arielelkin I created the PocketSVGControlPoint enum (and modified the other methods) because the last control point's validity depends on which curve set the point.

8.3.7 The quadratic Bézier curve commands

If there is no previous command or if the previous command was not a Q, q, T or t, assume the control point is coincident with the current point.

8.3.6 The cubic Bézier curve commands

If there is no previous command or if the previous command was not an C, c, S or s, assume the first control point is coincident with the current point.

We need to update the control point's state in all methods. However, your question brings up that appendSVGSCommand is actually not fully compliant. I'll make a commit on this pull and bump you.

@arielelkin
Copy link
Collaborator

Sounds good!

- Replace check if index == 0 and while statement into
`doesValenceMatch` method that produces more descriptive logging when
the parameters are insufficient
- Compute `[token command] == ` once per append command.
- Prevent Q and S control points from mixing
- Q and S use last point drawn as control if the previous command did
not produce a control point of that type.
- Move to point was producing a line after it moved to that point
@dbworku
Copy link
Contributor Author

dbworku commented May 11, 2015

@arielelkin How does it look?

- L style commands should have 2 parameters
- Fix logging on unichar
arielelkin added a commit that referenced this pull request May 14, 2015
Support Quadratic Bézier paths
@arielelkin arielelkin merged commit f69e180 into pocketsvg:master May 14, 2015
@arielelkin
Copy link
Collaborator

Pretty good, thank you!

barakwei pushed a commit to Lightricks/PocketSVG that referenced this pull request Sep 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants