aduros/flambe — pull request #235 by OvertureGames (2014-03-04 21:12:51+00:00)
Title: New 'Shape' display object to procedurally draw lines (with rounded caps)

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