Class Paint

java.lang.Object
lol.trq.helios.batch.Paint

public final class Paint extends Object
How a shape is coloured: one colour, a gradient across its box, or a radial gradient from its centre. Colours are packed 0xAARRGGBB, not premultiplied, and mixed per channel in sRGB.

Box gradients are bilinear between four corner colours; linear gradients at any angle are expressed exactly that way. For a line the box is the line itself, so a horizontal gradient runs from its start to its end.

  • Method Summary

    Modifier and Type
    Method
    Description
    static Paint
    corners(int topLeft, int topRight, int bottomRight, int bottomLeft)
    A different colour in each corner, blended bilinearly.
    static Paint
    horizontal(int left, int right)
    Left to right.
    static int
    lerp(int a, int b, float t)
    Mixes two packed colours per channel.
    static Paint
    linear(float degrees, int from, int to)
    A linear gradient across the box at an angle; 0 degrees runs left to right, 90 top to bottom.
    static Paint
    radial(int centre, int edge, float radius)
    A radial gradient from the centre of the shape.
    static Paint
    solid(int argb)
    One colour.
    static Paint
    vertical(int top, int bottom)
    Top to bottom.

    Methods inherited from class Object

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

    • solid

      public static Paint solid(int argb)
      One colour.
      Parameters:
      argb - the colour
      Returns:
      the paint
    • corners

      public static Paint corners(int topLeft, int topRight, int bottomRight, int bottomLeft)
      A different colour in each corner, blended bilinearly.
      Parameters:
      topLeft - top-left colour
      topRight - top-right colour
      bottomRight - bottom-right colour
      bottomLeft - bottom-left colour
      Returns:
      the paint
    • horizontal

      public static Paint horizontal(int left, int right)
      Left to right.
      Parameters:
      left - colour at the left edge
      right - colour at the right edge
      Returns:
      the paint
    • vertical

      public static Paint vertical(int top, int bottom)
      Top to bottom.
      Parameters:
      top - colour at the top edge
      bottom - colour at the bottom edge
      Returns:
      the paint
    • linear

      public static Paint linear(float degrees, int from, int to)
      A linear gradient across the box at an angle; 0 degrees runs left to right, 90 top to bottom.
      Parameters:
      degrees - the direction
      from - colour at the start corner
      to - colour at the end corner
      Returns:
      the paint
    • radial

      public static Paint radial(int centre, int edge, float radius)
      A radial gradient from the centre of the shape.
      Parameters:
      centre - colour at the centre
      edge - colour at radius and beyond
      radius - where the edge colour is reached; 0 or less means the shape's half width or half height, whichever is larger
      Returns:
      the paint
    • lerp

      public static int lerp(int a, int b, float t)
      Mixes two packed colours per channel.
      Parameters:
      a - the colour at 0
      b - the colour at 1
      t - the mix, clamped to [0, 1]
      Returns:
      the mixed colour