Package com.massifmaps.graphics
Class Color
java.lang.Object
com.massifmaps.graphics.Color
A color represented in RGBA space, alpha is expected to be non-premultiplied.
-
Constructor Summary
ConstructorsConstructorDescriptionColor()Constructs a completely opaque black color object.Color(int color) Constructs a map color object from a 32-bit encoded integer.Color(short r, short g, short b, short a) Constructs a map color object from the red, green, blue and alpha components.
Alpha component is interpreted as non-premultiplied transparency value,
thus to make half-transparent green, use Color(0, 255, 0, 128). -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if this object is equal to the specified object.shortgetA()Returns the alpha component of this map color.intgetARGB()Encodes this map color into 32-bit integer value (ARGB format).shortgetB()Returns the blue component of this map color.shortgetG()Returns the green component of this map color.shortgetR()Returns the red component of this map color.inthashCode()Returns the hash value of this object.toString()Creates a string representation of this map color, useful for logging.
-
Constructor Details
-
Color
public Color()Constructs a completely opaque black color object. -
Color
public Color(short r, short g, short b, short a) Constructs a map color object from the red, green, blue and alpha components.
Alpha component is interpreted as non-premultiplied transparency value,
thus to make half-transparent green, use Color(0, 255, 0, 128).- Parameters:
r- The red component. Must be between 0 and 255.g- The green component. Must be between 0 and 255.b- The blue component. Must be between 0 and 255.a- The alpha component. Must be between 0 and 255.
-
Color
public Color(int color) Constructs a map color object from a 32-bit encoded integer. The format is expected to be ARGB.- Parameters:
color- The color encoded into 32-bit integer as ARGB.
-
-
Method Details
-
equals
Checks if this object is equal to the specified object. -
hashCode
public int hashCode()Returns the hash value of this object. -
getR
public short getR()Returns the red component of this map color.- Returns:
- The red component in the [0..255] range.
-
getG
public short getG()Returns the green component of this map color.- Returns:
- The green component in the [0..255] range.
-
getB
public short getB()Returns the blue component of this map color.- Returns:
- The blue component in the [0..255] range.
-
getA
public short getA()Returns the alpha component of this map color.- Returns:
- The alpha component in the [0..255] range.
-
getARGB
public int getARGB()Encodes this map color into 32-bit integer value (ARGB format).- Returns:
- The encoded 32-bit integer representation of this map color.
-
toString
Creates a string representation of this map color, useful for logging.
-