Class Effect

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

public final class Effect extends Object

An effect: a kind and its parameters.

Parameters are numbers (Float), colors (Integer, 0xAARRGGBB), number arrays (float[]), color arrays (int[]), strings, BlendModes, Rasters and, for SVG filters, lists of primitives (each a Map). Every kind is described in Effects.

  • Field Details

  • Constructor Details

    • Effect

      public Effect(String kind)

      Creates an effect with no parameters set; every parameter then has its default.

      Parameters
      • kind: one of the kind constants
  • Method Details

    • getKind

      public String getKind()
      The kind.
    • isEnabled

      public boolean isEnabled()
      False keeps the effect but does not apply it.
    • setEnabled

      public void setEnabled(boolean enabled)

      Turns the effect on or off.

      Parameters
      • enabled: true to apply it
    • getParameters

      public Map<String,Object> getParameters()
      The parameters that have been set. The map is live.
    • set

      public Effect set(String name, Object value)

      Sets a parameter and returns this effect.

      Parameters
      • name: the parameter
      • value: its value
    • set

      public Effect set(String name, float value)

      Sets a number parameter and returns this effect.

      Parameters
      • name: the parameter
      • value: its value
    • setColor

      public Effect setColor(String name, int argb)

      Sets a color parameter and returns this effect.

      Parameters
      • name: the parameter
      • argb: the color
    • getFloat

      public float getFloat(String name, float def)

      A number parameter.

      Parameters
      • name: the parameter
      • def: the value when it is not set
    • getColor

      public int getColor(String name, int def)

      A color parameter.

      Parameters
      • name: the parameter
      • def: the value when it is not set
    • getString

      public String getString(String name, String def)

      A string parameter.

      Parameters
      • name: the parameter
      • def: the value when it is not set
    • getFloats

      public float[] getFloats(String name, float[] def)

      A number array parameter.

      Parameters
      • name: the parameter
      • def: the value when it is not set
    • getColors

      public int[] getColors(String name, int[] def)

      A color array parameter.

      Parameters
      • name: the parameter
      • def: the value when it is not set
    • getBlend

      public BlendMode getBlend(BlendMode def)

      The blend mode parameter blend.

      Parameters
      • def: the value when it is not set
    • getRaster

      public Raster getRaster(String name)

      A raster parameter, or null.

      Parameters
      • name: the parameter
    • getPrimitives

      public List<Map<String,Object>> getPrimitives()
      The SVG filter primitives, or an empty list.
    • copy

      public Effect copy()
      A deep copy.
    • apply

      public Raster apply(Raster layer, EffectContext ctx)

      Applies the effect.

      Parameters
      • layer: the layer's pixels in device space
      • ctx: the scale and backdrop
      Returns

      the new pixels, possibly a larger raster; layer is not changed

    • padding

      public int padding(double scale)

      How far, in device pixels, the effect can paint outside the layer's content.

      Parameters
      • scale: device pixels per unit