Class Effect

java.lang.Object
com.github.tommyettinger.textra.Effect
Direct Known Subclasses:
AttentionEffect, BlinkEffect, CannonEffect, CarouselEffect, CrowdEffect, EaseEffect, EmergeEffect, FadeEffect, GradientEffect, HangEffect, HeartbeatEffect, HighlightEffect, JoltEffect, JumpEffect, LinkEffect, RainbowEffect, RotateEffect, ScaleEffect, ShakeEffect, ShrinkEffect, SickEffect, SlideEffect, SpinEffect, SpiralEffect, SquashEffect, StylistEffect, TriggerEffect, WaveEffect, WindEffect

public abstract class Effect
extends java.lang.Object
Abstract text effect.
  • Field Summary

    Fields
    Modifier and Type Field Description
    float duration  
    int indexEnd  
    int indexStart  
    protected TypingLabel label  
    protected float totalTime  
  • Constructor Summary

    Constructors
    Constructor Description
    Effect​(TypingLabel label)  
  • Method Summary

    Modifier and Type Method Description
    void apply​(long glyph, int glyphIndex, float delta)
    Applies the effect to the given glyph.
    protected float calculateFadeout()
    Calculates the fadeout of this effect, if any.
    protected float calculateProgress​(float modifier)
    Calculates a linear progress dividing the total time by the given modifier.
    protected float calculateProgress​(float modifier, float offset)
    Calculates a linear progress dividing the total time by the given modifier.
    protected float calculateProgress​(float modifier, float offset, boolean pingpong)
    Calculates a linear progress dividing the total time by the given modifier.
    boolean isFinished()
    Returns whether this effect is finished and should be removed.
    protected abstract void onApply​(long glyph, int localIndex, int globalIndex, float delta)
    Called when this effect should be applied to the given glyph.
    protected boolean paramAsBoolean​(java.lang.String str)
    Returns a boolean value parsed from the given String, or the default value if the string couldn't be parsed.
    protected int paramAsColor​(java.lang.String str)
    Parses a color from the given string.
    protected float paramAsFloat​(java.lang.String str, float defaultValue)
    Returns a float value parsed from the given String, or the default value if the string couldn't be parsed.
    void update​(float delta)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • label

      protected final TypingLabel label
    • indexStart

      public int indexStart
    • indexEnd

      public int indexEnd
    • duration

      public float duration
    • totalTime

      protected float totalTime
  • Constructor Details

  • Method Details

    • update

      public void update​(float delta)
    • apply

      public final void apply​(long glyph, int glyphIndex, float delta)
      Applies the effect to the given glyph.
    • onApply

      protected abstract void onApply​(long glyph, int localIndex, int globalIndex, float delta)
      Called when this effect should be applied to the given glyph.
    • isFinished

      public boolean isFinished()
      Returns whether this effect is finished and should be removed. Note that effects are infinite by default.
    • calculateFadeout

      protected float calculateFadeout()
      Calculates the fadeout of this effect, if any. Only considers the second half of the duration.
    • calculateProgress

      protected float calculateProgress​(float modifier)
      Calculates a linear progress dividing the total time by the given modifier. Returns a value between 0 and 1 that loops in a ping-pong mode.
    • calculateProgress

      protected float calculateProgress​(float modifier, float offset)
      Calculates a linear progress dividing the total time by the given modifier. Returns a value between 0 and 1 that loops in a ping-pong mode.
    • calculateProgress

      protected float calculateProgress​(float modifier, float offset, boolean pingpong)
      Calculates a linear progress dividing the total time by the given modifier. Returns a value between 0 and 1.
    • paramAsFloat

      protected float paramAsFloat​(java.lang.String str, float defaultValue)
      Returns a float value parsed from the given String, or the default value if the string couldn't be parsed.
    • paramAsBoolean

      protected boolean paramAsBoolean​(java.lang.String str)
      Returns a boolean value parsed from the given String, or the default value if the string couldn't be parsed.
    • paramAsColor

      protected int paramAsColor​(java.lang.String str)
      Parses a color from the given string. Returns 256 if the color couldn't be parsed.