Class TextEffects

java.lang.Object
net.ixdarklord.coolcatcanvas.api.client.utils.TextEffects

public final class TextEffects extends Object
Gradient (rainbow included) and outlined text for GUI drawing.

For a component you build yourself, putting the ColorGradient in its style (ColorGradient.apply(MutableComponent)) is enough. gradient(FormattedCharSequence, ColorGradient) does the same to text you already have, replacing its colors, and the result can be kept and handed to anything that draws a FormattedCharSequence (tooltips, graphics.text, RenderUtils.drawScrollingString(GuiGraphicsExtractor, int, Font, Component, boolean, ScreenRectangle, int, int, boolean)...). The effects combine: an outlined rainbow is drawOutlinedText(graphics, font, rainbow(text), x, y, -1, 0xFF000000).

  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    drawCenteredGradientText(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.client.gui.Font font, net.minecraft.network.chat.Component text, int centerX, int y, ColorGradient gradient, boolean shadow)
     
    static void
    drawCenteredOutlinedText(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.client.gui.Font font, net.minecraft.network.chat.Component text, int centerX, int y, int color, int outlineColor)
     
    static void
    drawGradientOutlinedText(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.client.gui.Font font, net.minecraft.network.chat.Component text, int x, int y, int color, ColorGradient outline)
    Draws the text with an animated gradient outline.
    static void
    drawGradientOutlinedText(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.client.gui.Font font, net.minecraft.util.FormattedCharSequence text, int x, int y, int color, ColorGradient outline)
     
    static void
    drawGradientText(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.client.gui.Font font, String text, int x, int y, ColorGradient gradient, boolean shadow)
     
    static void
    drawGradientText(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.client.gui.Font font, net.minecraft.network.chat.Component text, int x, int y, ColorGradient gradient, boolean shadow)
     
    static void
    drawGradientText(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.client.gui.Font font, net.minecraft.util.FormattedCharSequence text, int x, int y, ColorGradient gradient, boolean shadow)
     
    static void
    drawOutlinedText(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.client.gui.Font font, String text, int x, int y, int color, int outlineColor)
     
    static void
    drawOutlinedText(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.client.gui.Font font, net.minecraft.network.chat.Component text, int x, int y, int color, int outlineColor)
     
    static void
    drawOutlinedText(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.client.gui.Font font, net.minecraft.util.FormattedCharSequence text, int x, int y, int color, int outlineColor)
    Draws the text with a one pixel outline around every glyph, like glowing signs.
    static net.minecraft.util.FormattedCharSequence
    gradient(net.minecraft.network.chat.Component text, ColorGradient gradient)
     
    static net.minecraft.util.FormattedCharSequence
    gradient(net.minecraft.util.FormattedCharSequence text, ColorGradient gradient)
    Colors the text with the gradient, replacing the colors of its style (bold, italic and the rest are kept).
    static net.minecraft.util.FormattedCharSequence
    rainbow(net.minecraft.network.chat.Component text)
    static net.minecraft.util.FormattedCharSequence
    rainbow(net.minecraft.util.FormattedCharSequence text)
    static net.minecraft.util.FormattedCharSequence
    recolor(net.minecraft.util.FormattedCharSequence text, int color)
    Draws every character in one color, whatever colors its style gives it.

    Methods inherited from class Object

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

    • rainbow

      public static net.minecraft.util.FormattedCharSequence rainbow(net.minecraft.network.chat.Component text)
    • rainbow

      public static net.minecraft.util.FormattedCharSequence rainbow(net.minecraft.util.FormattedCharSequence text)
    • gradient

      public static net.minecraft.util.FormattedCharSequence gradient(net.minecraft.network.chat.Component text, ColorGradient gradient)
    • gradient

      public static net.minecraft.util.FormattedCharSequence gradient(net.minecraft.util.FormattedCharSequence text, ColorGradient gradient)
      Colors the text with the gradient, replacing the colors of its style (bold, italic and the rest are kept). It animates each time it's drawn, so it can be kept.
    • recolor

      public static net.minecraft.util.FormattedCharSequence recolor(net.minecraft.util.FormattedCharSequence text, int color)
      Draws every character in one color, whatever colors its style gives it.
    • drawGradientText

      public static void drawGradientText(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.client.gui.Font font, String text, int x, int y, ColorGradient gradient, boolean shadow)
    • drawGradientText

      public static void drawGradientText(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.client.gui.Font font, net.minecraft.network.chat.Component text, int x, int y, ColorGradient gradient, boolean shadow)
    • drawGradientText

      public static void drawGradientText(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.client.gui.Font font, net.minecraft.util.FormattedCharSequence text, int x, int y, ColorGradient gradient, boolean shadow)
    • drawCenteredGradientText

      public static void drawCenteredGradientText(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.client.gui.Font font, net.minecraft.network.chat.Component text, int centerX, int y, ColorGradient gradient, boolean shadow)
    • drawOutlinedText

      public static void drawOutlinedText(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.client.gui.Font font, String text, int x, int y, int color, int outlineColor)
    • drawOutlinedText

      public static void drawOutlinedText(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.client.gui.Font font, net.minecraft.network.chat.Component text, int x, int y, int color, int outlineColor)
    • drawOutlinedText

      public static void drawOutlinedText(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.client.gui.Font font, net.minecraft.util.FormattedCharSequence text, int x, int y, int color, int outlineColor)
      Draws the text with a one pixel outline around every glyph, like glowing signs. color is the base color (the text's own style colors still apply over it); the outline is outlineColor everywhere.
    • drawGradientOutlinedText

      public static void drawGradientOutlinedText(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.client.gui.Font font, net.minecraft.network.chat.Component text, int x, int y, int color, ColorGradient outline)
      Draws the text with an animated gradient outline.
    • drawGradientOutlinedText

      public static void drawGradientOutlinedText(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.client.gui.Font font, net.minecraft.util.FormattedCharSequence text, int x, int y, int color, ColorGradient outline)
    • drawCenteredOutlinedText

      public static void drawCenteredOutlinedText(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.client.gui.Font font, net.minecraft.network.chat.Component text, int centerX, int y, int color, int outlineColor)