Class Rgb

java.lang.Object
com.oorian.css.color.Rgb
All Implemented Interfaces:
Serializable

public class Rgb extends Object implements Serializable
This class encapsulates the attributes used for setting an RGB color.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    float
    Alpha component (0.0 = fully transparent, 1.0 = fully opaque).
    int
    Blue color component (0 - 255).
    int
    Green color component (0 - 255).
    int
    Red color component (0 - 255).
  • Constructor Summary

    Constructors
    Constructor
    Description
    Rgb()
    Creates a default RGB object with RGB = 0, 0, 0 and alpha = 1.0.
    Rgb(int r, int g, int b)
    Creates an RGB object with the specified RGB values and alpha = 1.0.
    Rgb(int r, int g, int b, float a)
    Creates an RGBA object with the specified RGB and alpha values.
    Rgb(Rgb rgb)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    int
    Returns the RGB value as a single integer with components packed as 0xRRGGBB.
    boolean
    Returns whether this color has a non-opaque alpha value.
    int
    This method returns a String representation of this object.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • r

      public int r
      Red color component (0 - 255).
    • g

      public int g
      Green color component (0 - 255).
    • b

      public int b
      Blue color component (0 - 255).
    • a

      public float a
      Alpha component (0.0 = fully transparent, 1.0 = fully opaque).
  • Constructor Details

    • Rgb

      public Rgb()
      Creates a default RGB object with RGB = 0, 0, 0 and alpha = 1.0.
    • Rgb

      public Rgb(int r, int g, int b)
      Creates an RGB object with the specified RGB values and alpha = 1.0.
      Parameters:
      r - Red color component (0 - 255)
      g - Green color component (0 - 255)
      b - Blue color component (0 - 255)
    • Rgb

      public Rgb(int r, int g, int b, float a)
      Creates an RGBA object with the specified RGB and alpha values.
      Parameters:
      r - Red color component (0 - 255)
      g - Green color component (0 - 255)
      b - Blue color component (0 - 255)
      a - Alpha component (0.0 - 1.0)
    • Rgb

      public Rgb(Rgb rgb)
      Parameters:
      rgb - Copy constructor.
  • Method Details

    • getRgb

      public int getRgb()
      Returns the RGB value as a single integer with components packed as 0xRRGGBB.
      Returns:
      The RGB value with red in bits 16-23, green in bits 8-15, and blue in bits 0-7.
    • hasAlpha

      public boolean hasAlpha()
      Returns whether this color has a non-opaque alpha value.
      Returns:
      true if the alpha component is less than 1.0.
    • toString

      public String toString()
      This method returns a String representation of this object.
      Overrides:
      toString in class Object
      Returns:
      String representation of this object.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object