xref: /AOO41X/main/slideshow/source/inc/hslcolor.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_HSLCOLOR_HXX
29 #define INCLUDED_SLIDESHOW_HSLCOLOR_HXX
30 
31 #include <cppcanvas/color.hxx>
32 
33 
34 /* Definition of HSLColor class */
35 
36 namespace slideshow
37 {
38     namespace internal
39     {
40         class RGBColor;
41 
42         /** HSL color space class.
43          */
44         class HSLColor
45         {
46         public:
47             HSLColor();
48             explicit HSLColor( ::cppcanvas::Color::IntSRGBA nRGBColor );
49             HSLColor( double nHue, double nSaturation, double nLuminance );
50             explicit HSLColor( const RGBColor& 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 RGB color object.
83              */
84             RGBColor getRGBColor() const;
85 
86             struct HSLTriple
87             {
88                 HSLTriple();
89                 HSLTriple( double nHue, double nSaturation, double nLuminance );
90 
91                 double mnHue;
92                 double mnSaturation;
93                 double mnLuminance;
94             };
95 
96         private:
97             // default copy/assignment are okay
98             // HSLColor(const HSLColor&);
99             // HSLColor& operator=( const HSLColor& );
100 
101             HSLTriple	maHSLTriple;
102 
103             /// Pre-calculated value, needed for conversion back to RGB
104             double 		mnMagicValue;
105         };
106 
107         HSLColor operator+( const HSLColor& rLHS, const HSLColor& rRHS );
108         HSLColor operator*( const HSLColor& rLHS, const HSLColor& rRHS );
109         HSLColor operator*( double nFactor, const HSLColor& rRHS );
110 
111         /** HSL color linear interpolator.
112 
113             @param t
114             As usual, t must be in the [0,1] range
115 
116             @param bCCW
117             When true, hue interpolation happens counter-clockwise
118         */
119         HSLColor interpolate( const HSLColor& rFrom, const HSLColor& rTo, double t, bool bCCW=true );
120     }
121 }
122 
123 #endif /* INCLUDED_SLIDESHOW_HSLCOLOR_HXX */
124