Package ca.cgjennings.graphics.filters
Class GlowFilter
- java.lang.Object
-
- ca.cgjennings.graphics.filters.AbstractImageFilter
-
- ca.cgjennings.graphics.filters.GlowFilter
-
- All Implemented Interfaces:
java.awt.image.BufferedImageOp
public final class GlowFilter extends AbstractImageFilter
A filter that applies a glow effect around the edge defined by the non-transparent parts of an image.If either the number of blurring iterations or the effect strength is zero, the glow effect will not be visible.
- Since:
- 3.0
- Author:
- Chris Jennings
-
-
Constructor Summary
Constructors Constructor Description GlowFilter()
Creates a new glow filter with a yellow-white glow, width of 2, blur radius of 4, 1 iteration, strength of 2, and an outer glow.GlowFilter(int color, int blurRadius, boolean outerGlow, int strength)
Creates a new glow filter.GlowFilter(int color, int strokeWidth, int blurRadius, int iterations, boolean outerGlow, int strength)
Creates a new glow filter.GlowFilter(java.awt.Color color, int blurRadius, boolean outerGlow, int strength)
Creates a new glow filter.GlowFilter(java.awt.Color color, int strokeWidth, int blurRadius, int iterations, boolean outerGlow, int strength)
Creates a new glow filter.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.awt.image.BufferedImage
filter(java.awt.image.BufferedImage src, java.awt.image.BufferedImage dest)
int
getBlurRadius()
Returns the radius of the blurring applied to the glow effect.java.awt.Color
getColor()
Returns the current glow colour as an ARGB integer value.int
getColorRGB()
Returns the current glow colour as an ARGB integer value.int
getDistance()
Deprecated.Replaced bygetBlurRadius()
.int
getIterations()
Returns the number of blurring iterations that will be applied to the glow effect.int
getStrength()
Returns the strength of the glow effect.int
getWidth()
Returns the glow size, exclusive of blurring.boolean
isOuterGlow()
Returnstrue
if the filter will produce an outer glow, orfalse
if the filter will produce an inner glow.boolean
isSourceImagePainted()
Returnstrue
if the original source image appears in the destination.void
setBlurRadius(int radius)
Sets the blurring radius of the glow effect.void
setColor(java.awt.Color color)
Sets the current glow colour using aColor
instance.void
setColorRGB(int color)
Sets the current glow colour using an ARGB integer.void
setDistance(int blurRadius)
Deprecated.Replaced bysetBlurRadius(int)
.void
setIterations(int iterations)
Sets the number of blurring iterations that will be applied to the glow effect.void
setOuterGlow(boolean outerGlow)
Sets the type of glow effect to grow inward from the edge, outward from the edge, or both.void
setSourceImagePainted(boolean paintSource)
Sets whether the original image will be included in the output.void
setStrength(int strength)
Sets the strength of the glow effect.void
setWidth(int size)
The size of glow, exclusive of blurring.-
Methods inherited from class ca.cgjennings.graphics.filters.AbstractImageFilter
clamp, clamp, clamp, clampBoth, createCompatibleDestImage, fA, fB, fG, fR, getARGB, getARGB, getARGBSynch, getBounds2D, getPoint2D, getRenderingHints, iA, iB, iG, iR, setARGB, setARGB, setARGBSynch
-
-
-
-
Constructor Detail
-
GlowFilter
public GlowFilter()
Creates a new glow filter with a yellow-white glow, width of 2, blur radius of 4, 1 iteration, strength of 2, and an outer glow.
-
GlowFilter
public GlowFilter(int color, int blurRadius, boolean outerGlow, int strength)
Creates a new glow filter.- Parameters:
color
- the color, specified as an sRGB integerblurRadius
- the blur radius for the glowouterGlow
- iftrue
, the filter produces an outer glowstrength
- the strength of the glow effect
-
GlowFilter
public GlowFilter(java.awt.Color color, int blurRadius, boolean outerGlow, int strength)
Creates a new glow filter.- Parameters:
color
- the color, specified as an sRGB integerblurRadius
- the blur radius for the glowouterGlow
- iftrue
, the filter produces an outer glowstrength
- the strength of the glow effect
-
GlowFilter
public GlowFilter(int color, int strokeWidth, int blurRadius, int iterations, boolean outerGlow, int strength)
Creates a new glow filter.- Parameters:
color
- the color, specified as an sRGB integerstrokeWidth
- the width of the glow, exclusive of blurringblurRadius
- the blur radius for the glowiterations
- the number of iterations of the blurring effectouterGlow
- iftrue
, the filter produces an outer glowstrength
- the strength of the glow effect
-
GlowFilter
public GlowFilter(java.awt.Color color, int strokeWidth, int blurRadius, int iterations, boolean outerGlow, int strength)
Creates a new glow filter.- Parameters:
color
- the color, specified as an sRGB integerstrokeWidth
- the width of the glow, exclusive of blurringblurRadius
- the blur radius for the glowiterations
- the number of iterations of the blurring effectouterGlow
- iftrue
, the filter produces an outer glowstrength
- the strength of the glow effect
-
-
Method Detail
-
getColorRGB
public int getColorRGB()
Returns the current glow colour as an ARGB integer value.- Returns:
- the glow colour in 0xAARRGGBB format
-
setColorRGB
public void setColorRGB(int color)
Sets the current glow colour using an ARGB integer.- Parameters:
color
- the glow colour in 0xAARRGGBB format
-
getColor
public java.awt.Color getColor()
Returns the current glow colour as an ARGB integer value.- Returns:
- the glow colour
-
setColor
public void setColor(java.awt.Color color)
Sets the current glow colour using aColor
instance.- Parameters:
color
- the glow color
-
setBlurRadius
public void setBlurRadius(int radius)
Sets the blurring radius of the glow effect.- Parameters:
radius
- the blur radius of the glow effect, in pixels
-
getBlurRadius
public int getBlurRadius()
Returns the radius of the blurring applied to the glow effect.- Returns:
- the blur radius of the glow effect, in pixels
-
setDistance
@Deprecated public void setDistance(int blurRadius)
Deprecated.Replaced bysetBlurRadius(int)
.Sets the blurring radius of the glow effect.- Parameters:
blurRadius
- the blur radius of the glow effect, in pixels
-
getDistance
@Deprecated public int getDistance()
Deprecated.Replaced bygetBlurRadius()
.Returns the radius of the blurring applied to the glow effect.- Returns:
- the blur radius of the glow effect, in pixels
-
setWidth
public void setWidth(int size)
The size of glow, exclusive of blurring.- Parameters:
size
- the glow size, in pixels
-
getWidth
public int getWidth()
Returns the glow size, exclusive of blurring.- Returns:
- the glow size, in pixels
-
isOuterGlow
public boolean isOuterGlow()
Returnstrue
if the filter will produce an outer glow, orfalse
if the filter will produce an inner glow.- Returns:
true
for an outer glow type;false
for an inner glow type
-
setOuterGlow
public void setOuterGlow(boolean outerGlow)
Sets the type of glow effect to grow inward from the edge, outward from the edge, or both.- Parameters:
outerGlow
-true
for an outer glow type;false
for an inner glow type
-
getStrength
public int getStrength()
Returns the strength of the glow effect. Higher values produce a more intense glow.- Returns:
- the positive glow effect strength
-
setStrength
public void setStrength(int strength)
Sets the strength of the glow effect. Any non-negative value is valid, but typical values are in the range 1 to 8. Higher values will produce a more intense (less translucent) glow.- Parameters:
strength
- the positive intensity of the glow effect
-
setIterations
public void setIterations(int iterations)
Sets the number of blurring iterations that will be applied to the glow effect. This value may be 0, but cannot be negative. The default is one; higher values will produce a smoother glow effect but will also increase the extent of the glow.
-
getIterations
public int getIterations()
Returns the number of blurring iterations that will be applied to the glow effect. This value may be 0, but cannot be negative.- Returns:
- the number of times the blur effect is applied
-
setSourceImagePainted
public void setSourceImagePainted(boolean paintSource)
Sets whether the original image will be included in the output. Iftrue
, the glow effect will be combined with the original image.- Parameters:
paintSource
-true
to include the image the effect applies to,false
to produce the glow effect only
-
isSourceImagePainted
public boolean isSourceImagePainted()
Returnstrue
if the original source image appears in the destination.- Returns:
true
to include the image the effect applies to,false
to produce the glow effect only
-
filter
public java.awt.image.BufferedImage filter(java.awt.image.BufferedImage src, java.awt.image.BufferedImage dest)
-
-