Class Effects

java.lang.Object
com.codename1.art.effects.Effects

public final class Effects extends Object

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

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • dropShadow

      public static Effect dropShadow(int color, float dx, float dy, float radius, float spread)

      A drop shadow.

      Parameters
      • color: shadow color
      • dx: horizontal offset
      • dy: vertical offset
      • radius: blur radius
      • spread: 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: shadow color
      • dx: horizontal offset
      • dy: vertical offset
      • radius: blur radius
      • spread: 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: glow color
      • radius: blur radius
      • spread: 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: glow color
      • radius: blur radius
      • center: 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: 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: blur radius
    • motionBlur

      public static Effect motionBlur(float angle, float distance)

      A blur along one direction.

      Parameters
      • angle: direction in degrees
      • distance: 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: 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 width
      • cy: 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: stroke color
      • width: stroke width
      • position: "outside", "inside" or "center"
    • colorOverlay

      public static Effect colorOverlay(int color)

      A solid color over the layer.

      Parameters
      • color: the color
    • gradientOverlay

      public static Effect gradientOverlay(float[] positions, int[] colors, float angle, String style)

      A gradient over the layer.

      Parameters
      • positions: stop offsets 0 to 1
      • colors: stop colors
      • angle: direction in degrees
      • style: "linear", "radial", "angle", "reflected" or "diamond"
    • patternOverlay

      public static Effect patternOverlay(Raster pattern, float scale)

      A tiled pattern over the layer.

      Parameters
      • pattern: the tile
      • scale: tile scale
    • bevel

      public static Effect bevel(String style, float size, float depth, float angle, float altitude)

      Bevel and emboss.

      Parameters
      • style: "inner", "outer", "emboss" or "pillow"
      • size: bevel size
      • depth: strength, 1 is Photoshop's 100%
      • angle: light angle in degrees
      • altitude: light altitude in degrees
    • satin

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

      Satin shading.

      Parameters
      • color: shading color
      • angle: direction in degrees
      • distance: offset of the two copies
      • size: 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: 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 1
      • inWhite: input white point, 0 to 1
      • gamma: midtone gamma, 1 for none
      • outBlack: output black point
      • outWhite: 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: the curve for all channels; may be null
      • red: red curve; may be null
      • green: green curve; may be null
      • blue: blue curve; may be null
    • hueSaturation

      public static Effect hueSaturation(float hue, float saturation, float lightness)

      Hue, saturation and lightness.

      Parameters
      • hue: hue rotation in degrees
      • saturation: -1 (gray) to 1
      • lightness: -1 (black) to 1 (white)
    • brightnessContrast

      public static Effect brightnessContrast(float brightness, float contrast)

      Brightness and contrast.

      Parameters
      • brightness: -1 to 1
      • contrast: -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: 0 to 1
    • gradientMap

      public static Effect gradientMap(float[] positions, int[] colors)

      Luminance mapped through a gradient.

      Parameters
      • positions: stop offsets
      • colors: stop colors
    • channelMixer

      public static Effect channelMixer(float[] m)

      A channel mixer: three rows of r, g, b, constant.

      Parameters
      • m: twelve coefficients
    • photoFilter

      public static Effect photoFilter(int color, float density)

      A photo filter.

      Parameters
      • color: the filter color
      • density: 0 to 1
    • posterize

      public static Effect posterize(int levels)

      Posterize.

      Parameters
      • levels: tones per channel, at least 2
    • exposure

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

      Exposure.

      Parameters
      • exposure: stops
      • offset: added after exposure
      • gamma: gamma correction, 1 for none
    • vibrance

      public static Effect vibrance(float amount)

      Vibrance.

      Parameters
      • amount: -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: the shift in the shadows
      • midtones: the shift in the midtones
      • highlights: the shift in the highlights
      • preserveLuminosity: 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: 36 adjustments
      • absolute: 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: the kind