Class TextureIcon

java.lang.Object
io.github.cottonmc.cotton.gui.widget.icon.TextureIcon
All Implemented Interfaces:
Icon

public class TextureIcon extends Object implements Icon
An icon that draws a texture.
Since:
2.2.0
  • Constructor Details

    • TextureIcon

      public TextureIcon(Identifier texture)
      Constructs a new texture icon.
      Parameters:
      texture - the identifier of the icon texture
    • TextureIcon

      public TextureIcon(Texture texture)
      Constructs a new texture icon.
      Parameters:
      texture - the identifier of the icon texture
      Since:
      3.0.0
  • Method Details

    • getOpacity

      public float getOpacity()
      Gets the opacity of the texture.
      Returns:
      the opacity
    • setOpacity

      public TextureIcon setOpacity(float opacity)
      Sets the opacity of the texture.
      Parameters:
      opacity - the new opacity between 0 (fully transparent) and 1 (fully opaque)
      Returns:
      this icon
    • getColor

      public int getColor()
      Gets the color tint of the texture.
      Returns:
      the color tint
    • setColor

      public TextureIcon setColor(int color)
      Sets the color tint of the texture.
      Parameters:
      color - the new color tint
      Returns:
      this icon
    • paint

      @Environment(CLIENT) public void paint(DrawContext context, int x, int y, int size)
      Description copied from interface: Icon
      Paints this icon.
      Specified by:
      paint in interface Icon
      Parameters:
      context - the draw context
      x - the X coordinate
      y - the Y coordinate
      size - the size of this icon in pixels (size N means a N*N square)