Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public final class Effects
- Object
- Effects
Factories for every effect kind, and the code that applies them.
Lengths (offsets, radii, widths) are in the units of the node the effect is on; they are
scaled to device pixels when the effect is applied. A blur radius is twice the Gaussian
standard deviation, as Sketch, Figma and CSS use it. Angles are in degrees,
counter-clockwise from 3 o’clock, as Photoshop measures light. Every effect also takes
opacity (0 to 1) and most take blend.
Methods
Inherited methods
Method details
dropShadow
public static Effect dropShadow(int color, float dx, float dy, float radius, float spread)A drop shadow.
Parameters
colorint- shadow color
dxfloat- horizontal offset
dyfloat- vertical offset
radiusfloat- blur radius
spreadfloat- how far the shadow grows before it is blurred
innerShadow
public static Effect innerShadow(int color, float dx, float dy, float radius, float spread)An inner shadow.
Parameters
colorint- shadow color
dxfloat- horizontal offset
dyfloat- vertical offset
radiusfloat- blur radius
spreadfloat- choke, how far the shadow grows inward before it is blurred
outerGlow
public static Effect outerGlow(int color, float radius, float spread)An outer glow.
Parameters
colorint- glow color
radiusfloat- blur radius
spreadfloat- how far the glow grows before it is blurred
innerGlow
public static Effect innerGlow(int color, float radius, boolean center)An inner glow.
Parameters
colorint- glow color
radiusfloat- blur radius
centerboolean- true to glow from the center instead of the edges
gaussianBlur
public static Effect gaussianBlur(float radius)A Gaussian blur of the layer.
Parameters
radiusfloat- blur radius
backgroundBlur
public static Effect backgroundBlur(float radius)A blur of what is behind the layer, seen through the layer’s shape (frosted glass).
Parameters
radiusfloat- blur radius
motionBlur
public static Effect motionBlur(float angle, float distance)A blur along one direction.
Parameters
anglefloat- direction in degrees
distancefloat- length of the blur
zoomBlur
public static Effect zoomBlur(float amount, float cx, float cy)A zoom blur: every pixel is smeared along the line toward a center point.
Parameters
amountfloat- how far toward the center the smear reaches, 0 (none) to 1 (all the way)
cxfloat- the center’s x, as a fraction of the layer’s width
cyfloat- the center’s y, as a fraction of the layer’s height
stroke
public static Effect stroke(int color, float width, String position)An outline around the layer’s opaque pixels.
Parameters
colorint- stroke color
widthfloat- stroke width
positionString- “outside”, “inside” or “center”
colorOverlay
public static Effect colorOverlay(int color)A solid color over the layer.
Parameters
colorint- the color
gradientOverlay
public static Effect gradientOverlay(float[] positions, int[] colors, float angle, String style)A gradient over the layer.
Parameters
positionsfloat[]- stop offsets 0 to 1
colorsint[]- stop colors
anglefloat- direction in degrees
styleString- “linear”, “radial”, “angle”, “reflected” or “diamond”
patternOverlay
public static Effect patternOverlay(Raster pattern, float scale)A tiled pattern over the layer.
Parameters
patternRaster- the tile
scalefloat- tile scale
bevel
public static Effect bevel(String style, float size, float depth, float angle, float altitude)Bevel and emboss.
Parameters
styleString- “inner”, “outer”, “emboss” or “pillow”
sizefloat- bevel size
depthfloat- strength, 1 is Photoshop’s 100%
anglefloat- light angle in degrees
altitudefloat- light altitude in degrees
satin
public static Effect satin(int color, float angle, float distance, float size)Satin shading.
Parameters
colorint- shading color
anglefloat- direction in degrees
distancefloat- offset of the two copies
sizefloat- blur radius
colorMatrix
public static Effect colorMatrix(float[] m)A color matrix in SVG’s layout: four rows of five, applied to non-premultiplied
r, g, b, a, 1 with values 0 to 1.Parameters
mfloat[]- twenty coefficients
levels
public static Effect levels(float inBlack, float inWhite, float gamma, float outBlack, float outWhite)Levels.
Parameters
inBlackfloat- input black point, 0 to 1
inWhitefloat- input white point, 0 to 1
gammafloat- midtone gamma, 1 for none
outBlackfloat- output black point
outWhitefloat- output white point
curves
public static Effect curves(float[] master, float[] red, float[] green, float[] blue)Tone curves through control points, each
x, y pairs from 0 to 1.Parameters
masterfloat[]- the curve for all channels; may be null
redfloat[]- red curve; may be null
greenfloat[]- green curve; may be null
bluefloat[]- blue curve; may be null
hueSaturation
public static Effect hueSaturation(float hue, float saturation, float lightness)Hue, saturation and lightness.
Parameters
huefloat- hue rotation in degrees
saturationfloat- -1 (gray) to 1
lightnessfloat- -1 (black) to 1 (white)
brightnessContrast
public static Effect brightnessContrast(float brightness, float contrast)Brightness and contrast.
Parameters
brightnessfloat- -1 to 1
contrastfloat- -1 to 1
invert
public static Effect invert()Inverted colors.
threshold
public static Effect threshold(float level)Black where luminance is below
level, white elsewhere.Parameters
levelfloat- 0 to 1
gradientMap
public static Effect gradientMap(float[] positions, int[] colors)Luminance mapped through a gradient.
Parameters
positionsfloat[]- stop offsets
colorsint[]- stop colors
channelMixer
public static Effect channelMixer(float[] m)A channel mixer: three rows of
r, g, b, constant.Parameters
mfloat[]- twelve coefficients
photoFilter
public static Effect photoFilter(int color, float density)A photo filter.
Parameters
colorint- the filter color
densityfloat- 0 to 1
posterize
public static Effect posterize(int levels)Posterize.
Parameters
levelsint- tones per channel, at least 2
exposure
public static Effect exposure(float exposure, float offset, float gamma)Exposure.
Parameters
exposurefloat- stops
offsetfloat- added after exposure
gammafloat- gamma correction, 1 for none
vibrance
public static Effect vibrance(float amount)Vibrance.
Parameters
amountfloat- -1 to 1
blackAndWhite
public static Effect blackAndWhite()Black and white with Photoshop’s default hue weights.
colorBalance
public static Effect colorBalance(float[] shadows, float[] midtones, float[] highlights, boolean preserveLuminosity)Color balance. Each range is three numbers from -1 to 1: cyan to red, magenta to
green and yellow to blue.
Parameters
shadowsfloat[]- the shift in the shadows
midtonesfloat[]- the shift in the midtones
highlightsfloat[]- the shift in the highlights
preserveLuminosityboolean- keep each pixel’s luminosity
selectiveColor
public static Effect selectiveColor(float[] ranges, boolean absolute)Selective color. ranges holds four numbers (cyan, magenta, yellow and black, -1 to
- for each of reds, yellows, greens, cyans, blues, magentas, whites, neutrals and blacks, in that order.
Parameters
rangesfloat[]- 36 adjustments
absoluteboolean- true to add ink, false to change it in proportion to the ink present
svgFilter
public static Effect svgFilter()An empty SVG filter graph; add primitives to
getPrimitives.isAdjustment
public static boolean isAdjustment(String kind)True for the kinds that only change colors pixel by pixel, which an
AdjustmentNode can hold.Parameters
kindString- the kind