Gdk::RGBA Class Reference

An RGBA Color. More...

## Public Member Functions

| RGBA (GdkRGBA* gobject, bool make_a_copy=true)
| RGBA (const RGBA& other)
RGBA& | operator= (const RGBA& other)
| ~RGBA ()
void | swap (RGBA& other)
GdkRGBA* | gobj ()
| Provides access to the underlying C instance. More...
const GdkRGBA* | gobj () const
| Provides access to the underlying C instance. More...
GdkRGBA* | gobj_copy () const
| Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs. More...
| RGBA ()
| Instantiate a new Gdk::RGBA. More...
| RGBA (const Glib::ustring&value)
| Instantiate a new Gdk::RGBA. More...
void | set_grey_u (gushort value, gushort alpha=65535)
| Set a grey color, by using the same value for all color components. More...
void | set_grey (double g, double alpha=1.0)
void | set_rgba_u (gushort red_, gushort green_, gushort blue_, gushort alpha_=65535)
| Set the color, by specifying red, green, and blue color component values. More...
void | set_rgba (double red_, double green_, double blue_, double alpha_=1.0)
| Set the color, by specifying red, green, and blue color component values, as percentages. More...
void | set_hsv (double h, double s, double v)
void | set_hsl (double h, double s, double l)
bool | set (const Glib::ustring& spec)
| Parses a textual representation of a color, filling in the `red`, `green`, `blue` and `alpha` fields of the rgba struct. More...
gushort | get_red_u () const
| Get the red component of the color. More...
gushort | get_green_u () const
| Get the green component of the color. More...
gushort | get_blue_u () const
| Get the blue component of the color. More...
gushort | get_alpha_u () const
| Get the alpha component of the color. More...
void | set_red_u (gushort value)
| Set the red component of the color. More...
void | set_green_u (gushort value)
| Set the green component of the color. More...
void | set_blue_u (gushort value)
| Set the blue component of the color. More...
void | set_alpha_u (gushort value)
| Set the alpha component of the color. More...
double | get_red () const
| Get the red component of the color, as a percentage. More...
double | get_green () const
| Get the green component of the color, as a percentage. More...
double | get_blue () const
| Get the blue component of the color, as a percentage. More...
double | get_alpha () const
| Get the alpha component of the color, as a percentage. More...
void | set_red (double value)
| Set the red component of the color, as a percentage. More...
void | set_green (double value)
| Set the green component of the color, as a percentage. More...
void | set_blue (double value)
| Set the blue component of the color, as a percentage. More...
void | set_alpha (double value)
| Set the alpha component of the color, as a percentage. More...
Glib::ustring | to_string () const
| Returns a textual specification of rgba in the form `rgb (r, g, b)` or `rgba (r, g, b, a)`, where 'r', 'g', 'b' and 'a' represent the red, green, blue and alpha values respectively. More...

## Static Public Member Functions

static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system. More...

## Protected Attributes

GdkRGBA* | gobject_

## Related Functions

(Note that these are not member functions.)
bool | operator== (const RGBA& lhs, const RGBA& rhs)
bool | operator!= (const RGBA& lhs, const RGBA& rhs)
void | swap (RGBA& lhs, RGBA& rhs)
Gdk::RGBA | wrap (GdkRGBA* object, bool take_copy=false)
| A Glib::wrap() method for this object. More...

## Detailed Description

An RGBA Color.

The RGBA class is a convenient way to pass rgba colors around. It's based on cairo's way to deal with (possibly translucent) colors and mirrors its behavior. All values are in the range from 0.0 to 1.0 inclusive. So the color (0.0, 0.0, 0.0, 0.0) represents transparent black and (1.0, 1.0, 1.0, 1.0) is opaque white. Other values will be clamped to this range when drawing.

## Constructor & Destructor Documentation

Gdk::RGBA::RGBA | ( | GdkRGBA * | gobject,
|  | bool | make_a_copy = `true`
| ) |  |

