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

Path.CCW() confusion #335

Closed
konskoehler opened this issue Feb 3, 2025 · 2 comments
Closed

Path.CCW() confusion #335

konskoehler opened this issue Feb 3, 2025 · 2 comments

Comments

@konskoehler
Copy link

Hey,

I have been experimenting with the Path functions and encountered a confusing result.

When I run:

canvas.MustParseSVGPath("M0 0H10V10H0z").CCW()

It returns true, even though the given SVG path is clearly drawn in a clockwise direction (considering SVG's coordinate system, where x increases to the right and y increases downwards).

I expected CCW() to return false for this case. Could you help clarify if this is intended behavior or a bug?

Thanks for your time!

@tdewolff
Copy link
Owner

tdewolff commented Feb 3, 2025

Yes, canvas is in the first Cartesian quadrant coordinate system. That is, the bottom-left is the origin and X and Y increase along the right and towards the top. This is common in math and in general, but drawing coordinate systems are usually in the fourth Cartesian quadrant. This has been a decision from early on since it is confusing to think in the fourth quadrant (for me at least) and well all papers and algorithms are usually focused on the first quadrant.

That said, you can use https://github.com/tdewolff/canvas/blob/master/canvas.go#L303 to draw in the fourth quadrant, but internally all paths remain in the first quadrant.

@konskoehler
Copy link
Author

thanks for the explanation!

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

No branches or pull requests

2 participants