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 Path.addCircle
#4783
Support Path.addCircle
#4783
Conversation
This seems somewhat redundant with |
lib/ui/painting.dart
Outdated
@@ -1519,6 +1519,13 @@ class Path extends NativeFieldWrapperClass2 { | |||
} | |||
void _addOval(double left, double top, double right, double bottom) native 'Path_addOval'; | |||
|
|||
/// Adds a new subpath that consists of a curve that forms the | |||
/// circle centered on centerX,centerY with specified radius |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should end with a period. Also, put backticks around references to arguments.
If we add this, it would be nice if we could also find a way to test it. (I don't think we yet test much of this code, but we really should.) |
The following code all would result in the same end result in terms of drawing:
But The dart code in painting.dart could be rewritten to be an alias to one of those (which is what Skia does in C++ - |
RE Testing: there are some tests for painting in flutter/flutter, but nothing around paths. I'm not really sure how we could test Paths as they are today - there's no way to test for value equality or get any insight into the contents of a path right now. |
I was thinking more: Path c4 = new Path()..arcTo(new Rect.fromCircle(center: new Offset(cx, cy), radius: r), 0, pi * 2.0); ...but as you say, there's at least two other ways to do it too. Do we really want to add a fourth? |
(Does the existence of |
Yes, I don't see this as a particularly critical change - there are numerous work arounds. However, I think it will be an easy source of confusion for developers (particularly when trying to port existing path based logic from other languages/contexts). I think at the least it would make sense to support
I realize this is adding yet another way to achieve the same thing, but the existing alternatives are less immediately obvious if you just want to add a circle to a path and prone to introducing errors/increased need for unit testing. |
I would definitely support adding documentation to |
Ok. It may make sense to just create a Path drawing package in dartpub as well with "utility" methods like these. That should be entirely possible with no engine modifications. Would you like me to modify this PR to update documentation on |
Sure. Thanks! |
I only updated Path.addOval - canvas already has an exposed method |
When you said Canvas already had "drawCircle" I was like, wait, what? When did we add that. That's silly. |
Includes: * Add hint to use ninja with goma (flutter/engine#4894) * Support `Path.addCircle` (flutter/engine#4783) * Roll dart (flutter/engine#4902)
For some reason this is missing currently (can be achieved with
addOval
, which is implemented in dart and which is how Skia implements it anyway on the C++ side).I'd like to see this to support SVG rendering (particularly, making circles into paths).
See also flutter/flutter#15501