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

Implement arcTo() #11

Closed
tj opened this issue Oct 5, 2010 · 9 comments
Closed

Implement arcTo() #11

tj opened this issue Oct 5, 2010 · 9 comments

Comments

@tj
Copy link
Contributor

tj commented Oct 5, 2010

No description provided.

@RandomEtc
Copy link
Contributor

I have an initial version of this working. It's a lot of math. The kind of work that makes me think I've done it wrong, but then I remember that this is why there aren't that many finished graphics libraries...

The only changes to my master branch are for arcTo if you want to take a look the specific commits are RandomEtc/node-canvas@cfc497e and RandomEtc/node-canvas@30d342b

I borrowed example/arcTo.js from http://canvex.lazyilluminati.com/misc/arcto.html which covers several edge cases (backwards arcs, colinear control points, etc).

It might be worth borrowing from http://philip.html5.org/demos/canvas/arcto-inf.html too, which should look like http://philip.html5.org/demos/canvas/arcto-inf.png

@tj
Copy link
Contributor Author

tj commented Nov 23, 2010

wicked thanks man, I will take a look and merge shortly.

@RandomEtc
Copy link
Contributor

I'm porting that other demo now, FYI.

@RandomEtc
Copy link
Contributor

OK, they all fail :)

Better hold off on that merge!

(Also I just realized I overwrote my previous test... I'll be in touch)

RandomEtc/node-canvas@d3e7be7

@tj
Copy link
Contributor Author

tj commented Nov 23, 2010

ahaha k :) let me know

@RandomEtc
Copy link
Contributor

OK, I think I got a bit carried away with one of my tests. I'm calculating the control points correctly but I'm not catching some of the edge cases that the browser versions handle. I've got a test for triangle insideness in there which doesn't seem to be necessary, and something else needs to trigger that case instead.

Here's how Webkit does it with Cairo:
http://trac.webkit.org/browser/trunk/WebCore/platform/graphics/cairo/PathCairo.cpp#L160

And here's Chromium with Skia:
http://www.google.com/codesearch/p?hl=en#OAMlx_jo-ck/src/third_party/skia/src/core/SkPath.cpp&q=file:%28/|^%29Path\.h$%20package:%22chromium%22&gs=cpp:SkPath::arcTo%28float,%2520float,%2520float,%2520float,%2520float%29@chrome/trunk/src/third_party/skia/include/core/SkPath.h%257Cdecl&gsn=arcTo&l=670

I'll have to put this down for now. Sorry for false alarm!

@tj
Copy link
Contributor Author

tj commented Nov 23, 2010

Added arcTo(). Closed by ea4b13e

@tj
Copy link
Contributor Author

tj commented Nov 23, 2010

went with a slightly modified version of the webkit one, thanks for pointing it out

@RandomEtc
Copy link
Contributor

Awesome, glad you got it working!

This issue was closed.
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