Class Color


  • public class Color
    extends Object
    Color interface.

    The Color interface provide a representation of a color, independant from the target Window Toolkit (AWT, SWT, etc).

    Author:
    Martin Pernollet
    • Field Detail

      • BLACK

        public static final Color BLACK
      • WHITE

        public static final Color WHITE
      • GRAY

        public static final Color GRAY
      • RED

        public static final Color RED
      • GREEN

        public static final Color GREEN
      • BLUE

        public static final Color BLUE
      • YELLOW

        public static final Color YELLOW
      • MAGENTA

        public static final Color MAGENTA
      • CYAN

        public static final Color CYAN
      • ORANGE

        public static final Color ORANGE
      • COLORS

        public static final Color[] COLORS
      • r

        public float r
      • g

        public float g
      • b

        public float b
      • a

        public float a
      • rng

        public static Random rng
    • Constructor Detail

      • Color

        public Color​(float r,
                     float g,
                     float b)
        Initialize a color with an alpha channel set to 1, using input values between 0.0 and 1.0.
      • Color

        public Color​(int r,
                     int g,
                     int b)
        Initialize a color with an alpha channel set to 1, using input values between 0 and 255.
      • Color

        public Color​(float r,
                     float g,
                     float b,
                     float a)
        Initialize a color with input values between 0.0 and 1.0.
      • Color

        public Color​(int r,
                     int g,
                     int b,
                     int a)
        Initialize a color with values between 0 and 255.
      • Color

        public Color​(double r,
                     double g,
                     double b)
      • Color

        public Color​(double r,
                     double g,
                     double b,
                     double a)
    • Method Detail

      • mulSelf

        public Color mulSelf​(float ratio)
      • mulSelfWithAlpha

        public Color mulSelfWithAlpha​(float ratio)
      • divSelf

        public Color divSelf​(float ratio)
      • divSelfWithAlpha

        public Color divSelfWithAlpha​(float ratio)
      • alphaSelf

        public Color alphaSelf​(float alpha)
      • alpha

        public Color alpha​(float alpha)
      • toHex

        public String toHex()
        Return the hexadecimal representation of this color.
      • toArray

        public float[] toArray()
      • negative

        public Color negative()
      • negativeSelf

        public Color negativeSelf()
      • color

        public static Color color​(int c)
        Returns one of the main color based on id. Use id%(#colors)
      • distance

        public double distance​(Color c)
        Compute the distance between two colors.
      • distanceSq

        public double distanceSq​(Color c)
        Compute the square distance between two colors.