public class Effects extends Object
Modifier and Type | Method and Description |
---|---|
static Image |
dropshadow(Image source,
int blurRadius,
float opacity)
Generates a shadow for the source image and returns either the shadow itself or the image merged with the
shadow.
|
static Image |
dropshadow(Image source,
int blurRadius,
float opacity,
int xDistance,
int yDistance)
Generates a shadow for the source image and returns a new larger image containing the shadow
|
static Image |
gaussianBlurImage(Image image,
float radius)
Create a blur image from the given image.
|
static void |
growShrink(Component c,
int duration)
Deprecated.
use Component.growShrink instead
|
static boolean |
isGaussianBlurSupported()
Returns true if gaussian blur is supported on this platform
|
static Image |
reflectionImage(Image source)
Takes the given image and appends an effect of reflection below it that
is similar to the way elements appear in water beneath them.
|
static Image |
reflectionImage(Image source,
float mirrorRatio,
int alphaRatio)
Takes the given image and appends an effect of reflection below it that
is similar to the way elements appear in water beneath them.
|
static Image |
reflectionImage(Image source,
float mirrorRatio,
int alphaRatio,
int spacing)
Takes the given image and appends an effect of reflection below it that
is similar to the way elements appear in water beneath them.
|
static Image |
squareShadow(int width,
int height,
int blurRadius,
float opacity)
Generates a square shadow and returns it
|
static Image |
verticalPerspective(Image i,
float topScaleRatio,
float bottomScaleRatio,
float verticalShrink)
Skews an image in a faux perspective transform on the vertical axis, this is effectively a fast scale
algorithm that both shrinks the image vertically and reduces the width
|
public static Image reflectionImage(Image source)
source
- image to add the reflection effect topublic static Image reflectionImage(Image source, float mirrorRatio, int alphaRatio)
source
- image to add the reflection effect tomirrorRatio
- generally less than 1, a mirror ration of 0.5f will create a mirror image half the
height of the image, 0.75f will create a 3 quarter height mirror etc.alphaRatio
- starting point for the alpha value in the mirror, this should be a number between 0 - 255
(recommended larger than 0) indicating the opacity of the closest pixel. For a mirror thats completely
opaque use 255. A recommended value would be between 128 to 90.public static Image reflectionImage(Image source, float mirrorRatio, int alphaRatio, int spacing)
source
- image to add the reflection effect tomirrorRatio
- generally less than 1, a mirror ration of 0.5f will create a mirror image half the
height of the image, 0.75f will create a 3 quarter height mirror etc.alphaRatio
- starting point for the alpha value in the mirror, this should be a number between 0 - 255
(recommended larger than 0) indicating the opacity of the closest pixel. For a mirror thats completely
opaque use 255. A recommended value would be between 128 to 90.spacing
- the distance in pixels between the image and its reflectionpublic static void growShrink(Component c, int duration)
c
- the component to grow/shrink, its size must be different from its preferred sizeduration
- the duration in milliseconds for the grow/shrink animationpublic static Image verticalPerspective(Image i, float topScaleRatio, float bottomScaleRatio, float verticalShrink)
topScaleRatio
- the amount by which the top portion should be scaled where 1.0 means nonebottomScaleRatio
- the amount by which the bottom portion should be scaled where 1.0 means noneverticalShrink
- the scale ratio for the image height where 1.0 means nonepublic static Image gaussianBlurImage(Image image, float radius)
image
- the image to blurradius
- the radius to be used in the algorithmpublic static boolean isGaussianBlurSupported()
public static Image dropshadow(Image source, int blurRadius, float opacity, int xDistance, int yDistance)
source
- the source image for whom the shadow should be generatedblurRadius
- a shadow is blurred using a gaussian blur when available, a value of 10 is often satisfactoryopacity
- the opacity of the shadow between 0 - 1 where 1 is completely opaquexDistance
- the distance on the x axis from the main image body in pixels e.g. a negative value will represent a lightsource from the right (shadow on the left)yDistance
- the distance on the y axis from the main image body in pixels e.g. a negative value will represent a lightsource from the bottom (shadow on top)public static Image dropshadow(Image source, int blurRadius, float opacity)
source
- the source image for whom the shadow should be generatedblurRadius
- a shadow is blurred using a gaussian blur when available, a value of 10 is often satisfactoryopacity
- the opacity of the shadow between 0 - 1 where 1 is completely opaquepublic static Image squareShadow(int width, int height, int blurRadius, float opacity)
width
- the width of the shadow imageheight
- the height of the shadow imageblurRadius
- a shadow is blurred using a gaussian blur when available, a value of 10 is often satisfactoryopacity
- the opacity of the shadow between 0 - 1 where 1 is completely opaque