explicit

Gdk::RGBA::RGBA | ( | const RGBA& | other | ) |

Gdk::RGBA::~RGBA | ( |  | ) |

Gdk::RGBA::RGBA | ( |  | ) |

Instantiate a new Gdk::RGBA.

Gdk::RGBA::RGBA | ( | const Glib::ustring & | value | ) |

explicit

Instantiate a new Gdk::RGBA.

The text string can be in any of the forms accepted by XParseRGBA; these include names for a color from rgb.txt, such as DarkSlateGray, or a hex specification such as 305050.

Parameters

  value | the string specifying the color..

## Member Function Documentation

double Gdk::RGBA::get_alpha | ( |  | ) | const

Get the alpha component of the color, as a percentage.

Returns
  The alpha component of the color, as a percentage.

gushort Gdk::RGBA::get_alpha_u | ( |  | ) | const

Get the alpha component of the color.

Returns
  The alpha component of the color.

double Gdk::RGBA::get_blue | ( |  | ) | const

Get the blue component of the color, as a percentage.

Returns
  The blue component of the color, as a percentage.

gushort Gdk::RGBA::get_blue_u | ( |  | ) | const

Get the blue component of the color.

Returns
  The blue component of the color.

double Gdk::RGBA::get_green | ( |  | ) | const

Get the green component of the color, as a percentage.

Returns
  The green component of the color, as a percentage.

gushort Gdk::RGBA::get_green_u | ( |  | ) | const

Get the green component of the color.

Returns
  The green component of the color.

double Gdk::RGBA::get_red | ( |  | ) | const

Get the red component of the color, as a percentage.

Returns
  The red component of the color, as a percentage.

gushort Gdk::RGBA::get_red_u | ( |  | ) | const

Get the red component of the color.

Returns
  The red component of the color.

static GType Gdk::RGBA::get_type | ( |  | ) |

static

Get the GType for this class, for use with the underlying GObject type system.

GdkRGBA* Gdk::RGBA::gobj | ( |  | ) |

inline

Provides access to the underlying C instance.

const GdkRGBA* Gdk::RGBA::gobj | ( |  | ) | const

inline

Provides access to the underlying C instance.

GdkRGBA* Gdk::RGBA::gobj_copy | ( |  | ) | const

Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs.

RGBA& Gdk::RGBA::operator= | ( | const RGBA& | other | ) |

bool Gdk::RGBA::set | ( | const Glib::ustring & | spec | ) |

Parses a textual representation of a color, filling in the `red`, `green`, `blue` and `alpha` fields of the rgba struct.

The string can be either one of:

- A standard name (Taken from the X11 rgb.txt file).
- A hex value in the form '#rgb' '#rrggbb' '#rrrgggbbb' or '#rrrrggggbbbb'
- A RGB color in the form 'rgb(r,g,b)' (In this case the color will have full opacity)
- A RGBA color in the form 'rgba(r,g,b,a)'

Where 'r', 'g', 'b' and 'a' are respectively the red, green, blue and alpha color values. In the last two cases, r g and b are either integers in the range 0 to 255 or precentage values in the range 0% to 100%, and a is a floating point value in the range 0 to 1.

Since gtkmm 3.0:

Parameters

  spec | The string specifying the color.

Returns
  `true` if the parsing succeeded.

void Gdk::RGBA::set_alpha | ( | double | value | ) |

Set the alpha component of the color, as a percentage.

Parameters

  value | The alpha component of the color.

void Gdk::RGBA::set_alpha_u | ( | gushort | value | ) |

Set the alpha component of the color.

Parameters

  value | The alpha component of the color.

void Gdk::RGBA::set_blue | ( | double | value | ) |

Set the blue component of the color, as a percentage.

Parameters

  value | The blue component of the color.

void Gdk::RGBA::set_blue_u | ( | gushort | value | ) |

Set the blue component of the color.

