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