Class Transition

java.lang.Object
org.openpatch.scratch.Transition

public final class Transition extends Object
How one stage gives way to the next in window.transitionToStage(…). A transition is a small shader that mixes the old stage's picture (from) and the new one's (to) by progress, from 0 to 1; the built-in ones cover the usual cases, and fromShader(String) makes one of your own:
void main() {
  color = mix(texture(from, uv), texture(to, uv), progress);
}

During a transition the old stage stands still, the new stage's run() starts once the transition is over, and input is ignored.

  • Field Details

    • FADE

      public static final Transition FADE
      Fades the old stage to black, then the new one in.
    • CROSSFADE

      public static final Transition CROSSFADE
      Blends the old stage into the new one.
    • SLIDE_LEFT

      public static final Transition SLIDE_LEFT
      The new stage pushes the old one out to the left.
    • SLIDE_RIGHT

      public static final Transition SLIDE_RIGHT
      The new stage pushes the old one out to the right.
    • SLIDE_UP

      public static final Transition SLIDE_UP
      The new stage pushes the old one out upwards.
    • SLIDE_DOWN

      public static final Transition SLIDE_DOWN
      The new stage pushes the old one out downwards.
  • Method Details

    • fromShader

      public static Transition fromShader(String path)
      A transition of your own: a shader body with from, to (the two pictures), progress (0 to 1), uv and color.
      Parameters:
      path - the file with the body
      Returns:
      the transition
    • getName

      public String getName()
      Returns:
      the built-in name or the shader file
    • toString

      public String toString()
      Overrides:
      toString in class Object