New 'Shape' display object to procedurally draw lines (with rounded caps) #235
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've made a 'Shape' class that extends from 'Sprite' that will allow the user to create custom shapes (like lines, rectangles, circles, and polygons) by assembling various primitives together, which can then be transformed like any 'Sprite' object.
For instance, this new 'Shape' object would be instantiated, then by calling its methods it would append new primitives to its local origin. The 'Shape' could then be told to ease, rotate, etc. and all the attached primitives would move relatively to each other.
The pull request includes a new file "Shape.hx" that resides in the 'display' package, and some modifications to the three 'Graphics' renderers (canvas, webGL, stage3D). Canvas implementation was straight forward. As for the other two, I've ensured to stay consistent with the current underlying architecture of drawing with quads, and the lines/caps are essentially just a series of fancy fillRect's that share the same vertex buffer attributes and shader.
Note: This pull request has changes to "Library.hx" and "Flipbook.hx" which are unrelated (and can be omitted) to this merge. I mentioned in an email to Bruno a couple weeks ago that I needed to write support for an in-house sprite tool, and he mentioned I should use Library.fromFlipbooks(). I had to however support data-driven animation names, (not hardcoded, parameterized dynamic variables) so I opted to write an alternate version of the method that took an Array instead.
Sorry for the long-winded description, hope you find it useful!
-Jay