Nokia Maps API Reference

Contents

Class nokia.maps.gfx.Color

Class Summary

The static Color class offers methods to handle 32-bit integer color values. A 32-bit integer offers the most efficient way to store a color and is used, for example, in nokia.maps.gfx.IDL.

The methods on this class compress an RGBA (red, green, blue, alpha) color value into a 32-bit integer, extract values from a 32-bit integer, parse CSS strings into 32-bit integer color values or to create CSS strings from a 32-bit integer color value.

Method Summary
static alpha (color) : Number This method retrieves the alpha byte of a compressed color.
static blue (color) : Number This method retrieves the blue byte of a compressed color.
static byteOf (percent) : Number This method converts a percentage value (given as a decimal fraction between 0 and 1 into a byte value (0 to 255).
static compress (red, green, blue, alpha) : Number This method compresses the red, green, blue an alpha bytes of a color into a 32-bit integer.
static getCssHex (color, [addAlpha, [prefix]]) : String This method converts a compressed color into a hexadecimal CSS string notation, for example "#ff0000".
static getCssRGB (color, [addAlpha]) : String This method converts a compressed color into a CSS rgb string, for example "rgb(255,0,0)".
static getCssRGBA (color) : String This method converts a compressed color into a CSS rgba string, for example, "rgba(255,0,0,0.5)".
static green (color) : Number This method retrieves the green byte of a compressed color.
static parseCss (cssColor, [defaultOpacity]) : Number This method parses a CSS color definition into a compressed color (a 32-bit integer).
static percentOf (byteValue) : Number This method converts a byte value (0 to 255) into a percentage value expressed as a decimal fraction between 0 and 1.
static red (color) : Number This method retrieves the red byte of a compressed color.
Method Detail
static alpha (color) : Number
This method retrieves the alpha byte of a compressed color.
Parameters:
{Number} color A color as a 32-bit integer
Returns:
{Number} The alpha part of the compressed color as a a value between 0 and 255
static blue (color) : Number
This method retrieves the blue byte of a compressed color.
Parameters:
{Number} color A color as a 32-bit integer
Returns:
{Number} The blue part of the compressed color as a value between 0 and 255
static byteOf (percent) : Number
This method converts a percentage value (given as a decimal fraction between 0 and 1 into a byte value (0 to 255).
Parameters:
{Number} percent A decimal fraction between 0 and 1, representing a percentage value
Returns:
{Number} A number between 0 and 255, representing a byte value
static compress (red, green, blue, alpha) : Number
This method compresses the red, green, blue an alpha bytes of a color into a 32-bit integer.
Examples:
		// Compress a semi-transparent red color
		var color = nokia.maps.gfx.Color.compress(255, 0, 0, 127);
Parameters:
{Number} red The red byte of the color as a value between 0 and 255
{Number} green The green byte of the color as a value between 0 and 255
{Number} blue The blue byte of the color as a value between 0 and 255
{Number} alpha The alpha byte of the color as a value between 0 and 255
Returns:
{Number} The compressed 32-bit integer representing the color
static getCssHex (color, [addAlpha, [prefix]]) : String
This method converts a compressed color into a hexadecimal CSS string notation, for example "#ff0000".
Parameters:
{Number} color A 32-bit integer representing a compressed color value
{Boolean} [addAlpha]: A flag indicating whether to add the alpha byte (true) and thus an eight-character hex string instead or return a six-character RGB string
{String} [prefix]: The prefix to add in front of the returned hex string, the default is "#"
Returns:
{String} A CSS hex string representing the given compressed color, for example "#ff0000"
static getCssRGB (color, [addAlpha]) : String
This method converts a compressed color into a CSS rgb string, for example "rgb(255,0,0)".
Parameters:
{Number} color A 32-bit integer containing a compressed color value
{Boolean} [addAlpha]: A flag idicating whether to return an rgba string (true) or an rgb string (false)
Returns:
{String} A valid CSS rgb color value, for example "rgb(255,0,0)"
static getCssRGBA (color) : String
This method converts a compressed color into a CSS rgba string, for example, "rgba(255,0,0,0.5)".
Parameters:
{Number} color A 32-bit integer containing a compressed color value
Returns:
{String} A valid CSS rgba color value, for example "rgba(255,0,0,0.5)"
static green (color) : Number
This method retrieves the green byte of a compressed color.
Parameters:
{Number} color A color as a 32-bit integer
Returns:
{Number} The green part of the compressed color as a value between 0 and 255
static parseCss (cssColor, [defaultOpacity]) : Number
This method parses a CSS color definition into a compressed color (a 32-bit integer).
Parameters:
{String} cssColor The CSS color definition as a hexadecimal string, for example "#ff00ff".
{Number} [defaultOpacity]: The default opacity of the color as a percentage (given as a decimal fraction between 0 and 1); the default is 1 (opaque); if no opacity is specified in the cssColor, then defaultOpacity is used
Returns:
{Number} The compressed color representation of the received hexadecimal string or null if the parsing failed
static percentOf (byteValue) : Number
This method converts a byte value (0 to 255) into a percentage value expressed as a decimal fraction between 0 and 1.
Parameters:
{Number} byteValue A byte value between 0 and 255
Returns:
{Number} The corresponding percentage value as a double (a decimal fraction between 0 and 1)
static red (color) : Number
This method retrieves the red byte of a compressed color.
Parameters:
{Number} color A color as a 32-bit integer
Returns:
{Number} The red part of the compressed color as a value between 0 and 255
Documentation generated on Wed Jun 27 2012 16:54:35 GMT+0200 (CEST).