GraphicImage Template
drawRectangle()
Draw a rectangle
Syntax
GraphicImage = rb.GraphicImage.drawRectangle(topLeft, bottomRight, colour, options)
Parameters
The 'drawRectangle' method takes 4 parameters:
Name | Type/Value | Range/Length | Description | topLeft | struct Point | see definition | Required.
The coordinates of the starting point for this line
| bottomRight | struct Point | see definition | Required.
The coordinates of the end point for this line
| colour | number | | Required.
The colour to use for drawing this line. 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 'drawRectangle' 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 rectangle with the specified colour |
Example
// Create an empty 100x100 pixel image
var img = (new GraphicImage).create(100,100);
// Draw a rectangle within the image, border 3 pixels wide
var blue = img.colourAlloc( 0,0,255);
img.setPenWidth(3);
img.drawRectangle({x:10,y:10},{x:90,y:90}, red});
|