Class AbstractGradient
java.lang.Object
com.github.darksoulq.abyssallib.common.color.gradient.AbstractGradient
- All Implemented Interfaces:
ColorProvider
- Direct Known Subclasses:
LinearGradient, RadialGradient, SweepGradient
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
ConstructorsConstructorDescriptionAbstractGradient(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 TypeMethodDescriptionorg.bukkit.Colorget(org.bukkit.util.Vector pos, double t) Retrieves the color for a specific spatial position and time progress.org.bukkit.ColorgetAt(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, waitMethods 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 ofColorstops 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 ofColorstops to distribute.
-
AbstractGradient
Constructs a gradient with a list of colors evenly distributed across the 0.0 to 1.0 range.- Parameters:
colors- The list ofColorstops 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
Colorbased 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:
getin interfaceColorProvider- Parameters:
pos- The spatialVectorposition of the pixel or point.t- The global progress (typically 0.0 to 1.0).- Returns:
- The resulting
Colorat the sampled point.
-
getColors
public org.bukkit.Color[] getColors()Retrieves a copy of the color stops used in this gradient.- Returns:
- A new
Colorarray 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.
-