Class Color

java.lang.Object
dev.avelar.mapnik.Color

public final class Color extends Object
An RGBA colour with 8 bits per channel. Parse one from anything Mapnik's style files accept: a name ("rebeccapurple"), "#rrggbb", "#rrggbbaa" or "rgba(r,g,b,a)" with a from 0 to 1. Colours are accepted wherever the API also takes a colour string.
  • Field Details

    • WHITE

      public static final Color WHITE
    • BLACK

      public static final Color BLACK
    • TRANSPARENT

      public static final Color TRANSPARENT
  • Constructor Details

    • Color

      public Color(int red, int green, int blue, int alpha)
      Each channel from 0 to 255.
  • Method Details

    • rgb

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

      public static Color fromArgb(int argb)
      From 0xAARRGGBB, the layout of Image.getArgb(int, int).
    • parse

      public static Color parse(String text)
      Parse a colour string. Throws MapnikException if Mapnik does not understand it.
    • red

      public int red()
    • green

      public int green()
    • blue

      public int blue()
    • alpha

      public int alpha()
      Alpha from 0 (transparent) to 255 (opaque).
    • isOpaque

      public boolean isOpaque()
    • toArgb

      public int toArgb()
      As 0xAARRGGBB.
    • toHex

      public String toHex()
      #rrggbb, or #rrggbbaa when not opaque.
    • equals

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

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

      public String toString()
      Mapnik's own spelling, for example rgb(255,0,0) or rgba(255,0,0,0.5).
      Overrides:
      toString in class Object