Class GradientTools

java.lang.Object
com.github.tommyettinger.colorful.pure.ycwcm.GradientTools

public class GradientTools extends Object
Static methods for handling gradients of smoothly-changing colors, typically inside of FloatLists. 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 Type
    Method
    Description
    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 color start to the packed float YCwCm color end, 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 color start to the packed float YCwCm color end, 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 in chain.
    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 in chain.
    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 in chain.
    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 in chain.
    static com.github.tommyettinger.ds.FloatList
    appendPartialGradient(com.github.tommyettinger.ds.FloatList appending, float start, float end, int steps)
    Exactly like appendGradient(FloatList, float, float, int), but does not include end in what it appends to appending.
    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 like appendGradient(FloatList, float, float, int, InterpolationFunction), but does not include end in what it appends to appending.
    static com.github.tommyettinger.ds.FloatList
    makeGradient(float start, float end, int steps)
    Creates a FloatList gradient from the packed float YCwCm color start to the packed float YCwCm color end, 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 color start to the packed float YCwCm color end, taking the specified number of steps and using the specified InterpolationFunction for how it transitions.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • makeGradient

      public static com.github.tommyettinger.ds.FloatList makeGradient(float start, float end, int steps)
      Creates a FloatList gradient from the packed float YCwCm color start to the packed float YCwCm color end, taking the specified number of steps and using linear interpolation.
      Parameters:
      start - the packed float YCwCm color to start with
      end - the packed float YCwCm color to end on
      steps - 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 color start to the packed float YCwCm color end, taking the specified number of steps and using the specified InterpolationFunction for how it transitions.
      Parameters:
      start - the packed float YCwCm color to start with
      end - the packed float YCwCm color to end on
      steps - how many steps the gradient should use; usually greater than 2, and must be non-negative
      interpolation - 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 color start to the packed float YCwCm color end, taking the specified number of steps and using linear InterpolationFunction for how it transitions.
      Parameters:
      appending - a FloatList that will be appended to
      start - the packed float YCwCm color to start with
      end - the packed float YCwCm color to end on
      steps - 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 color start to the packed float YCwCm color end, taking the specified number of steps and using the specified InterpolationFunction for how it transitions.
      Parameters:
      appending - a FloatList that will be appended to
      start - the packed float YCwCm color to start with
      end - the packed float YCwCm color to end on
      steps - how many steps the gradient should use; usually greater than 2
      interpolation - 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 in chain. This uses linear InterpolationFunction for the whole gradient. Appends to the end of appending and produces a total of steps colors.
      Parameters:
      appending - a FloatList that will be appended to
      steps - how many steps the gradient should use; usually greater than 2
      chain - 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 in chain. This uses linear InterpolationFunction for the whole gradient. Appends to the end of appending and produces a total of steps colors.
      Parameters:
      appending - a FloatList that will be appended to
      steps - how many steps the gradient should use; usually greater than 2
      chain - 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 in chain. This uses the specified InterpolationFunction for the whole gradient, which can make some colors use smaller sections than others. Appends to the end of appending and produces a total of steps colors.
      Parameters:
      appending - a FloatList that will be appended to
      steps - how many steps the gradient should use; usually greater than 2
      interpolation - a libGDX InterpolationFunction that can be used to customize how start transitions to end
      chain - 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 in chain. This uses the specified InterpolationFunction for the whole gradient, which can make some colors use smaller sections than others. Appends to the end of appending and produces a total of steps colors.
      Parameters:
      appending - a FloatList that will be appended to
      steps - how many steps the gradient should use; usually greater than 2
      interpolation - a libGDX InterpolationFunction that can be used to customize how start transitions to end
      chain - 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 like appendGradient(FloatList, float, float, int), but does not include end in what it appends to appending. 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 append end in the last step.
      Parameters:
      appending - a FloatList that will be appended to
      start - the packed float YCwCm color to start with
      end - the packed float YCwCm color to end just before
      steps - 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 like appendGradient(FloatList, float, float, int, InterpolationFunction), but does not include end in what it appends to appending. 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 append end in the last step.
      Parameters:
      appending - a FloatList that will be appended to
      start - the packed float YCwCm color to start with
      end - the packed float YCwCm color to end just before
      steps - how many steps the gradient should use; usually greater than 2
      interpolation - a libGDX InterpolationFunction that can be used to customize how start transitions toward end
      Returns:
      appending, after adding the gradient to its end