Class 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.
-
Method Summary
Modifier and TypeMethodDescriptionstatic EffectbackgroundBlur(float radius) A blur of what is behind the layer, seen through the layer's shape (frosted glass).static EffectBevel and emboss.static EffectBlack and white with Photoshop's default hue weights.static EffectbrightnessContrast(float brightness, float contrast) Brightness and contrast.static EffectchannelMixer(float[] m) A channel mixer: three rows ofr, g, b, constant.static EffectcolorBalance(float[] shadows, float[] midtones, float[] highlights, boolean preserveLuminosity) Color balance.static EffectcolorMatrix(float[] m) A color matrix in SVG's layout: four rows of five, applied to non-premultipliedr, g, b, a, 1with values 0 to 1.static EffectcolorOverlay(int color) A solid color over the layer.static Effectcurves(float[] master, float[] red, float[] green, float[] blue) Tone curves through control points, eachx, ypairs from 0 to 1.static EffectdropShadow(int color, float dx, float dy, float radius, float spread) A drop shadow.static Effectexposure(float exposure, float offset, float gamma) Exposure.static EffectgaussianBlur(float radius) A Gaussian blur of the layer.static EffectgradientMap(float[] positions, int[] colors) Luminance mapped through a gradient.static EffectgradientOverlay(float[] positions, int[] colors, float angle, String style) A gradient over the layer.static EffecthueSaturation(float hue, float saturation, float lightness) Hue, saturation and lightness.static EffectinnerGlow(int color, float radius, boolean center) An inner glow.static EffectinnerShadow(int color, float dx, float dy, float radius, float spread) An inner shadow.static Effectinvert()Inverted colors.static booleanisAdjustment(String kind) True for the kinds that only change colors pixel by pixel, which anAdjustmentNodecan hold.static Effectlevels(float inBlack, float inWhite, float gamma, float outBlack, float outWhite) Levels.static EffectmotionBlur(float angle, float distance) A blur along one direction.static EffectouterGlow(int color, float radius, float spread) An outer glow.static EffectpatternOverlay(Raster pattern, float scale) A tiled pattern over the layer.static EffectphotoFilter(int color, float density) A photo filter.static Effectposterize(int levels) Posterize.static Effectsatin(int color, float angle, float distance, float size) Satin shading.static EffectselectiveColor(float[] ranges, boolean absolute) Selective color.static EffectAn outline around the layer's opaque pixels.static EffectAn empty SVG filter graph; add primitives togetPrimitives.static Effectthreshold(float level) Black where luminance is belowlevel, white elsewhere.static Effectvibrance(float amount) Vibrance.static EffectzoomBlur(float amount, float cx, float cy) A zoom blur: every pixel is smeared along the line toward a center point.
-
Method Details
-
dropShadow
A drop shadow.
Parameters
color: shadow colordx: horizontal offsetdy: vertical offsetradius: blur radiusspread: how far the shadow grows before it is blurred
-
innerShadow
An inner shadow.
Parameters
color: shadow colordx: horizontal offsetdy: vertical offsetradius: blur radiusspread: choke, how far the shadow grows inward before it is blurred
-
outerGlow
An outer glow.
Parameters
color: glow colorradius: blur radiusspread: how far the glow grows before it is blurred
-
innerGlow
An inner glow.
Parameters
color: glow colorradius: blur radiuscenter: true to glow from the center instead of the edges
-
gaussianBlur
A Gaussian blur of the layer.
Parameters
radius: blur radius
-
backgroundBlur
A blur of what is behind the layer, seen through the layer's shape (frosted glass).
Parameters
radius: blur radius
-
motionBlur
A blur along one direction.
Parameters
angle: direction in degreesdistance: length of the blur
-
zoomBlur
A zoom blur: every pixel is smeared along the line toward a center point.
Parameters
amount: how far toward the center the smear reaches, 0 (none) to 1 (all the way)cx: the center's x, as a fraction of the layer's widthcy: the center's y, as a fraction of the layer's height
-
stroke
-
colorOverlay
A solid color over the layer.
Parameters
color: the color
-
gradientOverlay
-
patternOverlay
-
bevel
-
satin
Satin shading.
Parameters
color: shading colorangle: direction in degreesdistance: offset of the two copiessize: blur radius
-
colorMatrix
A color matrix in SVG's layout: four rows of five, applied to non-premultiplied
r, g, b, a, 1with values 0 to 1.Parameters
m: twenty coefficients
-
levels
public static Effect levels(float inBlack, float inWhite, float gamma, float outBlack, float outWhite) Levels.
Parameters
inBlack: input black point, 0 to 1inWhite: input white point, 0 to 1gamma: midtone gamma, 1 for noneoutBlack: output black pointoutWhite: output white point
-
curves
Tone curves through control points, each
x, ypairs from 0 to 1.Parameters
master: the curve for all channels; may be nullred: red curve; may be nullgreen: green curve; may be nullblue: blue curve; may be null
-
hueSaturation
Hue, saturation and lightness.
Parameters
hue: hue rotation in degreessaturation: -1 (gray) to 1lightness: -1 (black) to 1 (white)
-
brightnessContrast
Brightness and contrast.
Parameters
brightness: -1 to 1contrast: -1 to 1
-
invert
Inverted colors. -
threshold
Black where luminance is below
level, white elsewhere.Parameters
level: 0 to 1
-
gradientMap
Luminance mapped through a gradient.
Parameters
positions: stop offsetscolors: stop colors
-
channelMixer
A channel mixer: three rows of
r, g, b, constant.Parameters
m: twelve coefficients
-
photoFilter
A photo filter.
Parameters
color: the filter colordensity: 0 to 1
-
posterize
Posterize.
Parameters
levels: tones per channel, at least 2
-
exposure
Exposure.
Parameters
exposure: stopsoffset: added after exposuregamma: gamma correction, 1 for none
-
vibrance
Vibrance.
Parameters
amount: -1 to 1
-
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: the shift in the shadowsmidtones: the shift in the midtoneshighlights: the shift in the highlightspreserveLuminosity: keep each pixel's luminosity
-
selectiveColor
Selective color.
rangesholds 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
ranges: 36 adjustmentsabsolute: true to add ink, false to change it in proportion to the ink present
-
svgFilter
An empty SVG filter graph; add primitives togetPrimitives. -
isAdjustment
True for the kinds that only change colors pixel by pixel, which an
AdjustmentNodecan hold.Parameters
kind: the kind
-