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.BufferedImagefilter(java.awt.image.BufferedImage src, java.awt.image.BufferedImage dest)intgetBlurRadius()Returns the radius of the blurring applied to the glow effect.java.awt.ColorgetColor()Returns the current glow colour as an ARGB integer value.intgetColorRGB()Returns the current glow colour as an ARGB integer value.intgetDistance()Deprecated.Replaced bygetBlurRadius().intgetIterations()Returns the number of blurring iterations that will be applied to the glow effect.intgetStrength()Returns the strength of the glow effect.intgetWidth()Returns the glow size, exclusive of blurring.booleanisOuterGlow()Returnstrueif the filter will produce an outer glow, orfalseif the filter will produce an inner glow.booleanisSourceImagePainted()Returnstrueif the original source image appears in the destination.voidsetBlurRadius(int radius)Sets the blurring radius of the glow effect.voidsetColor(java.awt.Color color)Sets the current glow colour using aColorinstance.voidsetColorRGB(int color)Sets the current glow colour using an ARGB integer.voidsetDistance(int blurRadius)Deprecated.Replaced bysetBlurRadius(int).voidsetIterations(int iterations)Sets the number of blurring iterations that will be applied to the glow effect.voidsetOuterGlow(boolean outerGlow)Sets the type of glow effect to grow inward from the edge, outward from the edge, or both.voidsetSourceImagePainted(boolean paintSource)Sets whether the original image will be included in the output.voidsetStrength(int strength)Sets the strength of the glow effect.voidsetWidth(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 aColorinstance.- 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()
Returnstrueif the filter will produce an outer glow, orfalseif the filter will produce an inner glow.- Returns:
truefor an outer glow type;falsefor 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-truefor an outer glow type;falsefor 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-trueto include the image the effect applies to,falseto produce the glow effect only
-
isSourceImagePainted
public boolean isSourceImagePainted()
Returnstrueif the original source image appears in the destination.- Returns:
trueto include the image the effect applies to,falseto produce the glow effect only
-
filter
public java.awt.image.BufferedImage filter(java.awt.image.BufferedImage src, java.awt.image.BufferedImage dest)
-
-