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_ColourGradient.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 ColourGradient final
38{
39public:
45 ColourGradient() noexcept;
46
48 ColourGradient (ColourGradient&&) noexcept;
49 ColourGradient& operator= (const ColourGradient&);
50 ColourGradient& operator= (ColourGradient&&) noexcept;
51
52 //==============================================================================
70 ColourGradient (Colour colour1, float x1, float y1,
71 Colour colour2, float x2, float y2,
72 bool isRadial);
73
91 ColourGradient (Colour colour1, Point<float> point1,
92 Colour colour2, Point<float> point2,
93 bool isRadial);
94
95 //==============================================================================
97 static ColourGradient vertical (Colour colour1, float y1,
98 Colour colour2, float y2);
99
101 static ColourGradient horizontal (Colour colour1, float x1,
102 Colour colour2, float x2);
103
105 template <typename Type>
106 static ColourGradient vertical (Colour colourTop, Colour colourBottom, Rectangle<Type> area)
107 {
108 return vertical (colourTop, (float) area.getY(), colourBottom, (float) area.getBottom());
109 }
110
112 template <typename Type>
113 static ColourGradient horizontal (Colour colourLeft, Colour colourRight, Rectangle<Type> area)
114 {
115 return horizontal (colourLeft, (float) area.getX(), colourRight, (float) area.getRight());
116 }
117
120
121 //==============================================================================
127 void clearColours();
128
140 int addColour (double proportionAlongGradient, Colour colour);
141
143 void removeColour (int index);
144
146 void multiplyOpacity (float multiplier) noexcept;
147
148 //==============================================================================
150 int getNumColours() const noexcept;
151
156 double getColourPosition (int index) const noexcept;
157
161 Colour getColour (int index) const noexcept;
162
166 void setColour (int index, Colour newColour) noexcept;
167
171 Colour getColourAtPosition (double position) const noexcept;
172
173 //==============================================================================
179 int createLookupTable (const AffineTransform& transform, HeapBlock<PixelARGB>& resultLookupTable) const;
180
186 void createLookupTable (PixelARGB* resultLookupTable, int numEntries) const noexcept;
187
192 template <size_t NumEntries>
193 void createLookupTable (PixelARGB (&resultLookupTable)[NumEntries]) const noexcept
194 {
195 static_assert (NumEntries != 0);
196 createLookupTable (resultLookupTable, NumEntries);
197 }
198
200 bool isOpaque() const noexcept;
201
203 bool isInvisible() const noexcept;
204
205 //==============================================================================
206 Point<float> point1, point2;
207
213 bool isRadial;
214
215 bool operator== (const ColourGradient&) const noexcept;
216 bool operator!= (const ColourGradient&) const noexcept;
217
218
219private:
220 //==============================================================================
221 struct ColourPoint
222 {
223 bool operator== (ColourPoint) const noexcept;
224 bool operator!= (ColourPoint) const noexcept;
225
226 double position;
227 Colour colour;
228 };
229
230 Array<ColourPoint> colours;
231
233};
234
235} // namespace juce
Represents a 2D affine-transformation matrix.
Holds a resizable array of primitive or copy-by-value objects.
Definition juce_Array.h:56
Describes the layout and colours that should be used to paint a colour gradient.
static ColourGradient vertical(Colour colourTop, Colour colourBottom, Rectangle< Type > area)
Creates a vertical linear gradient from top to bottom in a rectangle.
static ColourGradient horizontal(Colour colourLeft, Colour colourRight, Rectangle< Type > area)
Creates a horizontal linear gradient from right to left in a rectangle.
Represents a colour, also including a transparency value.
Definition juce_Colour.h:38
Very simple container class to hold a pointer to some data on the heap.
Represents a 32-bit INTERNAL pixel with premultiplied alpha, and can perform compositing operations w...
A pair of (x, y) coordinates.
Definition juce_Point.h:42
Manages a rectangle and allows geometric operations to be performed on it.
ValueType getRight() const noexcept
Returns the x coordinate of the rectangle's right-hand-side.
ValueType getX() const noexcept
Returns the x coordinate of the rectangle's left-hand-side.
ValueType getBottom() const noexcept
Returns the y coordinate of the rectangle's bottom edge.
ValueType getY() const noexcept
Returns the y coordinate of the rectangle's top edge.
#define JUCE_LEAK_DETECTOR(OwnerClass)
This macro lets you embed a leak-detecting object inside a class.
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
y1