xref: /aoo4110/main/slideshow/source/inc/rgbcolor.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef INCLUDED_SLIDESHOW_RGBCOLOR_HXX
25 #define INCLUDED_SLIDESHOW_RGBCOLOR_HXX
26 
27 #include <cppcanvas/color.hxx>
28 
29 
30 /* Definition of RGBColor class */
31 
32 namespace slideshow
33 {
34     namespace internal
35     {
36         class HSLColor;
37 
38         /** RGB color space class.
39          */
40         class RGBColor
41         {
42         public:
43             RGBColor();
44             explicit RGBColor( ::cppcanvas::Color::IntSRGBA nRGBColor );
45             RGBColor( double nRed, double nGreen, double nBlue );
46             explicit RGBColor( const HSLColor& rColor );
47 
48             /** Hue of the color.
49 
50             	@return hue, is in the range [0,360]
51              */
52             double getHue() const;
53 
54             /** Saturation of the color.
55 
56             	@return saturation, is in the range [0,1]
57              */
58             double getSaturation() const;
59 
60             /** Luminance of the color.
61 
62             	@return luminance, is in the range [0,1]
63              */
64             double getLuminance() const;
65 
66             /** Get the RGB red value.
67              */
68             double getRed() const;
69 
70             /** Get the RGB green value.
71              */
72             double getGreen() const;
73 
74             /** Get the RGB blue value.
75              */
76             double getBlue() const;
77 
78             /** Create an HSL color object.
79              */
80             HSLColor getHSLColor() const;
81 
82             /** Create an integer sRGBA color.
83              */
84             ::cppcanvas::Color::IntSRGBA getIntegerColor() const;
85 
86             RGBColor(const RGBColor& rLHS);
87             RGBColor& operator=( const RGBColor& rLHS);
88 
89             struct RGBTriple
90             {
91                 RGBTriple();
92                 RGBTriple( double nRed, double nGreen, double nBlue );
93 
94                 double mnRed;
95                 double mnGreen;
96                 double mnBlue;
97             };
98 
99         private:
100             // default copy/assignment are okay
101             // RGBColor(const RGBColor&);
102             // RGBColor& operator=( const RGBColor& );
103 
104             RGBTriple	maRGBTriple;
105         };
106 
107         RGBColor operator+( const RGBColor& rLHS, const RGBColor& rRHS );
108         RGBColor operator*( const RGBColor& rLHS, const RGBColor& rRHS );
109         RGBColor operator*( double nFactor, const RGBColor& rRHS );
110 
111 
112         /** RGB color linear interpolator.
113 
114             @param t
115             As usual, t must be in the [0,1] range
116         */
117         RGBColor interpolate( const RGBColor& rFrom, const RGBColor& rTo, double t );
118     }
119 }
120 
121 #endif /* INCLUDED_SLIDESHOW_RGBCOLOR_HXX */
122