Class GradientTools
java.lang.Object
com.github.tommyettinger.colorful.pure.ycwcm.GradientTools
Static methods for handling gradients of smoothly-changing colors, typically inside of
FloatList
s.
The intent is for the FloatList to be used as a sequence of packed float YCwCm colors. You can create a new
FloatList gradient with makeGradient(float, float, int, InterpolationFunction)
, but any FloatList will work
(although it only makes sense if it contains packed float colors or is empty). Once you have a FloatList, you can
pass it to appendGradient(FloatList, float, float, int, InterpolationFunction)
to make a gradient between two
colors, or appendGradientChain(FloatList, int, InterpolationFunction, float...)
to make a gradient between more
than two colors. You can also customize each section between colors with
appendPartialGradient(FloatList, float, float, int, InterpolationFunction)
, which is just like appendGradient() but
doesn't add the end color (since it is the start color of the next partial gradient, until you finally end by
appending just the end). Using appendPartialGradient(), you can have each transition use a different number of steps.-
Method Summary
Modifier and TypeMethodDescriptionstatic com.github.tommyettinger.ds.FloatList
appendGradient
(com.github.tommyettinger.ds.FloatList appending, float start, float end, int steps) Appends a gradient from the packed float YCwCm colorstart
to the packed float YCwCm colorend
, taking the specified number of steps and using linear InterpolationFunction for how it transitions.static com.github.tommyettinger.ds.FloatList
appendGradient
(com.github.tommyettinger.ds.FloatList appending, float start, float end, int steps, com.github.tommyettinger.digital.Interpolations.InterpolationFunction interpolation) Appends a gradient from the packed float YCwCm colorstart
to the packed float YCwCm colorend
, taking the specified number of steps and using the specified InterpolationFunction for how it transitions.static com.github.tommyettinger.ds.FloatList
appendGradientChain
(com.github.tommyettinger.ds.FloatList appending, int steps, float... chain) Appends a gradient between several packed float YCwCm colors provided inchain
.static com.github.tommyettinger.ds.FloatList
appendGradientChain
(com.github.tommyettinger.ds.FloatList appending, int steps, com.github.tommyettinger.digital.Interpolations.InterpolationFunction interpolation, float... chain) Appends a gradient between several packed float YCwCm colors provided inchain
.static com.github.tommyettinger.ds.FloatList
appendGradientChain
(com.github.tommyettinger.ds.FloatList appending, int steps, com.github.tommyettinger.digital.Interpolations.InterpolationFunction interpolation, com.github.tommyettinger.ds.FloatList chain) Appends a gradient between several packed float YCwCm colors provided inchain
.static com.github.tommyettinger.ds.FloatList
appendGradientChain
(com.github.tommyettinger.ds.FloatList appending, int steps, com.github.tommyettinger.ds.FloatList chain) Appends a gradient between several packed float YCwCm colors provided inchain
.static com.github.tommyettinger.ds.FloatList
appendPartialGradient
(com.github.tommyettinger.ds.FloatList appending, float start, float end, int steps) Exactly likeappendGradient(FloatList, float, float, int)
, but does not includeend
in what it appends toappending
.static com.github.tommyettinger.ds.FloatList
appendPartialGradient
(com.github.tommyettinger.ds.FloatList appending, float start, float end, int steps, com.github.tommyettinger.digital.Interpolations.InterpolationFunction interpolation) Exactly likeappendGradient(FloatList, float, float, int, InterpolationFunction)
, but does not includeend
in what it appends toappending
.static com.github.tommyettinger.ds.FloatList
makeGradient
(float start, float end, int steps) Creates a FloatList gradient from the packed float YCwCm colorstart
to the packed float YCwCm colorend
, taking the specified number of steps and using linear interpolation.static com.github.tommyettinger.ds.FloatList
makeGradient
(float start, float end, int steps, com.github.tommyettinger.digital.Interpolations.InterpolationFunction interpolation) Creates a FloatList gradient from the packed float YCwCm colorstart
to the packed float YCwCm colorend
, taking the specified number of steps and using the specified InterpolationFunction for how it transitions.
-
Method Details
-
makeGradient
Creates a FloatList gradient from the packed float YCwCm colorstart
to the packed float YCwCm colorend
, taking the specified number of steps and using linear interpolation.- Parameters:
start
- the packed float YCwCm color to start withend
- the packed float YCwCm color to end onsteps
- how many steps the gradient should use; usually greater than 2, and must be non-negative- Returns:
- a new FloatList that contains the requested gradient
-
makeGradient
public static com.github.tommyettinger.ds.FloatList makeGradient(float start, float end, int steps, com.github.tommyettinger.digital.Interpolations.InterpolationFunction interpolation) Creates a FloatList gradient from the packed float YCwCm colorstart
to the packed float YCwCm colorend
, taking the specified number of steps and using the specified InterpolationFunction for how it transitions.- Parameters:
start
- the packed float YCwCm color to start withend
- the packed float YCwCm color to end onsteps
- how many steps the gradient should use; usually greater than 2, and must be non-negativeinterpolation
- a libGDX InterpolationFunction that can be used to customize how start transitions to end- Returns:
- a new FloatList that contains the requested gradient
-
appendGradient
public static com.github.tommyettinger.ds.FloatList appendGradient(com.github.tommyettinger.ds.FloatList appending, float start, float end, int steps) Appends a gradient from the packed float YCwCm colorstart
to the packed float YCwCm colorend
, taking the specified number of steps and using linear InterpolationFunction for how it transitions.- Parameters:
appending
- a FloatList that will be appended tostart
- the packed float YCwCm color to start withend
- the packed float YCwCm color to end onsteps
- how many steps the gradient should use; usually greater than 2- Returns:
appending
, after adding the gradient to the end
-
appendGradient
public static com.github.tommyettinger.ds.FloatList appendGradient(com.github.tommyettinger.ds.FloatList appending, float start, float end, int steps, com.github.tommyettinger.digital.Interpolations.InterpolationFunction interpolation) Appends a gradient from the packed float YCwCm colorstart
to the packed float YCwCm colorend
, taking the specified number of steps and using the specified InterpolationFunction for how it transitions.- Parameters:
appending
- a FloatList that will be appended tostart
- the packed float YCwCm color to start withend
- the packed float YCwCm color to end onsteps
- how many steps the gradient should use; usually greater than 2interpolation
- a libGDX InterpolationFunction that can be used to customize how start transitions to end- Returns:
appending
, after adding the gradient to the end
-
appendGradientChain
public static com.github.tommyettinger.ds.FloatList appendGradientChain(com.github.tommyettinger.ds.FloatList appending, int steps, float... chain) Appends a gradient between several packed float YCwCm colors provided inchain
. This uses linear InterpolationFunction for the whole gradient. Appends to the end ofappending
and produces a total ofsteps
colors.- Parameters:
appending
- a FloatList that will be appended tosteps
- how many steps the gradient should use; usually greater than 2chain
- an array or varargs of packed float YCwCm colors that this will interpolate through in order- Returns:
appending
, after adding the gradient to the end
-
appendGradientChain
public static com.github.tommyettinger.ds.FloatList appendGradientChain(com.github.tommyettinger.ds.FloatList appending, int steps, com.github.tommyettinger.ds.FloatList chain) Appends a gradient between several packed float YCwCm colors provided inchain
. This uses linear InterpolationFunction for the whole gradient. Appends to the end ofappending
and produces a total ofsteps
colors.- Parameters:
appending
- a FloatList that will be appended tosteps
- how many steps the gradient should use; usually greater than 2chain
- a FloatList of packed float YCwCm colors that this will interpolate through in order- Returns:
appending
, after adding the gradient to the end
-
appendGradientChain
public static com.github.tommyettinger.ds.FloatList appendGradientChain(com.github.tommyettinger.ds.FloatList appending, int steps, com.github.tommyettinger.digital.Interpolations.InterpolationFunction interpolation, com.github.tommyettinger.ds.FloatList chain) Appends a gradient between several packed float YCwCm colors provided inchain
. This uses the specified InterpolationFunction for the whole gradient, which can make some colors use smaller sections than others. Appends to the end ofappending
and produces a total ofsteps
colors.- Parameters:
appending
- a FloatList that will be appended tosteps
- how many steps the gradient should use; usually greater than 2interpolation
- a libGDX InterpolationFunction that can be used to customize how start transitions to endchain
- a FloatList of packed float YCwCm colors that this will interpolate through in order- Returns:
appending
, after adding the gradient to the end
-
appendGradientChain
public static com.github.tommyettinger.ds.FloatList appendGradientChain(com.github.tommyettinger.ds.FloatList appending, int steps, com.github.tommyettinger.digital.Interpolations.InterpolationFunction interpolation, float... chain) Appends a gradient between several packed float YCwCm colors provided inchain
. This uses the specified InterpolationFunction for the whole gradient, which can make some colors use smaller sections than others. Appends to the end ofappending
and produces a total ofsteps
colors.- Parameters:
appending
- a FloatList that will be appended tosteps
- how many steps the gradient should use; usually greater than 2interpolation
- a libGDX InterpolationFunction that can be used to customize how start transitions to endchain
- an array or varargs of packed float YCwCm colors that this will interpolate through in order- Returns:
appending
, after adding the gradient to the end
-
appendPartialGradient
public static com.github.tommyettinger.ds.FloatList appendPartialGradient(com.github.tommyettinger.ds.FloatList appending, float start, float end, int steps) Exactly likeappendGradient(FloatList, float, float, int)
, but does not includeend
in what it appends toappending
. This is intended for the implementation of chained gradients, where the end of a previous gradient becomes the start of the next one. This still uses the specified number of steps, it just doesn't appendend
in the last step.- Parameters:
appending
- a FloatList that will be appended tostart
- the packed float YCwCm color to start withend
- the packed float YCwCm color to end just beforesteps
- how many steps the gradient should use; usually greater than 2- Returns:
appending
, after adding the gradient to its end
-
appendPartialGradient
public static com.github.tommyettinger.ds.FloatList appendPartialGradient(com.github.tommyettinger.ds.FloatList appending, float start, float end, int steps, com.github.tommyettinger.digital.Interpolations.InterpolationFunction interpolation) Exactly likeappendGradient(FloatList, float, float, int, InterpolationFunction)
, but does not includeend
in what it appends toappending
. This is intended for the implementation of chained gradients, where the end of a previous gradient becomes the start of the next one. This still uses the specified number of steps, it just doesn't appendend
in the last step.- Parameters:
appending
- a FloatList that will be appended tostart
- the packed float YCwCm color to start withend
- the packed float YCwCm color to end just beforesteps
- how many steps the gradient should use; usually greater than 2interpolation
- a libGDX InterpolationFunction that can be used to customize how start transitions toward end- Returns:
appending
, after adding the gradient to its end
-