public final class

Color

extends Object
java.lang.Object
   ↳ com.neomades.graphics.Color

Class Overview

Color object is used to encapsulate RGB components and opacity.

Static methods are provided in order to facilitate writing color with integers (0xAARRGGBB or 0xRRGGBB).

  • argb(int) : where the parameter is an integer (0xAARRGGBB) like 0xFF00FF00 (opaque and green)
  • rgb(int) : where the parameter is an integer (0xRRGGBB) like 0x00FF00 (opaque and green). In this case, opaque is implicit.

Summary

Fields
public static final Color BLACK Black.
public static final Color BLUE Blue.
public static final Color CYAN Cyan.
public static final Color DARK_BLUE Dark Blue.
public static final Color DARK_GRAY Dark Gray.
public static final Color GRAY Gray.
public static final Color GREEN Green.
public static final Color LIGHT_GRAY Light Gray.
public static final Color MAGENTA Magenta.
public static final Color ORANGE Orange.
public static final Color PINK Pink.
public static final Color RED Red.
public static final Color TRANSPARENT Transparent
public static final Color WHITE White.
public static final Color YELLOW Yellow.
Public Methods
static Color argb(int argb)
Create a sRGB color with integer argb code (eg.
static Color argb(int alpha, int red, int green, int blue)
Creates an sRGB color with the specified red, green, blue, and alpha values in the range (0 - 255).
int getAlpha()
Return the alpha value (0 - 255).
int getBlue()
Return the blue value (0 - 255).
int getGreen()
Return the green value (0 - 255).
abstract String getName()
int getRed()
Return the red value (0 - 255).
boolean isTransparent()
Return if this color is fully transparent (not visible).
static Color rgb(int rgb)
Create an opaque sRGB color with integer rgb code (eg.
static Color rgb(int red, int green, int blue)
Creates an opaque sRGB color with the specified red, green, and blue values in the range (0 - 255).
int toARGB()
Convert this color to integer color value (0xAARRGGBB) with alpha value.
int toRGB()
Convert this color to integer color value (0xRRGGBB) without alpha value.
[Expand]
Inherited Methods
From class java.lang.Object

Fields

public static final Color BLACK

Black.

     

public static final Color BLUE

Blue.

     

public static final Color CYAN

Cyan.

     

public static final Color DARK_BLUE

Dark Blue.

     

public static final Color DARK_GRAY

Dark Gray.

     

public static final Color GRAY

Gray.

     

public static final Color GREEN

Green.

     

public static final Color LIGHT_GRAY

Light Gray.

     

public static final Color MAGENTA

Magenta.

     

public static final Color ORANGE

Orange.

     

public static final Color PINK

Pink.

     

public static final Color RED

Red.

     

public static final Color TRANSPARENT

Transparent

public static final Color WHITE

White.

     

public static final Color YELLOW

Yellow.

     

Public Methods

public static Color argb (int argb)

Create a sRGB color with integer argb code (eg. : 0xAARRGGBB).

Parameters
argb integer ARGB code (0xAARRGGBB)
Returns
  • the corresponding color

public static Color argb (int alpha, int red, int green, int blue)

Creates an sRGB color with the specified red, green, blue, and alpha values in the range (0 - 255).

Parameters
alpha alpha/opacity component (0 : transparent, 255 : opaque)
red red component (0 - 255)
green green component (0 - 255)
blue blue component (0 - 255)
Returns
  • the corresponding color
Throws
IllegalArgumentException if one of parameters is out bounds (<0 or >255)

public int getAlpha ()

Return the alpha value (0 - 255).

Returns
  • the alpha component

public int getBlue ()

Return the blue value (0 - 255).

Returns
  • the blue component

public int getGreen ()

Return the green value (0 - 255).

Returns
  • the green component

public abstract String getName ()

public int getRed ()

Return the red value (0 - 255).

Returns
  • the red component

public boolean isTransparent ()

Return if this color is fully transparent (not visible).

Returns
  • true if the alpha value of this color is equal to 0

public static Color rgb (int rgb)

Create an opaque sRGB color with integer rgb code (eg. : 0xRRGGBB).

Parameters
rgb integer RGB code (0xRRGGBB)
Returns
  • the corresponding color

public static Color rgb (int red, int green, int blue)

Creates an opaque sRGB color with the specified red, green, and blue values in the range (0 - 255).

Parameters
red red component (0 - 255)
green green component (0 - 255)
blue blue component (0 - 255)
Returns
  • the corresponding color
Throws
IllegalArgumentException if one of parameters is out bounds (<0 or >255)

public int toARGB ()

Convert this color to integer color value (0xAARRGGBB) with alpha value.

Returns
  • the color integer value (0xAARRGGBB)

public int toRGB ()

Convert this color to integer color value (0xRRGGBB) without alpha value.

Returns
  • the color integer value (0xRRGGBB)