openshot-audio  0.1.5
juce_Colour.h
Go to the documentation of this file.
1 /*
2  ==============================================================================
3 
4  This file is part of the JUCE library.
5  Copyright (c) 2015 - ROLI Ltd.
6 
7  Permission is granted to use this software under the terms of either:
8  a) the GPL v2 (or any later version)
9  b) the Affero GPL v3
10 
11  Details of these licenses can be found at: www.gnu.org/licenses
12 
13  JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
14  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15  A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 
17  ------------------------------------------------------------------------------
18 
19  To release a closed-source product which uses JUCE, commercial licenses are
20  available: visit www.juce.com for more information.
21 
22  ==============================================================================
23 */
24 
25 #ifndef JUCE_COLOUR_H_INCLUDED
26 #define JUCE_COLOUR_H_INCLUDED
27 
28 
29 //==============================================================================
36 {
37 public:
38  //==============================================================================
40  Colour() noexcept;
41 
43  Colour (const Colour& other) noexcept;
44 
55  explicit Colour (uint32 argb) noexcept;
56 
58  Colour (uint8 red,
59  uint8 green,
60  uint8 blue) noexcept;
61 
63  static Colour fromRGB (uint8 red,
64  uint8 green,
65  uint8 blue) noexcept;
66 
68  Colour (uint8 red,
69  uint8 green,
70  uint8 blue,
71  uint8 alpha) noexcept;
72 
74  static Colour fromRGBA (uint8 red,
75  uint8 green,
76  uint8 blue,
77  uint8 alpha) noexcept;
78 
84  Colour (uint8 red,
85  uint8 green,
86  uint8 blue,
87  float alpha) noexcept;
88 
92  static Colour fromFloatRGBA (float red,
93  float green,
94  float blue,
95  float alpha) noexcept;
96 
103  Colour (float hue,
104  float saturation,
105  float brightness,
106  uint8 alpha) noexcept;
107 
113  Colour (float hue,
114  float saturation,
115  float brightness,
116  float alpha) noexcept;
117 
121  Colour (PixelARGB argb) noexcept;
122 
125  Colour (PixelRGB rgb) noexcept;
126 
129  Colour (PixelAlpha alpha) noexcept;
130 
137  static Colour fromHSV (float hue,
138  float saturation,
139  float brightness,
140  float alpha) noexcept;
141 
143  ~Colour() noexcept;
144 
146  Colour& operator= (const Colour& other) noexcept;
147 
149  bool operator== (const Colour& other) const noexcept;
151  bool operator!= (const Colour& other) const noexcept;
152 
153  //==============================================================================
157  uint8 getRed() const noexcept { return argb.getRed(); }
158 
162  uint8 getGreen() const noexcept { return argb.getGreen(); }
163 
167  uint8 getBlue() const noexcept { return argb.getBlue(); }
168 
172  float getFloatRed() const noexcept;
173 
177  float getFloatGreen() const noexcept;
178 
182  float getFloatBlue() const noexcept;
183 
186  const PixelARGB getPixelARGB() const noexcept;
187 
193  uint32 getARGB() const noexcept;
194 
195  //==============================================================================
200  uint8 getAlpha() const noexcept { return argb.getAlpha(); }
201 
206  float getFloatAlpha() const noexcept;
207 
212  bool isOpaque() const noexcept;
213 
218  bool isTransparent() const noexcept;
219 
221  Colour withAlpha (uint8 newAlpha) const noexcept;
222 
224  Colour withAlpha (float newAlpha) const noexcept;
225 
229  Colour withMultipliedAlpha (float alphaMultiplier) const noexcept;
230 
231  //==============================================================================
235  Colour overlaidWith (Colour foregroundColour) const noexcept;
236 
241  Colour interpolatedWith (Colour other, float proportionOfOther) const noexcept;
242 
243  //==============================================================================
247  float getHue() const noexcept;
248 
252  float getSaturation() const noexcept;
253 
257  float getBrightness() const noexcept;
258 
263  float getPerceivedBrightness() const noexcept;
264 
268  void getHSB (float& hue,
269  float& saturation,
270  float& brightness) const noexcept;
271 
272  //==============================================================================
274  Colour withHue (float newHue) const noexcept;
275 
277  Colour withSaturation (float newSaturation) const noexcept;
278 
282  Colour withBrightness (float newBrightness) const noexcept;
283 
290  Colour withRotatedHue (float amountToRotate) const noexcept;
291 
297  Colour withMultipliedSaturation (float multiplier) const noexcept;
298 
304  Colour withMultipliedBrightness (float amount) const noexcept;
305 
306  //==============================================================================
313  Colour brighter (float amountBrighter = 0.4f) const noexcept;
314 
321  Colour darker (float amountDarker = 0.4f) const noexcept;
322 
323  //==============================================================================
331  Colour contrasting (float amount = 1.0f) const noexcept;
332 
340  Colour contrasting (Colour targetColour, float minLuminosityDiff) const noexcept;
341 
346  static Colour contrasting (Colour colour1,
347  Colour colour2) noexcept;
348 
349  //==============================================================================
353  static Colour greyLevel (float brightness) noexcept;
354 
355  //==============================================================================
359  String toString() const;
360 
362  static Colour fromString (StringRef encodedColourString);
363 
365  String toDisplayString (bool includeAlphaValue) const;
366 
367 private:
368  //==============================================================================
369  PixelARGB argb;
370 };
371 
372 
373 #endif // JUCE_COLOUR_H_INCLUDED
#define noexcept
Definition: juce_CompilerSupport.h:141
uint8 getAlpha() const noexcept
Definition: juce_Colour.h:200
Definition: juce_String.h:43
uint8 getGreen() const noexcept
Definition: juce_Colour.h:162
#define JUCE_API
Definition: juce_StandardHeader.h:139
unsigned int uint32
Definition: juce_MathsFunctions.h:51
Definition: juce_Colour.h:35
Definition: juce_PixelFormats.h:610
forcedinline uint8 getBlue() const noexcept
Definition: juce_PixelFormats.h:109
uint8 getRed() const noexcept
Definition: juce_Colour.h:157
forcedinline uint8 getRed() const noexcept
Definition: juce_PixelFormats.h:107
bool operator==(const var &v1, const var &v2) noexcept
Definition: juce_Variant.cpp:565
forcedinline uint8 getGreen() const noexcept
Definition: juce_PixelFormats.h:108
Definition: juce_PixelFormats.h:56
uint8 getBlue() const noexcept
Definition: juce_Colour.h:167
bool operator!=(const var &v1, const var &v2) noexcept
Definition: juce_Variant.cpp:566
unsigned char uint8
Definition: juce_MathsFunctions.h:43
forcedinline uint8 getAlpha() const noexcept
Definition: juce_PixelFormats.h:106
Definition: juce_PixelFormats.h:361
Definition: juce_StringRef.h:65