GraphicImage Template
drawLine()
Draw a line between two points
Syntax
GraphicImage = rb.GraphicImage.drawLine(startPoint, endPoint, colour, antialias)
Parameters
The 'drawLine' method takes 4 parameters:
Name | Type/Value | Range/Length | Description | startPoint | struct Point | see definition | Required.
The coordinates of the starting point for this line
| endPoint | 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.
| antialias | bool | | Optional, default = true
By default, for true-colour images, drawLine will use anti-aliasing techniques to remove jagged
elements from the line. If you want to turn this off then specify 'false' for this parameter. Anti-aliasing
is not possible with palette images.
|
Results
The 'drawLine' 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 line in a specific colour between two points, given the coordinates of the start and
end point for the line. The first two parameters specify the start and end-points for the line. The third parameter the
colour. You can use any defined colour, or use the special value of GraphicImage.styled to
use a style defined with
GraphicImage.setPenStyle Example
// Create an empty 100x100 pixel image
var img = (new GraphicImage).create(100,100);
// Draw a big X, three pixels wide across the image
var red = img.colourAlloc(255,0,0);
var blue = img.colourAlloc( 0,0,255);
img.setPenWidth(3);
img.drawLine({x:0,y:0},{x:99,y:99}, red});
img.drawLine({x:0,y:99},{x:99,y:0}, blue});
|