const virtual class vaseGraphics::Color

sys::Obj
  vaseGraphics::Color : vaseGraphics::Brush

@Js
@Serializable { simple=true }

Models an ARGB color (alpha, red, green, blue). Color is also a solid Brush.

a

Int a()

The alpha component from 0 to 255, where 255 is opaque and 0 is transparent.

argb

const Int argb

The ARGB components masked together: bits 31-24 alpha; bits 16-23 red; bits 8-15 green; bits 0-7 blue.

b

Int b()

The blue component from 0 to 255.

black

const static Color black := Color.make(0)

Constant for 0x00_00_00

blue

const static Color blue := Color.make(255)

Constant for 0x00_00_ff

darkGray

const static Color darkGray := Color.make(11119017)

Constant for 0xa9_a9_a9

darker

Color darker(Float percentage := 0.2f)

Get a color which is a dark shade of this color. This decreases the brightness by the given percentage which is a float between 0.0 and 1.0.

equals

virtual override Bool equals(Obj? that)

Equality is based on argb.

fromArgb

static Int fromArgb(Int a, Int r, Int g, Int b)

fromStr

static Color? fromStr(Str s, Bool checked := true)

Parse color from string (see toStr). If invalid and checked is true then throw ParseErr otherwise return null. The following formats are supported:

  • #AARRGGBB
  • #RRGGBB
  • #RGB

Examples:

Color.fromStr("#8A0")
Color.fromStr("#88AA00")
Color.fromStr("#d088aa00")
g

Int g()

The green component from 0 to 255.

getA

static Int getA(Int argb)

static utilit

getB

static Int getB(Int argb)

getG

static Int getG(Int argb)

getR

static Int getR(Int argb)

gray

const static Color gray := Color.make(8421504)

Constant for 0x80_80_80

green

const static Color green := Color.make(65280)

Constant for 0x00_ff_00

h

Float h()

Hue as a float between 0.0 and 360.0 of the HSV model (hue, saturation, value), also known as HSB (hue, saturation, brightness). Also see makeHsv, s, v.

hash

virtual override Int hash()

Return argb as the hash code.

lighter

Color lighter(Float percentage := 0.2f)

Get a color which is a lighter shade of this color. This increases the brightness by the given percentage which is a float between 0.0 and 1.0.

make

new make(Int argb := 0, Bool hasAlpha := false)

Make a new instance with the ARGB components masked together: bits 31-24 alpha; bits 16-23 red; bits 8-15 green; bits 0-7 blue. If hasAlpha is false, then we assume the alpha bits are 0xFF.

makeArgb

static Color makeArgb(Int a, Int r, Int g, Int b)

Make a new instance with the ARGB individual components as integers between 0 and 255.

makeHsv

static Color makeHsv(Float h, Float s, Float v)

Construct a color using HSV model (hue, saturation, value), also known as HSB (hue, saturation, brightness):

  • hue as 0.0 to 360.0
  • saturation as 0.0 to 1.0
  • value (or brightness) as 0.0 to 1.0 Also see h, s, v.
makeRgb

static Color makeRgb(Int r, Int g, Int b)

Make a new instance with the RGB individual components as integers between 0 and 255.

orange

const static Color orange := Color.make(16753920)

Constant for 0xff_a5_00

purple

const static Color purple := Color.make(8388736)

Constant for 0x80_00_80

r

Int r()

The red component from 0 to 255.

red

const static Color red := Color.make(16711680)

Constant for 0xff_00_00

rgb

Int rgb()

Get the RGB bitmask without the alpha bits.

s

Float s()

Saturation as a float between 0.0 and 1.0 of the HSV model (hue, saturation, value), also known as HSB (hue, saturation, brightness). Also see makeHsv, h, v.

toCss

Str toCss()

To a valid CSS color string.

toStr

virtual override Str toStr()

If the alpha component is 255, then format as "#RRGGBB" hex string, otherwise format as "#AARRGGBB" hex string.

v

Float v()

Value or brightness as a float between 0.0 and 1.0 of the HSV model (hue, saturation, value), also known as HSB (hue, saturation, brightness). Also see makeHsv, h, s.

white

const static Color white := Color.make(16777215)

Constant for 0xff_ff_ff

yellow

const static Color yellow := Color.make(16776960)

Constant for 0xff_ff_00