Interface Spring


public interface Spring
Values keyed by any object that ease toward their targets without overshooting, at the same speed at any frame rate. Time passes on its own: each update moves a value by the time since its last one.
A key seen for the first time starts at its target, and so does one that has not been updated for a while, so something that was out of sight does not animate a change it missed.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Forgets every value, so each key starts at its target again.
    void
    set(Object key, float value)
    Puts the value for key at value, standing still, for example to have a new piece grow from 0.
    static Spring
    settling(double seconds)
     
    static Spring
     
    default float
    update(Object key, boolean on)
    Moves the value for key toward 1 while on, toward 0 otherwise.
    float
    update(Object key, float target)
    Moves the value for key toward target.
  • Method Details

    • settling

      static Spring settling(double seconds)
      Parameters:
      seconds - About how long a value takes to settle on a new target; 0 jumps
      Returns:
      New springs
    • settling

      static Spring settling(DoubleSupplier seconds)
      Parameters:
      seconds - Read on every update, so the time can follow a setting; 0 jumps
      Returns:
      New springs
    • update

      float update(Object key, float target)
      Moves the value for key toward target.
      Returns:
      The current value
    • update

      default float update(Object key, boolean on)
      Moves the value for key toward 1 while on, toward 0 otherwise.
      Returns:
      The current value, 0 to 1
    • set

      void set(Object key, float value)
      Puts the value for key at value, standing still, for example to have a new piece grow from 0.
    • clear

      void clear()
      Forgets every value, so each key starts at its target again.