I'm currently working on a Polygon plugin. You basically feed it some vertices (in the proper order) in local space and then draw.
It also handles collisions.
What I have done so far:
- Is overlapping another object
- Is overlapping at offset
- Collisions enabled
- On Drawn
- Compare area
- Add Vertex (x,y) \\ in local space
- Log Vertex List \\ outputs the vertex list in the js consol
- Draw Polygon (fillColor,lineWidth,lineColor) \\ every change in vertex list needs a draw call to be seen
- Move Vertex (index,x,y)
- Remove Vertex (index)
- Clear Polygon \\ empty the vertex list and erase the poly)
- Load (JSON)
- Download (JSON)
- VertexX(index) (in world space)
- VertexY(index) (in world space)
- LocalVertexX(index) (the original values entered in Add Vertex)
- LocalVertexY(index) (the original values entered in Add Vertex)
Basically everything in this list is done and I'm already using it for a project so I can thorouoghly test it.
Also it might not be super easy to work with since I'm mixing local and world space. But that's what I found the most practical.
You create vertices relative to the position of the object so you can feed the same vertex list to other instances an have the same shape drawn.
And you retrive the vertex position in world space so you can "pin" some objects to them or do some calculations.
You can copy polygons using either the LocalVertex expressions or Get as JSON -> Load
I don't support textured polygon for now at least... If it's not too hard to implement and if it doesn't make the plugin too complex I might.
I think I'll be releasing it this month so we'll be able to talk about it in its own topic =)