Skip to content

Added the Win2d Path Geometry parser. #3503

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

Merged

Conversation

ratishphilip
Copy link
Contributor

@ratishphilip ratishphilip commented Sep 26, 2020

Fixes #3421

WPF has a Path Mini Language which is used to describe geometric paths and figures. Support for a similar language does not exist in Win2d library. CanvasPathGeometry class aims to resolve that.

PR Type

What kind of change does this PR introduce?

  • Feature

What is the current behavior?

No parser for converting SVG path data to CanvasGeometry exists. Moreover, no mini language exists for defining Brushes, Strokes and StrokeStyles.

What is the current behavior?

No parser for converting SVG path data to CanvasGeometry exists. Moreover, no mini language exists for defining Brushes, Strokes and StrokeStyles.

What is the new behavior?

I have defined the Win2d Path Mini Language, which is a superset of the Path Language specification in SVG and can be used to define the following

  • CanvasGeometry
  • Color (in hex format or Vector4 format)
  • Various brushes deriving from ICanvasBrush
    • SolidColorBrush
    • LinearGradientBrush
    • LinearGradientBrush with GradientStopHdr
    • RadialGradientBrush
    • RadialGradientBrush with GradientStopHdr
  • CanvasStrokeStyle
  • CanvasStroke which derives from ICanvasStroke (an interface which encapsulates the attributes of a stroke - Width, Brush, Style and Transform)

I have implemented the CanvasPathGeometry class which contains a set of static helper methods which enable the parsing of Win2d Path Mini Language as string and convert them to appropriate CanvasGeometry, Color, ICanvasBrush or ICanvasStroke. Also I have added extension methods to Compositor, CanvasPathBuilder and CanvasDrawingSession to build upon the aforementioned helper methods.

PR Checklist

Please check if your PR fulfills the following requirements:

@ghost
Copy link

ghost commented Sep 26, 2020

Thanks ratishphilip for opening a Pull Request! The reviewers will test the PR and highlight if there is any conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌

@michael-hawker
Copy link
Member

@ratishphilip sorry we've been heads down updating some of our pipeline stuff recently. Just took a quick look now and noticed there were no tests associated with the PR. Especially with some of the RegEx and Math helpers it'd be good to bring in any unit tests you have as well for maintaining this work in the future and guarding against accidental regressions. Thanks!

@michael-hawker michael-hawker marked this pull request as draft November 10, 2020 18:35
@Kyaa-dost Kyaa-dost added feature 💡 and removed feature request 📬 A request for new changes to improve functionality labels Dec 3, 2020
@michael-hawker
Copy link
Member

Hey @ratishphilip thoughts on being able to add tests for anything here? We're going to be closing out our features for the 7.0 release in the next couple of weeks here before the holidays (tentatively Dec 18th). Worst case we just move this to the next milestone. Just wanted to check-in and get your thoughts. Thanks!

@ratishphilip
Copy link
Contributor Author

Hey @michael-hawker, sorry for the delayed response. Been a bit busy with my day job lately. I will try to update the PR this weekend.

@ratishphilip
Copy link
Contributor Author

@michael-hawker Almost done with the unit tests. Will be updating the PR tomorrow.

@ratishphilip
Copy link
Contributor Author

@michael-hawker The unit test cases have been added.

@ratishphilip ratishphilip marked this pull request as ready for review December 16, 2020 21:30
@ratishphilip
Copy link
Contributor Author

@michael-hawker All the review comments have been implemented and the comments resolved.

Copy link
Member

@michael-hawker michael-hawker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ratishphilip for the sample updates. I was able to get to a few cases where typing gobblygook didn't provide an error message, but we can always improve things and catch other edge cases more later as follow-ons. I mean in the main case someone's going to copy a well known path to render, so I'm not too worried. 🙂

@Sergio0694 you all good now too? Auto-merge should take care of the rest! 🎉

Copy link
Member

@Sergio0694 Sergio0694 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! 🎉
Thank you @ratishphilip for adding these APIs to the Toolkit!

Sorry I had to manually push a commit to this branch - we merged #3726 which removed the Guard/ThrowHelper APIs from the base Microsoft.Toolkit package so I wanted to just refactor the code to get this PR merged in, and didn't want to bother you to basically undo the changes we requested a while back, before that other PR was in the works. Hope that's alright for you! 😄

Thanks again for your contribution! 🙌

@ratishphilip
Copy link
Contributor Author

ratishphilip commented Feb 4, 2021

Hey @Sergio0694 I am perfectly fine with that. 😃 Thanks for incorporating those changes. 😄👍

@michael-hawker michael-hawker merged commit 44eb3e2 into CommunityToolkit:master Feb 4, 2021
@michael-hawker
Copy link
Member

Merged! 🎉🎉🎉

Thanks for contributing this to the Toolkit @ratishphilip! I know this was one of the larger chunks of things from your own library. Hope to see more contributions in the future! I know a lot of your composition helpers would go great with the effect pipeline and animation stuff @Sergio0694 has been putting together too!

@michael-hawker michael-hawker added this to the 7.0 milestone Feb 4, 2021
@ratishphilip
Copy link
Contributor Author

Thanks @michael-hawker and @Sergio0694 for helping merge it to WCT.
I am preparing the next big chunk from my library to be added to WCT. 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Adding Win2d Path Mini Language Parser to WCT
5 participants