Parameters

  value | The blue component of the color.

void Gdk::RGBA::set_green | ( | double | value | ) |

Set the green component of the color, as a percentage.

Parameters

  value | The green component of the color.

void Gdk::RGBA::set_green_u | ( | gushort | value | ) |

Set the green component of the color.

Parameters

  value | The green component of the color.

void Gdk::RGBA::set_grey | ( | double | g,
|  | double | alpha = `1.0`
| ) |  |

void Gdk::RGBA::set_grey_u | ( | gushort | value,
|  | gushort | alpha = `65535`
| ) |  |

Set a grey color, by using the same value for all color components.

Parameters

  value | The value to be used for the red, green, and blue components.
  alpha | The alpha component of the color.

void Gdk::RGBA::set_hsl | ( | double | h,
|  | double | s,
|  | double | l
| ) |  |

void Gdk::RGBA::set_hsv | ( | double | h,
|  | double | s,
|  | double | v
| ) |  |

void Gdk::RGBA::set_red | ( | double | value | ) |

Set the red component of the color, as a percentage.

Parameters

  value | The red component of the color.

void Gdk::RGBA::set_red_u | ( | gushort | value | ) |

Set the red component of the color.

Parameters

  value | The red component of the color.

void Gdk::RGBA::set_rgba | ( | double | red_,
|  | double | green_,
|  | double | blue_,
|  | double | alpha_ = `1.0`
| ) |  |

Set the color, by specifying red, green, and blue color component values, as percentages.

Parameters

  red_ | The red component of the color, as a percentage.
  green_ | The green component of the color, as a percentage.
  blue_ | The blue component of the color, as a percentage.
  alpha_ | The alpha component of the color, as a percentage.

void Gdk::RGBA::set_rgba_u | ( | gushort | red_,
|  | gushort | green_,
|  | gushort | blue_,
|  | gushort | alpha_ = `65535`
| ) |  |

Set the color, by specifying red, green, and blue color component values.

Parameters

  red_ | The red component of the color.
  green_ | The green component of the color.
  blue_ | The blue component of the color.
  alpha_ | The alpha component of the color.

void Gdk::RGBA::swap | ( | RGBA& | other | ) |

Glib::ustring Gdk::RGBA::to_string | ( |  | ) | const

Returns a textual specification of rgba in the form `rgb (r, g, b)` or `rgba (r, g, b, a)`, where 'r', 'g', 'b' and 'a' represent the red, green, blue and alpha values respectively.

r, g, and b are represented as integers in the range 0 to 255, and a is represented as floating point value in the range 0 to 1.

These string forms are string forms those supported by the CSS3 colors module, and can be parsed by parse().

Note that this string representation may lose some precision, since r, g and b are represented as 8-bit integers. If this is a concern, you should use a different representation.

Since gtkmm 3.0:

Returns
  A newly allocated text string.

## Friends And Related Function Documentation

bool operator!= | ( | const RGBA& | lhs,
|  | const RGBA& | rhs
| ) |  |

related

Parameters

  lhs | The left-hand side
  rhs | The right-hand side

Returns
  The result

bool operator== | ( | const RGBA& | lhs,
|  | const RGBA& | rhs
| ) |  |

related

Parameters

  lhs | The left-hand side
  rhs | The right-hand side

Returns
  The result

void swap | ( | RGBA& | lhs,
|  | RGBA& | rhs
| ) |  |

related

Parameters

  lhs | The left-hand side
  rhs | The right-hand side

Gdk::RGBA wrap | ( | GdkRGBA * | object,
|  | bool | take_copy = `false`
| ) |  |

related

A Glib::wrap() method for this object.

Parameters

  object | The C instance.
  take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns
  A C++ instance that wraps this C instance.

## Member Data Documentation

GdkRGBA* Gdk::RGBA::gobject_

protected

The documentation for this class was generated from the following file:

- gdkmm/rgba.h