Whitebeam Template Reference Documentation

Site Map
 
Home
 
Application Guide
Reference
  Installation
  Configuration
  XML Markup
  JavaScript Classes
  ROM
  Templates
  Environment
  Dev Process
  Tools
  External Links
  Example libraries
Community
Contact Whitebeam
To-Do
Download
Credits
Licence
Whitebeam Users
 
 
 

Whitebeam Template Reference Documentation

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
pointsarray of struct Pointssee definition Required. The coordinates of each vertex of the polygon to draw
colournumber  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.
optionsMetaData  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 :

OptionDefaultDescription
antialiastrueIf set to 'true', for true-colour images, anti-aliasing techniques will be used to remove jagged edges
fillfalseIf 'true' this method will fill all the area within the polygon with the specified colour
closetrueIf '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});
        
Whitebeam release 1.3.36
(loadtime : 20ms)