(you have to specify color with a string (in "") and you can use either rgb(r,g,b), hsl(hue,saturation,lightness) or "#rrggbb" or special recognized values like "black" "red" "green" etc)
You can move, or remove vertices via their indexes (0-based)
You can insert a vertex inside the list by giving an index.
If the index you specify is negative or greater than the index of the current last vertex, it will be respectively clamped to 0 or [index of the last vertex] + 1
Clear polygon will do two things at the same time:
empty the vertex list and delete the current polygon texture.
I basically copied the piece of code from the Array plugin. So you can load and save a vertex list in JSON format.
It can be usefull if you want to copy a polygon shape or save some shape for later uses (polygon editor?)
When you use the draw polygon action, you basically create a texture. This texture can then be scaled using width/height, and rotated using angle.
But remember that since it became a texture, you will see stretching artefacts.
Another thing to be aware of, if you stretch your polygon, you basically modify the relation between originalWidth (which is the distance between the left most and the right most vertex in local space) and current Width of the object.
The draw polygon action will keep this relation.
If your width is twice your originalWidth, and you modify your vertex list and draw, the ratio will be kept.
Local-Space vs World-Space
Add, Insersion and move can be either done in local space or world space.
Local-space means relative to the space of the polygon object. So if you add vertices and then change the angle of the object, you'll have the same result the other way around.
Via expression, you have access to the local coordinate (LocalVertexX,LocalVertexY) or the world-space coordinate, their real position in the world (VertexX,VertexY)
The value you get from the Area expression or evaluated with the Compare area condition will be right for convex and concave polygon but wrong for invalid polygons (when two edge cross each other).
You can set the Origin of the polygon wherever you want to, even after your vertex list is built.
The vertex list will be recalculated accordingly, and the position will be changed so the origin is moved but nothing is changed visually.
It may be usefull to set a new rotating point or anything you want to do in runtime.
You can test it in the demo.capx in the zip or Creation/Edition demo below.
To help you during development, you can enable the debug mode property.
This way you can see what vertex are added, inserted or removed, when polygon are drawn and when JSON's are loaded
But sometimes you don't need that much, or you would prefer triggering debug information yourself via event.
For that, you have the log vertex list action. It will write the list of vertices in the console (only in preview)
You can test everything about scaling, rotating, vertex creation here:
Just to fool around
Creating random graphs
One possible application of it:
One crazy really unusable and "you shouldn't do that" application:
Here is the plugin with the capx of the demo in it.
(I didn't provide the 3D one because I don't want to encourage anyone to use that method (:)
I made some video to show you how I to use it
Polygon Plugin:RamblingActionsExpressionsPolygon Splitting:Starting ShapeCutting NodesNode SelectionSplit FunctionLine EquationGroupingChildren CreationPolygon SelectionHelper FunctionsFeedbacksNode FilteringLittle BugFinal Rambling
Do remember that drawing a polygon is an expensive computation, avoid as much as possible to do that every tick.
I hope you like it and don't hesitate to report bug and tell me how you used it (:Yann2013-04-23 00:21:22