Class IntColorGlider

java.lang.Object
com.github.yellowstonegames.smooth.Glider
com.github.yellowstonegames.smooth.IntColorGlider

public class IntColorGlider extends Glider
Allows specifying a smoothly-changing color using an int-based color (often RGBA8888, but possibly produced by DescriptiveColor and in Oklab space) for the start and the end, with a change amount that affects how far a color has been edited from start to end. Typical usage sets the start with setStart(int) once and the end more than once with setEnd(int), changing the end each time the move is complete. The current color is automatically calculated in getColor(), and its value will be different every time Glider.setChange(float) is called with a different amount. You can optionally use an Interpolations.Interpolator to make the rate of change different.
This is a type of Glider, and so is compatible with other Gliders (it can also be merged with them).
  • Constructor Details

    • IntColorGlider

      public IntColorGlider()
      Constructs an empty IntColorGlider that needs to have its setStart(int) and setEnd(int) methods called before it can be meaningfully used.
    • IntColorGlider

      public IntColorGlider(int start)
      Creates an IntColorGlider that linear-interpolates the start color to fully transparent. Unlike a transition from start to DescriptiveColor.TRANSPARENT, this will only change the alpha channel, keeping the color intact except for its alpha.
      Parameters:
      start - the color that will fade to transparent
    • IntColorGlider

      public IntColorGlider(int start, int end)
      Creates an IntColorGlider that linear-interpolates the start color to the end color.
      Parameters:
      start - the start color, as an int (this could be RGBA or Oklab)
      end - the end color, as an int (this could be RGBA or Oklab, but should be the same kind as start)
    • IntColorGlider

      public IntColorGlider(int start, int end, Runnable completeRunner)
      Creates an IntColorGlider that linear-interpolates the start color to the end color, and runs the given Runnable upon completion.
      Parameters:
      start - the start color, as an int (this could be RGBA or Oklab)
      end - the end color, as an int (this could be RGBA or Oklab, but should be the same kind as start)
      completeRunner - a Runnable that, if non-null, will be run when the glide completes
    • IntColorGlider

      public IntColorGlider(int start, int end, com.github.tommyettinger.digital.Interpolations.Interpolator interpolation, Runnable completeRunner)
      Creates an IntColorGlider that interpolates the start color to the end color using the given Interpolator, and runs the given Runnable upon completion.
      Parameters:
      start - the start color, as an int (this could be RGBA or Oklab)
      end - the end color, as an int (this could be RGBA or Oklab, but should be the same kind as start)
      interpolation - how to interpolate from start to end; typically a constant from Interpolations
      completeRunner - a Runnable that, if non-null, will be run when the glide completes
    • IntColorGlider

      public IntColorGlider(IntColorGlider other)
  • Method Details

    • getColor

      public int getColor()
      Gets the current color value, which is different when Glider.getChange() is.
      Returns:
      the current int color
    • getStart

      public int getStart()
      Returns:
      start color
    • setStart

      public void setStart(int start)
      Parameters:
      start - start color
    • getEnd

      public int getEnd()
      Returns:
      end color
    • setEnd

      public void setEnd(int end)
      Parameters:
      end - end color