JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
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) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
29//==============================================================================
37class JUCE_API Colour final
38{
39public:
40 //==============================================================================
42 Colour() = default;
43
45 Colour (const Colour&) = default;
46
57 explicit Colour (uint32 argb) noexcept;
58
60 Colour (uint8 red,
61 uint8 green,
62 uint8 blue) noexcept;
63
65 static Colour fromRGB (uint8 red,
66 uint8 green,
67 uint8 blue) noexcept;
68
70 Colour (uint8 red,
71 uint8 green,
72 uint8 blue,
73 uint8 alpha) noexcept;
74
76 static Colour fromRGBA (uint8 red,
77 uint8 green,
78 uint8 blue,
79 uint8 alpha) noexcept;
80
86 Colour (uint8 red,
87 uint8 green,
88 uint8 blue,
89 float alpha) noexcept;
90
94 static Colour fromFloatRGBA (float red,
95 float green,
96 float blue,
97 float alpha) noexcept;
98
105 Colour (float hue,
106 float saturation,
107 float brightness,
108 uint8 alpha) noexcept;
109
115 Colour (float hue,
116 float saturation,
117 float brightness,
118 float alpha) noexcept;
119
125 static Colour fromHSV (float hue,
126 float saturation,
127 float brightness,
128 float alpha) noexcept;
129
135 static Colour fromHSL (float hue,
136 float saturation,
137 float lightness,
138 float alpha) noexcept;
139
143 Colour (PixelARGB argb) noexcept;
144
147 Colour (PixelRGB rgb) noexcept;
148
151 Colour (PixelAlpha alpha) noexcept;
152
154 ~Colour() = default;
155
157 Colour& operator= (const Colour&) = default;
158
160 bool operator== (const Colour& other) const noexcept;
162 bool operator!= (const Colour& other) const noexcept;
163
164 //==============================================================================
168 uint8 getRed() const noexcept { return argb.getRed(); }
169
173 uint8 getGreen() const noexcept { return argb.getGreen(); }
174
178 uint8 getBlue() const noexcept { return argb.getBlue(); }
179
183 float getFloatRed() const noexcept;
184
188 float getFloatGreen() const noexcept;
189
193 float getFloatBlue() const noexcept;
194
197 PixelARGB getPixelARGB() const noexcept;
198
201 PixelARGB getNonPremultipliedPixelARGB() const noexcept;
202
208 uint32 getARGB() const noexcept;
209
210 //==============================================================================
215 uint8 getAlpha() const noexcept { return argb.getAlpha(); }
216
221 float getFloatAlpha() const noexcept;
222
227 bool isOpaque() const noexcept;
228
233 bool isTransparent() const noexcept;
234
236 Colour withAlpha (uint8 newAlpha) const noexcept;
237
239 Colour withAlpha (float newAlpha) const noexcept;
240
244 Colour withMultipliedAlpha (float alphaMultiplier) const noexcept;
245
246 //==============================================================================
250 Colour overlaidWith (Colour foregroundColour) const noexcept;
251
256 Colour interpolatedWith (Colour other, float proportionOfOther) const noexcept;
257
258 //==============================================================================
262 float getHue() const noexcept;
263
267 float getSaturation() const noexcept;
268
272 float getSaturationHSL() const noexcept;
273
277 float getBrightness() const noexcept;
278
282 float getLightness() const noexcept;
283
288 float getPerceivedBrightness() const noexcept;
289
293 void getHSB (float& hue,
294 float& saturation,
295 float& brightness) const noexcept;
296
300 void getHSL (float& hue,
301 float& saturation,
302 float& lightness) const noexcept;
303
304 //==============================================================================
306 [[nodiscard]] Colour withHue (float newHue) const noexcept;
307
309 [[nodiscard]] Colour withSaturation (float newSaturation) const noexcept;
310
312 [[nodiscard]] Colour withSaturationHSL (float newSaturation) const noexcept;
313
317 [[nodiscard]] Colour withBrightness (float newBrightness) const noexcept;
318
322 [[nodiscard]] Colour withLightness (float newLightness) const noexcept;
323
328 [[nodiscard]] Colour withRotatedHue (float amountToRotate) const noexcept;
329
334 [[nodiscard]] Colour withMultipliedSaturation (float multiplier) const noexcept;
335
342 [[nodiscard]] Colour withMultipliedSaturationHSL (float multiplier) const noexcept;
343
348 [[nodiscard]] Colour withMultipliedBrightness (float amount) const noexcept;
349
354 [[nodiscard]] Colour withMultipliedLightness (float amount) const noexcept;
355
356 //==============================================================================
362 [[nodiscard]] Colour brighter (float amountBrighter = 0.4f) const noexcept;
363
369 [[nodiscard]] Colour darker (float amountDarker = 0.4f) const noexcept;
370
371 //==============================================================================
379 [[nodiscard]] Colour contrasting (float amount = 1.0f) const noexcept;
380
388 [[nodiscard]] Colour contrasting (Colour targetColour, float minLuminosityDiff) const noexcept;
389
394 [[nodiscard]] static Colour contrasting (Colour colour1,
395 Colour colour2) noexcept;
396
397 //==============================================================================
401 [[nodiscard]] static Colour greyLevel (float brightness) noexcept;
402
403 //==============================================================================
407 String toString() const;
408
410 [[nodiscard]] static Colour fromString (StringRef encodedColourString);
411
413 String toDisplayString (bool includeAlphaValue) const;
414
415private:
416 //==============================================================================
417 PixelARGB argb { 0, 0, 0, 0 };
418};
419
420} // namespace juce
Represents a colour, also including a transparency value.
Definition juce_Colour.h:38
uint8 getBlue() const noexcept
Returns the blue component of this colour.
~Colour()=default
Destructor.
Colour(const Colour &)=default
Creates a copy of another Colour object.
uint8 getGreen() const noexcept
Returns the green component of this colour.
uint8 getRed() const noexcept
Returns the red component of this colour.
Colour()=default
Creates a transparent black colour.
Represents a 32-bit INTERNAL pixel with premultiplied alpha, and can perform compositing operations w...
Represents an 8-bit single-channel pixel, and can perform compositing operations on it.
Represents a 24-bit RGB pixel, and can perform compositing operations on it.
A simple class for holding temporary references to a string literal or String.
The JUCE String class!
Definition juce_String.h:53
JUCE Namespace.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Definition juce_Memory.h:88
unsigned int uint32
A platform-independent 32-bit unsigned integer type.
unsigned char uint8
A platform-independent 8-bit unsigned integer type.