Color
#struct ColorA colour: sRGB channels from 0 to 1, an alpha, and an optional dark variant made by light dark. Channels may be below 0 or above 1 for colours outside sRGB.
| Name | Type | Description |
|---|---|---|
r | f64 = 0 | The red channel, 0 to 1 inside sRGB. |
g | f64 = 0 | The green channel, 0 to 1 inside sRGB. |
b | f64 = 0 | The blue channel, 0 to 1 inside sRGB. |
a | f64 = 1 | The alpha, from 0 (transparent) to 1 (opaque), not premultiplied. |
current | bool = false | True for current, the text colour of the element; the channels are then unused. |
has_dark | bool = false | True when the colour has a dark variant, as made by light dark(a, b) or LightDark. |
dark_r | f64 = 0 | The red channel of the dark variant. Read the dark variant with Dark instead of these fields. |
dark_g | f64 = 0 | The green channel of the dark variant. |
dark_b | f64 = 0 | The blue channel of the dark variant. |
dark_a | f64 = 1 | The alpha of the dark variant. |
dark_current | bool = false | True when the dark variant is current. |
import color
func main:
c := color.Rgba(51, 102, 170, 0.5)
println "r", c.r, "g", c.g, "b", c.b, "a", c.a, "current", c.current
wide := color.New(1.093, -0.227, -0.15, 1.0)
println "wide gamut red keeps channels outside 0 to 1:", wide.r, wide.g
println "argb", color.Argb(c), "back", color.Css(color.FromArgb(color.Argb(c)))
println "argb clamps", color.Argb(wide)
endr 0.2 g 0.4 b 0.6666666666666666 a 0.5 current false wide gamut red keeps channels outside 0 to 1: 1.093 -0.227 argb 2150852266 back #3366aa80 argb clamps 4294901760