ALBA
albaColor.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: ALBA (Agile Library for Biomedical Applications)
4 Module: albaColor
5 Authors: Silvano Imboden
6
7 Copyright (c) BIC
8 All rights reserved. See Copyright.txt or
9
10
11 This software is distributed WITHOUT ANY WARRANTY; without even
12 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13 PURPOSE. See the above copyright notice for more information.
14
15=========================================================================*/
16
17#ifndef __albaColor_H__
18#define __albaColor_H__
19
20//----------------------------------------------------------------------------
42class ALBA_EXPORT albaColor
43//----------------------------------------------------------------------------
44{
45 public:
49 albaColor( int r, int g, int b, int a=0 );
51 albaColor( double *vtkRGBA );
53 albaColor( wxColour col );
54
56 void Set( wxColour col );
58 wxColour Get();
59
61 void SetRGB( int r, int g, int b, int a=-1 );
63 void GetRGB( int *r, int *g, int *b, int *a= NULL );
64
66 void SetHSV(int h, int s, int v);
68 void GetHSV(int *h, int *s, int *v);
69
72 void SetFloatRGB( double r, double g, double b, double o=-1 );
75 void GetFloatRGB( double *r, double *g, double *b, double *o );
76
79 void HSVToRGB();
82 void RGBToHSV();
83
85 static void RGBToHSV(int r, int g, int b, int *h, int *s, int *v);
87 static void HSVToRGB(int h, int s, int v, int *r, int *g, int *b);
88
90 static void RGBToHSL(int r, int g, int b, int *h, int *s, int *l);
92 static void HSLToRGB(int h, int s, int v, int *r, int *g, int *b);
93
94
96 static albaColor InterpolateHSV(albaColor c1, albaColor c2, double t);
98 static albaColor InterpolateRGB(albaColor c1, albaColor c2, double t);
99
102 static albaColor CheckeredColor(albaColor c, int x, int y)
103 {
104 static albaColor check0 = albaColor(128,128,128);
105 static albaColor check1 = albaColor(255,255,255);
106
107 int a = x%16 >= 8;
108 int b = y%16 >= 8;
109 if( a+b == 1 )
110 return albaColor::InterpolateRGB(c,check0,c.m_Alpha/255.0);
111 else
112 return albaColor::InterpolateRGB(c,check1,c.m_Alpha/255.0);
113 }
114 // member variables
115 int m_Red,m_Green,m_Blue;
116 int m_Hue,m_Saturation,m_Value;
118};
119#endif
albaColor is a class representing an RGBA color:
Definition: albaColor.h:44
void SetRGB(int r, int g, int b, int a=-1)
Set using integer RGBA - components in [0..255].
static void RGBToHSL(int r, int g, int b, int *h, int *s, int *l)
static function - conversion from RGB to HSL, all represented on Integer
static void RGBToHSV(int r, int g, int b, int *h, int *s, int *v)
static function - conversion from RGB to HSV, all represented on Integer
static albaColor InterpolateHSV(albaColor c1, albaColor c2, double t)
static function - Interpolate two color using a weight t in HSV space.
static void HSLToRGB(int h, int s, int v, int *r, int *g, int *b)
static function - conversion from RGB to HSL, all represented on Integer
void SetFloatRGB(double r, double g, double b, double o=-1)
Set using double RGBA - components normalized on [0,1].
void GetRGB(int *r, int *g, int *b, int *a=NULL)
Get returning integer RGBA - components in [0..255].
void Set(wxColour col)
Set using wxColour.
wxColour Get()
Get returning wxColour.
int m_Blue
rgb color representation
Definition: albaColor.h:115
albaColor(int r, int g, int b, int a=0)
ctor accepting an integer RGBA
int m_Hue
Definition: albaColor.h:116
void GetFloatRGB(double *r, double *g, double *b, double *o)
Get returning double RGBA - components normalized on [0,1].
albaColor(wxColour col)
ctor accepting an wxColour
albaColor()
default ctor
static albaColor CheckeredColor(albaColor c, int x, int y)
static function - used to visually render a transparent color.
Definition: albaColor.h:102
void GetHSV(int *h, int *s, int *v)
Set returning integer HSV - H in [0..360] ,S,V in [0..255].
albaColor(double *vtkRGBA)
ctor accepting an vtk color
void HSVToRGB()
Force updating the RGB representation.
void RGBToHSV()
Force updating the HSV representation.
static albaColor InterpolateRGB(albaColor c1, albaColor c2, double t)
static function - Interpolate two color using a weight t in RGB space.
static void HSVToRGB(int h, int s, int v, int *r, int *g, int *b)
static function - conversion from HSV to RGB, all represented on Integer
int m_Alpha
alpha value
Definition: albaColor.h:117
void SetHSV(int h, int s, int v)
Set using integer HSV - H in [0..360] ,S,V in [0..255].