const class graphics::Color
sys::Obj graphics::Color : graphics::Paint
@Js@Serializable { simple=true }
Models an CSS4 RGB color with alpha
- a
-
const Float aThe alpha component from 0.0 to 1.0
- asColorPaint
-
virtual override Color asColorPaint()Return this
- b
-
Int b()The blue component from 0 to 255.
- black
-
const static Color black := Color.make(0, 1.0)Black is #000
- 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.
- desaturate
-
Color desaturate(Float percentage := 0.2f)Convenience for
saturate(-percentage). - equals
-
virtual override Bool equals(Obj? that)Equality
- fromStr
-
static new fromStr(Str s, Bool checked := true)Parse color from CSS 4 string. If invalid and checked is true then throw ParseErr otherwise return null. The following formats are supported:
- CSS keyword color
- #RRGGBB
- #RRGGBBAA
- #RGB
- #RGBA
- rgb(r, g b)
- rgba(r, g, b, a)
- hsl(h, s, l)
- hsla(h, s, l, a)
Functional notation works with comma or space separated arguments.
Examples:
Color.fromStr("red") Color.fromStr("#8A0") Color.fromStr("#88AA00") Color.fromStr("rgba(255, 0, 0, 0.3)") Color.fromStr("rgb(100% 0% 0% 25%)") - g
-
Int g()The green component from 0 to 255.
- h
-
Float h()Hue as a float between 0.0 and 360.0 of the HSL model (hue, saturation, lightness). Also see
makeHsl,s,l. - hash
-
virtual override Int hash()Return the hash code.
- interpolateHsl
-
static Color interpolateHsl(Color a, Color b, Float t)Interpolate between a and b where t is 0.0 to 1.0 using HSL color model.
- interpolateRgb
-
static Color interpolateRgb(Color a, Color b, Float t)Interpolate between a and b where t is 0.0 to 1.0 using RGB color model.
- isColorPaint
-
virtual override Bool isColorPaint()Always return true
- isTransparent
-
Bool isTransparent()Return if
ais zero, fully transparent - l
-
Float l()Lightness (brightness) as a float between 0.0 and 1.0 of the HSL model (hue, saturation, lightness). Also see
makeHsl,h,s. - 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 rgb := 0, Float a := 1.0f)Make a new instance with the RGB components masked together: bits 16-23 red; bits 8-15 green; bits 0-7 blue. Alpha should be a float between 1.0 and 0.0.
- makeHsl
-
static Color makeHsl(Float h, Float s, Float l, Float a := 1.0f)Construct a color using HSL model (hue, saturation, lightness):
- makeRgb
-
static Color makeRgb(Int r, Int g, Int b, Float a := 1.0f)Make a new instance with the RGB individual components as integers between 0 and 255 and alpha as float between 1.0 and 0.0.
- opacity
-
Color opacity(Float opacity := 1.0f)Adjust the opacity of this color and return new instance, where
opacityis between 0.0 and 1.0. - r
-
Int r()The red component from 0 to 255.
- rgb
-
const Int rgbThe RGB components masked together: bits 16-23 red; bits 8-15 green; bits 0-7 blue.
- s
-
Float s()Saturation as a float between 0.0 and 1.0 of the HSL model (hue, saturation, lightness). Also see
makeHsl,h,l. - saturate
-
Color saturate(Float percentage := 0.2f)Adjust saturation as percentage between -1..1.
- toHexStr
-
Str toHexStr()Format as #RGB, #RRGGBB or #RRGGBBAA syntax
- toStr
-
virtual override Str toStr()If the alpha component is 1.0, then format as
"#RRGGBB"hex string, otherwise format as"rbga()"notation. - transparent
-
const static Color transparent := Color.make(0, 0.0)Transparent constant with opacity set to zero
- white
-
const static Color white := Color.make(16777215, 1.0)White is #FFF