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