xref: /AOO41X/main/slideshow/source/inc/rgbcolor.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef INCLUDED_SLIDESHOW_RGBCOLOR_HXX
29 #define INCLUDED_SLIDESHOW_RGBCOLOR_HXX
30 
31 #include <cppcanvas/color.hxx>
32 
33 
34 /* Definition of RGBColor class */
35 
36 namespace slideshow
37 {
38     namespace internal
39     {
40         class HSLColor;
41 
42         /** RGB color space class.
43          */
44         class RGBColor
45         {
46         public:
47             RGBColor();
48             explicit RGBColor( ::cppcanvas::Color::IntSRGBA nRGBColor );
49             RGBColor( double nRed, double nGreen, double nBlue );
50             explicit RGBColor( const HSLColor& rColor );
51 
52             /** Hue of the color.
53 
54             	@return hue, is in the range [0,360]
55              */
56             double getHue() const;
57 
58             /** Saturation of the color.
59 
60             	@return saturation, is in the range [0,1]
61              */
62             double getSaturation() const;
63 
64             /** Luminance of the color.
65 
66             	@return luminance, is in the range [0,1]
67              */
68             double getLuminance() const;
69 
70             /** Get the RGB red value.
71              */
72             double getRed() const;
73 
74             /** Get the RGB green value.
75              */
76             double getGreen() const;
77 
78             /** Get the RGB blue value.
79              */
80             double getBlue() const;
81 
82             /** Create an HSL color object.
83              */
84             HSLColor getHSLColor() const;
85 
86             /** Create an integer sRGBA color.
87              */
88             ::cppcanvas::Color::IntSRGBA getIntegerColor() const;
89 
90             RGBColor(const RGBColor& rLHS);
91             RGBColor& operator=( const RGBColor& rLHS);
92 
93             struct RGBTriple
94             {
95                 RGBTriple();
96                 RGBTriple( double nRed, double nGreen, double nBlue );
97 
98                 double mnRed;
99                 double mnGreen;
100                 double mnBlue;
101             };
102 
103         private:
104             // default copy/assignment are okay
105             // RGBColor(const RGBColor&);
106             // RGBColor& operator=( const RGBColor& );
107 
108             RGBTriple	maRGBTriple;
109         };
110 
111         RGBColor operator+( const RGBColor& rLHS, const RGBColor& rRHS );
112         RGBColor operator*( const RGBColor& rLHS, const RGBColor& rRHS );
113         RGBColor operator*( double nFactor, const RGBColor& rRHS );
114 
115 
116         /** RGB color linear interpolator.
117 
118             @param t
119             As usual, t must be in the [0,1] range
120         */
121         RGBColor interpolate( const RGBColor& rFrom, const RGBColor& rTo, double t );
122     }
123 }
124 
125 #endif /* INCLUDED_SLIDESHOW_RGBCOLOR_HXX */
126