\( \newcommand{\E}{\mathrm{E}} \) \( \newcommand{\A}{\mathrm{A}} \) \( \newcommand{\R}{\mathrm{R}} \) \( \newcommand{\N}{\mathrm{N}} \) \( \newcommand{\Q}{\mathrm{Q}} \) \( \newcommand{\Z}{\mathrm{Z}} \) \( \def\ccSum #1#2#3{ \sum_{#1}^{#2}{#3} } \def\ccProd #1#2#3{ \sum_{#1}^{#2}{#3} }\)
CGAL 5.0.2 - IO Streams
CGAL::Color Class Reference

#include <CGAL/IO/Color.h>

Definition

An object of the class Color is a color available for drawing operations in many CGAL output streams.

Each color is defined by a 4 unsigned chars (r,g,b,a) with 0 \(\le\) r,g,b,a \( \le \) 255, the so-called rgba-value of the color.

The alpha parameter (representing transparency) is often ignored and left to its default value (255 = no transparency), which is why we often refer to the rgb-value of the color.

See also
CGAL::Geomview_stream

Related Functions

(Note that these are not member functions.)

Color black ()
 Constructs Color(0,0,0).
 
Color blue ()
 Constructs Color(0,0,255).
 
Color deep_blue ()
 Constructs Color(10,0,100).
 
Color gray ()
 Constructs Color(100,100,100).
 
Color green ()
 Constructs Color(0,255,0).
 
Color orange ()
 Constructs Color(235,150,0).
 
Color purple ()
 Constructs Color(100,0,70).
 
Color red ()
 Constructs Color(255,0,0).
 
Color violet ()
 Constructs Color(255,0,255).
 
Color white ()
 Constructs Color(255,255,255).
 
Color yellow ()
 Constructs Color(255,255,0).
 

Creation

 Color ()
 creates a color with rgba-value (0,0,0,255), i.e. black.
 
 Color (unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha=255)
 creates a color with rgba-value (red,green,blue,alpha).
 

Component Access

unsigned char red () const
 returns the red component.
 
unsigned char & red ()
 returns a reference on the red component.
 
unsigned char green () const
 returns the green component.
 
unsigned char & green ()
 returns a reference on the green component.
 
unsigned char blue () const
 returns the blue component.
 
unsigned char & blue ()
 returns a reference on the blue component.
 
unsigned char alpha () const
 returns the alpha component.
 
unsigned char & alpha ()
 returns a reference on the alpha component.
 

Array Access

unsigned char operator[] (std::size_t i) const
 returns the \(i^{th}\) component of the rgb color (the \(0^{th}\) is red, the \(1^{st}\) is blue, etc.).
 
unsigned char & operator[] (std::size_t i)
 returns a reference on the \(i^{th}\) component of c (the \(0^{th}\) is red, the \(1^{st}\) is blue, etc.).
 
const std::array< unsigned char, 4 > & to_rgba () const
 returns the array with rgba values.
 
const std::array< unsigned char, 3 > & to_rgb () const
 returns the array with rgb values.
 
std::array< double, 3 > to_hsv () const
 computes the hsv (hue, saturation, value) values and returns an array representing them as float values between 0 and 1.
 

Modification

void set_rgb (unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha=255)
 replaces the rgb values of the colors by the one given as parameters.
 
void set_hsv (double hue, double saturation, double value, unsigned char alpha=255)
 replaces the rgb values of the colors by the conversion to rgb of the hsv values given as parameters. More...
 

Member Function Documentation

◆ set_hsv()

void CGAL::Color::set_hsv ( double  hue,
double  saturation,
double  value,
unsigned char  alpha = 255 
)

replaces the rgb values of the colors by the conversion to rgb of the hsv values given as parameters.

Double values given as parameters should take range between 0 and 1.