Class Recolor

  • All Implemented Interfaces:
    org.polyfrost.polyui.operations.ComponentOp

    
    public final class Recolor<S extends Drawable>
    extends ComponentOp.Animatable<S>
                        

    Changes the color of the component to the specified color. Supports animation and callback function on finish.

    If the color is a PolyColor.Gradient, this component's color will be changed to a gradient between the current color and the specified color.

    Since:

    0.19.1

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private Function1<S, Unit> onFinish
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      Boolean verify() override this function to verify that this operation is valid, which is run before it is applied.
      Unit apply() Apply the operation, this is called before the component is rendered.
      Boolean unapply() Unapply the operation.
      • Methods inherited from class org.polyfrost.polyui.operations.ComponentOp.Animatable

        add, finishNow, getOnFinish, reset, reverse, setOnFinish
      • Methods inherited from class org.polyfrost.polyui.operations.ComponentOp

        exclusive
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Recolor

        Recolor(S drawable, PolyColor toColor, Animation animation, Function1<S, Unit> onFinish)
        Parameters:
        toColor - The color to change the component to.
        animation - The animation to use.
        onFinish - The callback function to execute when the color change animation finishes.
    • Method Detail

      • verify

         Boolean verify()

        override this function to verify that this operation is valid, which is run before it is applied. (default: always true)

        Returns:

        true if this operation is deemed to be valid.

        Since:

        1.1.1

      • apply

         Unit apply()

        Apply the operation, this is called before the component is rendered.

      • unapply

         Boolean unapply()

        Unapply the operation. this is called after the component is rendered.

        return true to instantly remove this operation from the component.