Class AbstractGradient

java.lang.Object
com.github.darksoulq.abyssallib.common.color.gradient.AbstractGradient
All Implemented Interfaces:
ColorProvider
Direct Known Subclasses:
LinearGradient, RadialGradient, SweepGradient

public abstract class AbstractGradient extends Object implements ColorProvider
An abstract base class for multi-stop color gradients. * This class handles the core logic of interpolating between multiple colors at specific floating-point positions within a normalized range of 0.0 to 1.0. It implements the ColorProvider interface to allow spatial color sampling.
  • Constructor Summary

    Constructors
    Constructor
    Description
    AbstractGradient(List<org.bukkit.Color> colors)
    Constructs a gradient with a list of colors evenly distributed across the 0.0 to 1.0 range.
    AbstractGradient(org.bukkit.Color... colors)
    Constructs a gradient with colors evenly distributed across the 0.0 to 1.0 range.
    AbstractGradient(org.bukkit.Color[] colors, float[] positions)
    Constructs a gradient with specific color stops and their positions.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.bukkit.Color
    get(org.bukkit.util.Vector pos, double t)
    Retrieves the color for a specific spatial position and time progress.
    org.bukkit.Color
    getAt(double t)
    Calculates the color at a specific interpolation point using a local progress calculation.
    org.bukkit.Color[]
    Retrieves a copy of the color stops used in this gradient.
    float[]
    Retrieves a copy of the normalized position stops used in this gradient.

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface ColorProvider

    filter, get
  • Constructor Details

    • AbstractGradient

      public AbstractGradient(org.bukkit.Color[] colors, float[] positions)
      Constructs a gradient with specific color stops and their positions.
      Parameters:
      colors - The array of Color stops used for interpolation.
      positions - The array of normalized positions (0.0 to 1.0) for each stop.
      Throws:
      IllegalArgumentException - If the color and position arrays do not have the same length.
    • AbstractGradient

      public AbstractGradient(org.bukkit.Color... colors)
      Constructs a gradient with colors evenly distributed across the 0.0 to 1.0 range.
      Parameters:
      colors - The varargs array of Color stops to distribute.
    • AbstractGradient

      public AbstractGradient(List<org.bukkit.Color> colors)
      Constructs a gradient with a list of colors evenly distributed across the 0.0 to 1.0 range.
      Parameters:
      colors - The list of Color stops to distribute.
  • Method Details

    • getAt

      public org.bukkit.Color getAt(double t)
      Calculates the color at a specific interpolation point using a local progress calculation.
      Parameters:
      t - The normalized progress (0.0 to 1.0).
      Returns:
      The interpolated Color based on the surrounding stops.
    • get

      public org.bukkit.Color get(org.bukkit.util.Vector pos, double t)
      Retrieves the color for a specific spatial position and time progress.
      Specified by:
      get in interface ColorProvider
      Parameters:
      pos - The spatial Vector position of the pixel or point.
      t - The global progress (typically 0.0 to 1.0).
      Returns:
      The resulting Color at the sampled point.
    • getColors

      public org.bukkit.Color[] getColors()
      Retrieves a copy of the color stops used in this gradient.
      Returns:
      A new Color array containing the stops.
    • getPositions

      public float[] getPositions()
      Retrieves a copy of the normalized position stops used in this gradient.
      Returns:
      A new float array containing the normalized positions.