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_FillType.cpp
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
30 : colour (0xff000000)
31{
32}
33
35 : colour (c)
36{
37}
38
40 : colour (0xff000000), gradient (new ColourGradient (g))
41{
42}
43
45 : colour (0xff000000), gradient (new ColourGradient (std::move (g)))
46{
47}
48
49FillType::FillType (const Image& im, const AffineTransform& t) noexcept
50 : colour (0xff000000), image (im), transform (t)
51{
52}
53
55 : colour (other.colour),
56 gradient (createCopyIfNotNull (other.gradient.get())),
57 image (other.image),
58 transform (other.transform)
59{
60}
61
63{
64 if (this != &other)
65 {
66 colour = other.colour;
67 gradient.reset (createCopyIfNotNull (other.gradient.get()));
68 image = other.image;
69 transform = other.transform;
70 }
71
72 return *this;
73}
74
76 : colour (other.colour),
77 gradient (std::move (other.gradient)),
78 image (std::move (other.image)),
79 transform (other.transform)
80{
81}
82
84{
85 jassert (this != &other); // hopefully the compiler should make this situation impossible!
86
87 colour = other.colour;
88 gradient = std::move (other.gradient);
89 image = std::move (other.image);
90 transform = other.transform;
91 return *this;
92}
93
95{
96}
97
98bool FillType::operator== (const FillType& other) const
99{
100 return colour == other.colour && image == other.image
101 && transform == other.transform
102 && (gradient == other.gradient
103 || (gradient != nullptr && other.gradient != nullptr && *gradient == *other.gradient));
104}
105
106bool FillType::operator!= (const FillType& other) const
107{
108 return ! operator== (other);
109}
110
112{
113 gradient.reset();
114 image = {};
115 colour = newColour;
116}
117
119{
120 if (gradient != nullptr)
121 {
123 }
124 else
125 {
126 image = {};
127 gradient.reset (new ColourGradient (newGradient));
128 colour = Colours::black;
129 }
130}
131
133{
134 gradient.reset();
135 image = newImage;
136 transform = newTransform;
137 colour = Colours::black;
138}
139
140void FillType::setOpacity (const float newOpacity) noexcept
141{
142 colour = colour.withAlpha (newOpacity);
143}
144
146{
147 return colour.isTransparent() || (gradient != nullptr && gradient->isInvisible());
148}
149
151{
152 FillType f (*this);
154 return f;
155}
156
157} // namespace juce
Represents a 2D affine-transformation matrix.
AffineTransform followedBy(const AffineTransform &other) const noexcept
Returns the result of concatenating another transformation after this one.
Describes the layout and colours that should be used to paint a colour gradient.
Represents a colour, also including a transparency value.
Definition juce_Colour.h:38
bool isTransparent() const noexcept
Returns true if this colour is completely transparent.
Represents a colour or fill pattern to use for rendering paths.
FillType & operator=(const FillType &)
Makes a copy of another FillType.
Image image
The image that should be used for tiling.
void setColour(Colour newColour) noexcept
Turns this object into a solid colour fill.
void setGradient(const ColourGradient &newGradient)
Turns this object into a gradient fill.
FillType transformed(const AffineTransform &transform) const
Returns a copy of this fill, adding the specified transform applied to the existing transform.
void setOpacity(float newOpacity) noexcept
Changes the opacity that should be used.
AffineTransform transform
The transform that should be applied to the image or gradient that's being drawn.
void setTiledImage(const Image &image, const AffineTransform &transform) noexcept
Turns this object into a tiled image fill type.
Colour colour
The solid colour being used.
FillType() noexcept
Creates a default fill type, of solid black.
~FillType() noexcept
Destructor.
std::unique_ptr< ColourGradient > gradient
Returns the gradient that should be used for filling.
bool isInvisible() const noexcept
Returns true if this fill type is completely transparent.
Holds a fixed-size bitmap.
Definition juce_Image.h:58
#define jassert(expression)
Platform-independent assertion macro.
JUCE Namespace.
Type * createCopyIfNotNull(const Type *objectToCopy)
If a pointer is non-null, this returns a new copy of the object that it points to,...
Definition juce_Memory.h:60
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