Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public final class Effects

  1. Object
  2. 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

public static Effect dropShadow(int color, float dx, float dy, float radius, float spread)A drop shadow.
public static Effect innerShadow(int color, float dx, float dy, float radius, float spread)An inner shadow.
public static Effect outerGlow(int color, float radius, float spread)An outer glow.
public static Effect innerGlow(int color, float radius, boolean center)An inner glow.
public static Effect gaussianBlur(float radius)A Gaussian blur of the layer.
public static Effect backgroundBlur(float radius)A blur of what is behind the layer, seen through the layer’s shape (frosted glass).
public static Effect motionBlur(float angle, float distance)A blur along one direction.
public static Effect zoomBlur(float amount, float cx, float cy)A zoom blur: every pixel is smeared along the line toward a center point.
public static Effect stroke(int color, float width, String position)An outline around the layer’s opaque pixels.
public static Effect colorOverlay(int color)A solid color over the layer.
public static Effect gradientOverlay(float[] positions, int[] colors, float angle, String style)A gradient over the layer.
public static Effect patternOverlay(Raster pattern, float scale)A tiled pattern over the layer.
public static Effect bevel(String style, float size, float depth, float angle, float altitude)Bevel and emboss.
public static Effect satin(int color, float angle, float distance, float size)Satin shading.
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.
public static Effect levels(float inBlack, float inWhite, float gamma, float outBlack, float outWhite)Levels.
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.
public static Effect hueSaturation(float hue, float saturation, float lightness)Hue, saturation and lightness.
public static Effect brightnessContrast(float brightness, float contrast)Brightness and contrast.
public static Effect invert()Inverted colors.
public static Effect threshold(float level)Black where luminance is below level, white elsewhere.
public static Effect gradientMap(float[] positions, int[] colors)Luminance mapped through a gradient.
public static Effect channelMixer(float[] m)A channel mixer: three rows of r, g, b, constant.
public static Effect photoFilter(int color, float density)A photo filter.
public static Effect posterize(int levels)Posterize.
public static Effect exposure(float exposure, float offset, float gamma)Exposure.
public static Effect vibrance(float amount)Vibrance.
public static Effect blackAndWhite()Black and white with Photoshop’s default hue weights.
public static Effect colorBalance(float[] shadows, float[] midtones, float[] highlights, boolean preserveLuminosity)Color balance.
public static Effect selectiveColor(float[] ranges, boolean absolute)Selective color.
public static Effect svgFilter()An empty SVG filter graph; add primitives to getPrimitives.
public static boolean isAdjustment(String kind)True for the kinds that only change colors pixel by pixel, which an AdjustmentNode can hold.

Inherited methods

Method details

dropShadow

public static Effect dropShadow(int color, float dx, float dy, float radius, float spread)
A drop shadow.

Parameters

color int
shadow color
dx float
horizontal offset
dy float
vertical offset
radius float
blur radius
spread float
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

color int
shadow color
dx float
horizontal offset
dy float
vertical offset
radius float
blur radius
spread float
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

color int
glow color
radius float
blur radius
spread float
how far the glow grows before it is blurred

innerGlow

public static Effect innerGlow(int color, float radius, boolean center)
An inner glow.

Parameters

color int
glow color
radius float
blur radius
center boolean
true to glow from the center instead of the edges

gaussianBlur

public static Effect gaussianBlur(float radius)
A Gaussian blur of the layer.

Parameters

radius float
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

radius float
blur radius

motionBlur

public static Effect motionBlur(float angle, float distance)
A blur along one direction.

Parameters

angle float
direction in degrees
distance float
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

amount float
how far toward the center the smear reaches, 0 (none) to 1 (all the way)
cx float
the center’s x, as a fraction of the layer’s width
cy float
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

color int
stroke color
width float
stroke width
position String
“outside”, “inside” or “center”

colorOverlay

public static Effect colorOverlay(int color)
A solid color over the layer.

Parameters

color int
the color

gradientOverlay

public static Effect gradientOverlay(float[] positions, int[] colors, float angle, String style)
A gradient over the layer.

Parameters

positions float[]
stop offsets 0 to 1
colors int[]
stop colors
angle float
direction in degrees
style String
“linear”, “radial”, “angle”, “reflected” or “diamond”

patternOverlay

public static Effect patternOverlay(Raster pattern, float scale)
A tiled pattern over the layer.

Parameters

pattern Raster
the tile
scale float
tile scale

bevel

public static Effect bevel(String style, float size, float depth, float angle, float altitude)
Bevel and emboss.

Parameters

style String
“inner”, “outer”, “emboss” or “pillow”
size float
bevel size
depth float
strength, 1 is Photoshop’s 100%
angle float
light angle in degrees
altitude float
light altitude in degrees

satin

public static Effect satin(int color, float angle, float distance, float size)
Satin shading.

Parameters

color int
shading color
angle float
direction in degrees
distance float
offset of the two copies
size float
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

m float[]
twenty coefficients

levels

public static Effect levels(float inBlack, float inWhite, float gamma, float outBlack, float outWhite)
Levels.

Parameters

inBlack float
input black point, 0 to 1
inWhite float
input white point, 0 to 1
gamma float
midtone gamma, 1 for none
outBlack float
output black point
outWhite float
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

master float[]
the curve for all channels; may be null
red float[]
red curve; may be null
green float[]
green curve; may be null
blue float[]
blue curve; may be null

hueSaturation

public static Effect hueSaturation(float hue, float saturation, float lightness)
Hue, saturation and lightness.

Parameters

hue float
hue rotation in degrees
saturation float
-1 (gray) to 1
lightness float
-1 (black) to 1 (white)

brightnessContrast

public static Effect brightnessContrast(float brightness, float contrast)
Brightness and contrast.

Parameters

brightness float
-1 to 1
contrast float
-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

level float
0 to 1

gradientMap

public static Effect gradientMap(float[] positions, int[] colors)
Luminance mapped through a gradient.

Parameters

positions float[]
stop offsets
colors int[]
stop colors

channelMixer

public static Effect channelMixer(float[] m)
A channel mixer: three rows of r, g, b, constant.

Parameters

m float[]
twelve coefficients

photoFilter

public static Effect photoFilter(int color, float density)
A photo filter.

Parameters

color int
the filter color
density float
0 to 1

posterize

public static Effect posterize(int levels)
Posterize.

Parameters

levels int
tones per channel, at least 2

exposure

public static Effect exposure(float exposure, float offset, float gamma)
Exposure.

Parameters

exposure float
stops
offset float
added after exposure
gamma float
gamma correction, 1 for none

vibrance

public static Effect vibrance(float amount)
Vibrance.

Parameters

amount float
-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

shadows float[]
the shift in the shadows
midtones float[]
the shift in the midtones
highlights float[]
the shift in the highlights
preserveLuminosity boolean
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

  1. for each of reds, yellows, greens, cyans, blues, magentas, whites, neutrals and blacks, in that order.

Parameters

ranges float[]
36 adjustments
absolute boolean
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

kind String
the kind