GraphicImage Template
drawPolygon()
Draw a polygon
Syntax
GraphicImage = rb.GraphicImage.drawPolygon(points, colour, options)
Parameters
The 'drawPolygon' method takes 3 parameters:
Name | Type/Value | Range/Length | Description | points | array of struct Points | see definition | Required.
The coordinates of each vertex of the polygon to draw
| colour | number | | Required.
The colour to use for drawing the polygon. This can be any colour allocated with 'colourAlloc' or 'colourResolve', or
can be the special valie 'GraphicImage.styled' to use the
defined styled.
| options | MetaData | | Optional. Object containing optional values that change how the rectangle is drawn |
Results
The 'drawPolygon' method returns GraphicImage:
Type/Value | Range/Length | Description |
GraphicImage |
  |
Returns a reference to 'this' if the operation succeeds, otherwise throws an exception.
|
Remarks Draw a rectanglem given it's top left and bottom right coordinates. By default
the rectangle is drawn with a border but is not filled. Set the 'fill' option on
the last parameter to cause the rectangle to be solid. The last parameter to this call is an optional set of 'options' expressed as a JavaScript object. To
specify a non-default value for one of these options, include the options object. Currently defined flags are : Option | Default | Description |
---|
antialias | true | If set to 'true', for true-colour images, anti-aliasing techniques will be used to remove jagged edges | fill | false | If 'true' this method will fill all the area within the polygon with the specified colour | close | true | If 'true' (the default) then the last point in the polygon is joined back to the first point |
Example
// Create an empty 100x100 pixel image
var img = (new GraphicImage).create(100,100);
// Draw a blue trapeze within the image, border 3 pixels wide
var blue = img.colourAlloc( 0,0,255);
img.setPenWidth(3);
img.drawPolygon( [{x:20,y:20},
{x:80,y:20},
{x:90,y:40},
{x:10,y:40}]
blue});
|