GraphicImage Template
setPenStyle()
Set pen drawing style
Syntax
GraphicImage = rb.GraphicImage.setPenStyle(point_colours)
Parameters
The 'setPenStyle' method takes 1 parameter:
Name | Type/Value | Range/Length | Description | point_colours | array of numbers | | Required.
Defines the 'style' of the drawing pen
|
Results
The 'setPenStyle' method returns GraphicImage:
Type/Value | Range/Length | Description |
GraphicImage |
  |
Return a reference to the GraphicImage (to 'this')
|
Remarks By default drawing operations such as drawRectangle, use a continuous line. This method
allows this default behaviour to be modified to create dashed lines, lines
of varying colour and other effects. The style is specified as an array of 'colour values'. You can specify that
particular pixels are not drawn in order to create dashed lines. Colours are
specified as usual, with values returned from colourAlloc (or colourResolve).
for pixels that are to remain transparent set the colour to the special value
of GraphicImage.transparent. To tell the drawing tool to use the defined style instead of a standard
colour use the special colour value of GraphicImage.styled. Example To draw a rectangle using an long-dashed line with each dash being 10 pixels
and a short gap of 5 pixels use the following style, alternate each dash between
red and blue :
// Create an empty 100x100 pixel palette based image
var img = (new GraphicImage).create(100,100, false);
var red = img.colourResolve(255, 0, 0);
var blue = img.colourResolve( 0, 0,255);
var t = GraphicImage.transparent;
// Define the style using an array of colours, using -1 to indicate transparent
var style = [
// Red dash
red,red,red,red,red,red,red,red,red,red,
// Transparent dot
t, t, t, t, t,
// Blue dash
blue,blue,blue,blue,blue,blue,blue,blue,blue,blue,
// Transparent dot
t, t, t, t, t,
];
// Set style
img.setPenStyle(style);
// Draw a dashed rectangle 75x50 pixels using the defined style. Style
// is identified using the special colour value of '-1' (third parameter)
img.drawRectangle({x:30,y:30},{x:80,y:80},-1);
|