GraphicImage Template
colourResolve()
Allocate a colour for use in drawing methods
Syntax
number = rb.GraphicImage.colourResolve(red, green, blue, alpha)
Parameters
The 'colourResolve' method takes 4 parameters:
Name | Type/Value | Range/Length | Description | red | number | 0-255 | Required.
The RED component of the colour to allocate
| green | number | 0-255 | Required.
The GREEN component of the colour to allocate
| blue | number | 0-255 | Required.
The BLUE component of the colour to allocate
| alpha | number | 0-127 | Optional, default = 0
The 'ALPHA' component of the colour to allocate. This defines the transparency of the new
colour - or the amount to which the colour underneath is allowed to shine through this colour
when drawing. A value of 127 is fully transparent, 0 is opaque.
|
Results
The 'colourResolve' method returns number:
Type/Value | Range/Length | Description |
number |
  |
Return a numeric value representing the colour
|
Remarks Allocate a colour for subsequent drawing operations. For true-colour images this
method always returns the requested colour and is functionally identical to
colourAlloc. For palette images this method allocates colours from the available palette using the following palette : - A search is made of existing colours. If there is an exact match with the requested colour then that
is returned to the application
- If there is no exact match, but the palette is not full then
a new palette slot is allocated for the requested colour and that is returned
to the application
- If there is no exact match and the palette is full then
the set of existing colours is compared against the requested colour and the
best match is returned to the application
Example
// Create an empty 100x100 pixel palette based image
var img = (new GraphicImage).create(100,100, false);
// Draw the pixels {0,0},{1,1},{2,2} to red and the pixel at {3,3} to blue
var red = img.colourResolve(255, 0, 0);
var greem = img.colourResolve( 0,255, 0);
var blue = img.colourResolve( 0, 0,255);
var pixels = [
{x:0, y:1},
{x:1, y:1},
{x:2, y:2},
{x:3, y:3, c:blue}
];
img.drawPixels(pixels,red);
|