29static void blurDataTriplets (
uint8* d,
int num,
const int delta)
noexcept
32 d[0] = (
uint8) ((d[0] + d[delta] + 1) / 3);
39 const uint32 newLast = d[0];
40 d[0] = (
uint8) ((last + d[0] + d[delta] + 1) / 3);
46 d[0] = (
uint8) ((last + d[0] + 1) / 3);
49static void blurSingleChannelImage (
uint8*
const data,
const int width,
const int height,
50 const int lineStride,
const int repetitions)
noexcept
52 jassert (width > 2 && height > 2);
54 for (
int y = 0; y < height; ++y)
55 for (
int i = repetitions; --i >= 0;)
56 blurDataTriplets (data + lineStride * y, width, 1);
58 for (
int x = 0; x < width; ++x)
59 for (
int i = repetitions; --i >= 0;)
60 blurDataTriplets (data + x, height, lineStride);
63static void blurSingleChannelImage (Image& image,
int radius)
65 const Image::BitmapData bm (image, Image::BitmapData::readWrite);
66 blurSingleChannelImage (bm.data, bm.width, bm.height, bm.lineStride, 2 * radius);
71 : colour (shadowColour), radius (r), offset (o)
85 blurSingleChannelImage (shadowImage,
radius);
100 if (area.getWidth() > 2 && area.getHeight() > 2)
108 (
float) (
offset.
y - area.getY())));
111 blurSingleChannelImage (renderedPath,
radius);
114 g.
drawImageAt (renderedPath, area.getX(), area.getY(),
true);
119 bool isCorner,
float centreX,
float centreY,
float edgeX,
float edgeY)
133 for (
float i = 0.05f; i < 1.0f; i += 0.1f)
137 const float expandedRadius = (
float)
radius + radiusInset;
141 auto r = area.
expanded (expandedRadius);
145 drawShadowSection (g, cg, top.removeFromLeft (expandedRadius),
true, 1.0f, 1.0f, 0, 1.0f);
146 drawShadowSection (g, cg, top.removeFromRight (expandedRadius),
true, 0, 1.0f, 1.0f, 1.0f);
147 drawShadowSection (g, cg, top,
false, 0, 1.0f, 0, 0);
149 drawShadowSection (g, cg, bottom.removeFromLeft (expandedRadius),
true, 1.0f, 0, 0, 0);
150 drawShadowSection (g, cg, bottom.removeFromRight (expandedRadius),
true, 0, 0, 1.0f, 0);
151 drawShadowSection (g, cg, bottom,
false, 0, 0, 0, 1.0f);
153 drawShadowSection (g, cg, r.removeFromLeft (expandedRadius),
false, 1.0f, 0, 0, 0);
154 drawShadowSection (g, cg, r.removeFromRight (expandedRadius),
false, 0, 0, 1.0f, 0);
Describes the layout and colours that should be used to paint a colour gradient.
bool isRadial
If true, the gradient should be filled circularly, centred around point1, with point2 defining a poin...
int addColour(double proportionAlongGradient, Colour colour)
Adds a colour at a point along the length of the gradient.
Represents a colour, also including a transparency value.
Colour withAlpha(uint8 newAlpha) const noexcept
Returns a colour that's the same colour as this one, but with a new alpha value.
Colour withMultipliedAlpha(float alphaMultiplier) const noexcept
Returns a colour that's the same colour as this one, but with a modified alpha value.
DropShadowEffect()
Creates a default drop-shadow effect.
void setShadowProperties(const DropShadow &newShadow)
Sets up parameters affecting the shadow's appearance.
void applyEffect(Image &sourceImage, Graphics &destContext, float scaleFactor, float alpha) override
Overridden to render the effect.
~DropShadowEffect() override
Destructor.
A graphics context, used for drawing a component or image.
void setOpacity(float newOpacity)
Changes the opacity to use with the current colour.
void drawImageAt(const Image &imageToDraw, int topLeftX, int topLeftY, bool fillAlphaChannelWithCurrentBrush=false) const
Draws an image.
void setGradientFill(const ColourGradient &gradient)
Sets the context to use a gradient for its fill pattern.
void fillRect(Rectangle< int > rectangle) const
Fills a rectangle with the current colour or brush.
void fillPath(const Path &path) const
Fills a path using the currently selected colour or brush.
Rectangle< int > getClipBounds() const
Returns the position of the bounding box for the current clipping region.
void setColour(Colour newColour)
Changes the current drawing colour.
Holds a fixed-size bitmap.
Image convertedToFormat(PixelFormat newFormat) const
Returns a version of this image with a different image format.
void duplicateIfShared()
Makes sure that no other Image objects share the same underlying data as this one.
bool isValid() const noexcept
Returns true if this image isn't null.
@ SingleChannel
< each pixel is a 1-byte alpha channel value.
A path is a sequence of lines and curves that may either form a closed shape or be open-ended.
Rectangle< float > getBounds() const noexcept
Returns the smallest rectangle that contains all points within the path.
A pair of (x, y) coordinates.
constexpr Point< float > toFloat() const noexcept
Casts this point to a Point<float> object.
ValueType y
The point's Y coordinate.
ValueType x
The point's X coordinate.
Manages a rectangle and allows geometric operations to be performed on it.
Rectangle< float > toFloat() const noexcept
Casts this rectangle to a Rectangle<float>.
Rectangle< int > getSmallestIntegerContainer() const noexcept
Returns the smallest integer-aligned rectangle that completely contains this one.
Rectangle removeFromBottom(ValueType amountToRemove) noexcept
Removes a strip from the bottom of this rectangle, reducing this rectangle by the specified amount an...
Rectangle removeFromTop(ValueType amountToRemove) noexcept
Removes a strip from the top of this rectangle, reducing this rectangle by the specified amount and r...
Rectangle reduced(ValueType deltaX, ValueType deltaY) const noexcept
Returns a rectangle that is smaller than this one by a given amount.
Point< ValueType > getRelativePoint(FloatType relativeX, FloatType relativeY) const noexcept
Returns a point within this rectangle, specified as proportional coordinates.
Rectangle expanded(ValueType deltaX, ValueType deltaY) const noexcept
Returns a rectangle that is larger than this one by a given amount.
unsigned int uint32
A platform-independent 32-bit unsigned integer type.
unsigned char uint8
A platform-independent 8-bit unsigned integer type.
int roundToInt(const FloatType value) noexcept
Fast floating-point-to-integer conversion.
Defines a drop-shadow effect.
Point< int > offset
The offset of the shadow.
void drawForPath(Graphics &g, const Path &path) const
Renders a drop-shadow based on the shape of a path.
void drawForImage(Graphics &g, const Image &srcImage) const
Renders a drop-shadow based on the alpha-channel of the given image.
int radius
The approximate spread of the shadow.
void drawForRectangle(Graphics &g, const Rectangle< int > &area) const
Renders a drop-shadow for a rectangle.
DropShadow()=default
Creates a default drop-shadow effect.
Colour colour
The colour with which to render the shadow.