29static void blurDataTriplets (
uint8* d,
int num,
const int delta)
noexcept
32 d[0] = (
uint8) ((d[0] + d[delta] + 1) / 3);
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)
56 blurDataTriplets (data + lineStride * y, width, 1);
58 for (
int x = 0; x < width; ++x)
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);
100 if (area.getWidth() > 2 && area.getHeight() > 2)
106 g2.setColour (Colours::white);
108 (
float) (
offset.
y - area.getY())));
133 for (
float i = 0.05f; i < 1.0f; i += 0.1f)
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.
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.
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.
@ 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.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
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.