const class gfx::Color

sys::Obj
  gfx::Color : gfx::Brush

@Js
@Serializable { simple=true }

Source

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

a

Int a()

Source

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

argb

const Int argb

Source

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

b

Int b()

Source

The blue component from 0 to 255.

black

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

Source

Constant for 0x00_00_00

blue

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

Source

Constant for 0x00_00_ff

darkGray

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

Source

Constant for 0xa9_a9_a9

darker

Color darker(Float percentage := 0.2f)

Source

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.

dispose

Void dispose()

Source

Free any operating system resources used by this color. Dispose is required if this color has been used in an operation such as FWT onPaint which allocated a system resource to represent this instance.

equals

virtual override Bool equals(Obj? that)

Source

Equality is based on argb.

fromStr

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

Source

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()

Source

The green component from 0 to 255.

gray

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

Source

Constant for 0x80_80_80

green

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

Source

Constant for 0x00_ff_00

h

Float h()

Source

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()

Source

Return argb as the hash code.

lighter

Color lighter(Float percentage := 0.2f)

Source

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)

Source

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)

Source

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)

Source

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)

Source

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

orange

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

Source

Constant for 0xff_a5_00

purple

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

Source

Constant for 0x80_00_80

r

Int r()

Source

The red component from 0 to 255.

red

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

Source

Constant for 0xff_00_00

rgb

Int rgb()

Source

Get the RGB bitmask without the alpha bits.

s

Float s()

Source

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()

Source

To a valid CSS color string.

toStr

virtual override Str toStr()

Source

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

v

Float v()

Source

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)

Source

Constant for 0xff_ff_ff

yellow

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

Source

Constant for 0xff_ff_00