Class IntColorGlider
java.lang.Object
com.github.yellowstonegames.smooth.Glider
com.github.yellowstonegames.smooth.IntColorGlider
Allows specifying a smoothly-changing color using an int-based color (often RGBA8888, but possibly produced by
This is a type of Glider, and so is compatible with other Gliders (it can also be merged with them).
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).
-
Nested Class Summary
Nested classes/interfaces inherited from class Glider
Glider.Changer -
Field Summary
Fields inherited from class Glider
change, changers, completeRunner, interpolation -
Constructor Summary
ConstructorsConstructorDescriptionConstructs an empty IntColorGlider that needs to have itssetStart(int)andsetEnd(int)methods called before it can be meaningfully used.IntColorGlider(int start) Creates an IntColorGlider that linear-interpolates the start color to fully transparent.IntColorGlider(int start, int end) Creates an IntColorGlider that linear-interpolates the start color to the end color.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.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.IntColorGlider(IntColorGlider other) -
Method Summary
Methods inherited from class Glider
addChanger, addChangers, addChangers, equals, getChange, getCompleteRunner, getEndFloat, getEndInt, getFloat, getInt, getInterpolation, getStartFloat, getStartInt, hashCode, merge, onComplete, removeChanger, resetToCurrent, setChange, setCompleteRunner, setEndFloat, setEndInt, setInterpolation, setStartFloat, setStartInt
-
Constructor Details
-
IntColorGlider
public IntColorGlider()Constructs an empty IntColorGlider that needs to have itssetStart(int)andsetEnd(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 toDescriptiveColor.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
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 fromInterpolationscompleteRunner- a Runnable that, if non-null, will be run when the glide completes
-
IntColorGlider
-
-
Method Details
-
getColor
public int getColor()Gets the current color value, which is different whenGlider.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
-