Name
Polygon -- draw a polygon (V1.9)
Synopsis
Polygon(x, y, vertices, count[[, color], table])
Function
This function draws a polygon from a table of vertices. You have to pass a table of x,y points that are used to draw the polygon in the vertices parameter. The count parameter specifies how many vertices your polygon has. Additionally, you need to specify the color for the polygon (in RGB format). The polygon will be drawn in the form style specified using SetFormStyle() and will be filled according to the configuration selected with SetFillStyle(). Also remember that the last vertex should close your polygon, which means that it must be the same as the first vertex.

The vertices can also be negative and/or specified in floating point notation to achieve the best precision. Hollywood will not round them off before it does the final rasterization.

If layers are enabled, this command will add a new layer of the type #POLYGON to the layer stack.

New in Hollywood 2.0: Color can also be an ARGB value for alpha-blended drawing.

Starting with Hollywood 4.5, this function accepts a new optional table argument that can be used to specify one or more of the standard tags for all of Hollywood's draw commands. See Standard drawing tags for more information about the standard tags that nearly all Hollywood drawing commands support.

Note that when drawing to a palette-based target and the palette mode is set to #PALETTEMODE_PEN, this function will draw using the pen set via SetDrawPen() instead of the color passed to the function.

Inputs
x
x offset for the polygon on the display
y
y offset for the polygon on the display
vertices
a table of vertices that describe the polygon
count
number of vertices in the table
color
optional: RGB or ARGB color (defaults to #BLACK) color is optional because it is not required when you render to a mask or alpha channel
table
optional: table containing further arguments; can be any from the ones listed above and from the standard tags (V4.5)
Example
v = {}
v[0] = 0    ;X1
v[1] = 100  ;Y1
v[2] = 50   ;X2
v[3] = 0    ;Y2
v[4] = 100  ;X3
v[5] = 100  ;Y3
v[6] = 0    ;X4
v[7] = 100  ;Y4
Polygon(#CENTER, #CENTER, v, 4, #RED)
The above code draws a red triangle in the center of the display.


Polygon(#CENTER, #CENTER, v, 4, #RED, {Rotate = 45})
The above code draws a triangle rotated by 45 degrees.

Show TOC