Whitebeam Object Definition

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 Object Definition

Method Description

GraphicImage.colourResolve()

Allocate a colour for use in drawing methods

Syntax

number = GraphicImage.colourResolve(red, green, blue, alpha)

Parameters

The 'GraphicImage.colourResolve' method takes 4 parameters:

Name Type/Value Range/Length Description
rednumber0-255 Required. The RED component of the colour to allocate
greennumber0-255 Required. The GREEN component of the colour to allocate
bluenumber0-255 Required. The BLUE component of the colour to allocate
alphanumber0-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 'GraphicImage.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 :

  1. A search is made of existing colours. If there is an exact match with the requested colour then that is returned to the application
  2. 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
  3. 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);
        
Whitebeam release 1.3.36
(loadtime : 12ms)