java.lang.Object
com.thecoderscorner.menu.domain.state.PortableColor

public class PortableColor extends Object
A portable color that represents a color in the RGBA space with single byte values for each entry (between 0..255). It can convert to and from web color format strings.
  • Field Details

  • Constructor Details

    • PortableColor

      public PortableColor(int red, int green, int blue)
      Create a color from RGB with alpha set to full (255), each value from 0 to 255
      Parameters:
      red - the red component
      green - the green component
      blue - the blue component
    • PortableColor

      public PortableColor(int red, int green, int blue, int alpha)
      Create a color from RGBA using values from 0 to 255
      Parameters:
      red - the red component
      green - the green component
      blue - the blue component
      alpha - the alpha
    • PortableColor

      public PortableColor(String htmlCode)
      Create a color object from a web color code such as #FFFFFF
      Parameters:
      htmlCode - the html code
  • Method Details

    • getRed

      public int getRed()
      Returns:
      red component between 0 and 255
    • getGreen

      public int getGreen()
      Returns:
      green component between 0 and 255
    • getBlue

      public int getBlue()
      Returns:
      blue component between 0 and 255
    • getAlpha

      public int getAlpha()
      Returns:
      alpha component between 0 and 255
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toHtml

      public String toHtml()
    • asPortableColor

      public static PortableColor asPortableColor(int argb)
    • applyAlphaChannel

      public PortableColor applyAlphaChannel()