Module: rgba

RGBA colors API. Colors in Blend4Web are always stored in linear space, for more info check documentation.
Source:

Summary

Methods

Detailed Description

Methods

create() → {RGBA}

Creates a new empty RGB vector representing black opaque color.
Returns:
A new RGBA vector.
Type
RGBA
Source:

css_to_rgba(css_red, css_green, css_blue, css_alpha, destopt) → {RGBA}

Convert CSS color components to RGBA.
Parameters:
Name Type Attributes Default Description
css_red Number CSS color red component (0-255).
css_green Number CSS color green component (0-255).
css_blue Number CSS color blue component (0-255).
css_alpha Number CSS alpha component (0-1).
dest RGBA <optional>
rgba.create() Destination RGB vector.
Returns:
Destination RGB vector.
Type
RGBA
Source:
Example
var m_rgba = require("rgba");

// rgba(128, 128, 128, 0.5) converted to [0.219, 0.219, 0.219, 0.5]
var rgba_color = m_rgba.css_to_rgba(128, 128, 128, 0.5);

from_values(r, g, b, a) → {RGBA}

Creates a new RGBA vector initialized with the given values.
Parameters:
Name Type Description
r Number Red component.
g Number Green component.
b Number Blue component.
a Number Alpha component.
Returns:
A new RGBA vector.
Type
RGBA
Source:

rgba_to_css(rgba) → {Array.<Number>}

Convert RGBA color components to CSS color.
Parameters:
Name Type Description
rgba RGBA RGBA color vector.
Returns:
Array with CSS colors.
Type
Array.<Number>
Source:
Example
var m_rgba = require("rgba");

var rgba_color = m_rgba.from_values(0.219, 0.219, 0.219, 0.5);
// [0.219, 0.219, 0.219, 0.5] converted to [128, 128, 128, 0.5]
var color = m_rgba.rgba_to_css(rgba_color);

set(r, g, b, a, dest) → {RGBA}

Set the components of RGBA vector to the given values.
Parameters:
Name Type Description
r Number Red component.
g Number Green component.
b Number Blue component.
a Number Alpha component.
dest RGBA Destination RGBA vector.
Returns:
Destination RGBA vector.
Type
RGBA
Source: