Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_SLIDESHOW_SOURCE_INC_HSLCOLOR_HXX
21 : #define INCLUDED_SLIDESHOW_SOURCE_INC_HSLCOLOR_HXX
22 :
23 : #include <cppcanvas/color.hxx>
24 :
25 :
26 : /* Definition of HSLColor class */
27 :
28 : namespace slideshow
29 : {
30 : namespace internal
31 : {
32 : class RGBColor;
33 :
34 : /** HSL color space class.
35 : */
36 : class HSLColor
37 : {
38 : public:
39 : HSLColor();
40 : HSLColor( double nHue, double nSaturation, double nLuminance );
41 : explicit HSLColor( const RGBColor& rColor );
42 :
43 : /** Hue of the color.
44 :
45 : @return hue, is in the range [0,360]
46 : */
47 0 : double getHue() const { return maHSLTriple.mnHue; }
48 :
49 : /** Saturation of the color.
50 :
51 : @return saturation, is in the range [0,1]
52 : */
53 0 : double getSaturation() const { return maHSLTriple.mnSaturation; }
54 :
55 : /** Luminance of the color.
56 :
57 : @return luminance, is in the range [0,1]
58 : */
59 0 : double getLuminance() const { return maHSLTriple.mnLuminance; }
60 :
61 : struct HSLTriple
62 : {
63 : HSLTriple();
64 : HSLTriple( double nHue, double nSaturation, double nLuminance );
65 :
66 : double mnHue;
67 : double mnSaturation;
68 : double mnLuminance;
69 : };
70 :
71 : private:
72 : // default copy/assignment are okay
73 : // HSLColor(const HSLColor&);
74 : // HSLColor& operator=( const HSLColor& );
75 :
76 : HSLTriple maHSLTriple;
77 :
78 : /// Pre-calculated value, needed for conversion back to RGB
79 : double mnMagicValue;
80 : };
81 :
82 : bool operator==( const HSLColor& rLHS, const HSLColor& rRHS );
83 : bool operator!=( const HSLColor& rLHS, const HSLColor& rRHS );
84 : HSLColor operator+( const HSLColor& rLHS, const HSLColor& rRHS );
85 : HSLColor operator*( const HSLColor& rLHS, const HSLColor& rRHS );
86 : HSLColor operator*( double nFactor, const HSLColor& rRHS );
87 :
88 : /** HSL color linear interpolator.
89 :
90 : @param t
91 : As usual, t must be in the [0,1] range
92 :
93 : @param bCCW
94 : When true, hue interpolation happens counter-clockwise
95 : */
96 : HSLColor interpolate( const HSLColor& rFrom, const HSLColor& rTo, double t, bool bCCW=true );
97 : }
98 : }
99 :
100 : #endif // INCLUDED_SLIDESHOW_SOURCE_INC_HSLCOLOR_HXX
101 :
102 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|