Color
#include <bb/cascades/Color>
An implementation of Paint that represents a color with alpha channel.
At this point the Color objects are immutable.
Color c1 = Color::fromRGBA(0.5f, 1.0f, 0.2f, 0.8f); Color c2 = Color::fromARGB(0xff996633);
Predefined color constants
The predefined constants are helpful when you quickly need to specify a color that stands out (for example, if you are debugging and wondering how a specific Container is laid out).

Container container = Container::create()
.background(Color::DarkGreen)
.preferredSize(100.0f, 100.0f);

Using Color in QML
Accessing the Color class from QML:
Container {
// specify r, g, b components using hex string
background: Color.create("#ff808080")
preferredWidth: 100
preferredHeight: 50
}
Container {
// specify r, g, b components using floats
background: Color.create(0.2, 0.4, 0.5)
preferredWidth: 100
preferredHeight: 50
}
Container {
// specify the color using one of predefined constants
background: Color.Green
preferredWidth: 100
preferredHeight: 50
}

BlackBerry 10.0.0
Inheritance
| bb::cascades::Paint | |||
| bb::cascades::ColorPaint | |||
| bb::cascades::Color | |||
Public Static Attributes Index
| const Color | White |
| const Color | Black |
| const Color | Red |
| const Color | DarkRed |
| const Color | Green |
| const Color | DarkGreen |
| const Color | Blue |
| const Color | DarkBlue |
| const Color | Cyan |
| const Color | DarkCyan |
| const Color | Magenta |
| const Color | DarkMagenta |
| const Color | Yellow |
| const Color | DarkYellow |
| const Color | Gray |
| const Color | DarkGray |
| const Color | LightGray |
| const Color | Transparent |
Public Functions Index
| Color () | |
| Color (const Color &orig) | |
| Color & | operator= (const Color &other) |
| virtual | ~Color () |
| virtual bool | operator== (const Paint &other) const |
| virtual bool | operator!= (const Paint &other) const |
| float | alpha () const |
| float | red () const |
| float | green () const |
| float | blue () const |
| ColorPaint () | |
| ColorPaint (const ColorPaint &orig) | |
| bool | isNull () const |
| virtual ColorPaint & | operator= (const ColorPaint &other) |
| Paint & | operator= (const Paint &other) |
| Paint (const Paint &orig) |
Static Public Functions Index
Public Static Attributes
Public Functions
A copy constructor which creates a copy of the passed Color object.
Color c = Color::Green;
or
Color c(Color::Green);
| Parameters | |
|---|---|
| orig |
The color object to create a copy of. |
BlackBerry 10.0.0
Color &
An assignment operator which sets this instance to have the same color and alpha components as the passed one.
| Parameters | |
|---|---|
| other |
The color object to create a copy of. |
BlackBerry 10.0.0
virtual
Destructor.
BlackBerry 10.0.0
virtual bool
An == operator for Color objects.
virtual bool
A != operator for Color objects.
This is equivalent to !operator==();
true if the objects are not equal, false otherwise.
BlackBerry 10.0.0
float
Returns the alpha component of this color.
The alpha component.
BlackBerry 10.0.0
float
Returns the red component of this color.
The red component.
BlackBerry 10.0.0
float
Returns the green component of this color.
The green component.
BlackBerry 10.0.0
float
Returns the blue component of this color.
The blue component.
BlackBerry 10.0.0
Creates a null ColorPaint object.
The resulting paint is a null paint until initialized with another (non-null) ColorPaint object. There is no public API for creating a non-null ColorPaint directly without using the copy constructor.
// creates a null paint
ColorPaint c;
...
// Initializes c with the value of label.textColor().
c = SystemDefaults::Paints::defaultText();
BlackBerry 10.0.0
A copy constructor which creates a copy of the passed ColorPaint object.
ColorPaint c = SystemDefaults::Paints::defaultText();
or
ColorPaint c(SystemDefaults::Paints::defaultText());
| Parameters | |
|---|---|
| orig |
The ColorPaint object to create a copy of. |
BlackBerry 10.0.0
bool 
Checks whether this Paint object is a null paint.
true if this Paint object is a null paint, false otherwise.
BlackBerry 10.0.0
virtualColorPaint & 
Assignment operator that makes this color a copy of the passed color.
| Parameters | |
|---|---|
| other |
The ColorPaint object to make a copy of. |
BlackBerry 10.0.0
Copy constructor for Paint objects.
BlackBerry 10.0.0
Static Public Functions
Color
Creates a Color with specified red, green, blue and alpha components.
Values must be in the [0.0 - 1.0] range. If alpha is not specified it is assumed to be 1.0f. If components are not in the [0.0 - 1.0] range they are clamped to it.
// Creates a nice yellow color. Alpha is left out and // thus gets the default value 1.0f. Color c = Color::fromRGBA(1.0f, 0.8f, 0.2f);
| Parameters | |
|---|---|
| red |
The red component. |
| green |
The green component. |
| blue |
The blue component. |
| alpha |
The alpha component (optional, defaults to 1.0f). |
The created color object.
BlackBerry 10.0.0