Package heronarts.lx

Class LXLayeredComponent

All Implemented Interfaces:
LXLoopTask, LXPath, LXSerializable, LXParameterListener
Direct Known Subclasses:
LXDeviceComponent, LXLayer

public abstract class LXLayeredComponent extends LXModelComponent implements LXLoopTask
Base class for system components that run in the engine, which have common attributes, such as parameters, modulators, and layers. For instance, patterns, transitions, and effects are all LXComponents.
  • Field Details

    • colors

      protected int[] colors
    • layers

      public final List<LXLayer> layers
    • palette

      protected final LXPalette palette
  • Constructor Details

    • LXLayeredComponent

      protected LXLayeredComponent(LX lx)
    • LXLayeredComponent

      protected LXLayeredComponent(LX lx, String label)
    • LXLayeredComponent

      protected LXLayeredComponent(LX lx, LXDeviceComponent component)
    • LXLayeredComponent

      protected LXLayeredComponent(LX lx, LXBuffer buffer)
    • LXLayeredComponent

      protected LXLayeredComponent(LX lx, String label, LXBuffer buffer)
  • Method Details

    • getBuffer

      protected LXBuffer getBuffer()
    • getColors

      public int[] getColors()
    • setBuffer

      protected LXLayeredComponent setBuffer(LXDeviceComponent component)
    • setBuffer

      public LXLayeredComponent setBuffer(LXBuffer buffer)
    • loop

      public void loop(double deltaMs)
      Specified by:
      loop in interface LXLoopTask
      Overrides:
      loop in class LXModelComponent
    • onLoop

      protected void onLoop(double deltaMs)
    • afterLayers

      protected void afterLayers(double deltaMs)
    • addLayer

      protected final LXLayer addLayer(LXLayer layer)
    • removeLayer

      protected final LXLayer removeLayer(LXLayer layer)
    • getLayers

      public final List<LXLayer> getLayers()
    • dispose

      public void dispose()
      Description copied from class: LXComponent
      Invoked when a component is being removed from the system and will no longer be used at all. This unregisters the component and should free up any resources and parameter listeners. Ideally after this method is called the object should be eligible for garbage collection. Subclasses are generally expected to override this method to handle their particular cleanup work. They should also generally call super.dispose() at the appropriate time to perform the basic cleanup, which may need to happen either before or after cleaning up other objects.
      Overrides:
      dispose in class LXModulatorComponent
    • getColor

      protected int getColor(int i)
      Retrieves the color at index i. This is provided mainly as documentation, but you should not generally use this method. You're better of just indexing directly to this.colors[i] and saving function call overhead.
      Parameters:
      i - Color index
      Returns:
      Color at that buffer index
    • getColor

      protected int getColor(LXPoint p)
      Retrieves the color at a given point. This is provided mainly as documentation, you should not generally use this method. You're better off just indexing directly by calling this.colors[p.index] and saving the function call overhead for a single point.
      Parameters:
      p - Point
      Returns:
      Color at that point
    • setColor

      protected final LXLayeredComponent setColor(int i, int c)
      Sets the color of point i
      Parameters:
      i - Point index
      c - color
      Returns:
      this
    • setColor

      protected final LXLayeredComponent setColor(LXPoint p, int c)
      Sets the color of a point. This is provided for clarity, but if you're working with large pixel counts you may just skip calling this method and set colors[p.index] to avoid per-pixel function call overhead.
      Parameters:
      p - Point
      c - color
      Returns:
      this
    • blendColor

      protected final LXLayeredComponent blendColor(int i, int c, LXColor.Blend blendMode)
      Blend the color at index i with its existing value
      Parameters:
      i - Index
      c - New color
      blendMode - blending mode
      Returns:
      this
    • blendColor

      protected final LXLayeredComponent blendColor(LXModel model, int c, LXColor.Blend blendMode)
    • addColor

      protected final LXLayeredComponent addColor(int i, int c)
      Adds to the color of point i, using blendColor with ADD
      Parameters:
      i - Point index
      c - color
      Returns:
      this
    • addColor

      protected final LXLayeredComponent addColor(LXModel model, int c)
      Adds the color to the fixture
      Parameters:
      model - model
      c - New color
      Returns:
      this
    • subtractColor

      protected final LXLayeredComponent subtractColor(int i, int c)
      Subtracts from the color of point i, using blendColor with SUBTRACT
      Parameters:
      i - Point index
      c - color
      Returns:
      this
    • setColors

      protected final LXLayeredComponent setColors(int c)
      Sets all points to one color
      Parameters:
      c - Color
      Returns:
      this
    • setColor

      protected final LXLayeredComponent setColor(LXModel model, int c)
      Sets the color of all points in a fixture
      Parameters:
      model - Model
      c - color
      Returns:
      this
    • clearColors

      protected final LXLayeredComponent clearColors()
      Clears all colors
      Returns:
      this