A simple representation of color. All color components range from 0.0 to 1.0, e.g.

layer.backgroundColor = Color(hue: 0.4, saturation: 0.8, brightness: 0.2)
layer.backgroundColor = new Color({hue: 0.4, saturation: 0.8, brightness: 0.2})

Method reference

  • public init(red: Double, green: Double, blue: Double, alpha: Double = 1.0)new Color({red: Number, green: Number, blue: Number, [alpha: Number = 1.0]})

    Creates a Color from a RGB color.

  • public init(hex: UInt32, alpha: Float)new Color({hex: String, [alpha: Number = 1.0]})

    Creates a Color based on a hex code.

    Do not include # in your hex code.
  • public init(hue: Double, saturation: Double, brightness: Double, alpha: Double = 1.0)new Color({hue: Number, saturation: Number, brightness: Number, [alpha: Number = 1.0]})

    Creates a Color from a HSB color.

  • public init(white: Double, alpha: Double = 1.0)new Color({white: Number, [alpha: Number = 1.0]})

    Creates a grayscale Color from a white value, where 0 is black and 1 is white.

  • Variables

  • public static var black: ColorColor.blackColor

  • public static var darkGray: ColorColor.darkGrayColor

  • public static var lightGray: ColorColor.lightGrayColor

  • public static var white: ColorColor.whiteColor

  • public static var gray: ColorColor.grayColor

  • public static var red: ColorColor.redColor

  • public static var green: ColorColor.greenColor

  • public static var blue: ColorColor.blueColor

  • public static var cyan: ColorColor.cyanColor

  • public static var yellow: ColorColor.yellowColor

  • public static var magenta: ColorColor.magentaColor

  • public static var orange: ColorColor.orangeColor

  • public static var purple: ColorColor.purpleColor

  • public static var brown: ColorColor.brownColor

  • public static var clear: ColorColor.clearColor

    Equivalent to black, but with a 0.0 alpha value.