StumpyCore::RGBA
Inherits Struct < Value < Object
A RGBA is made up of four components:
red, green, blue and alpha,
each with a resolution of 16 bit.
All 148 Named CSS Colors are available as constants.
Constants
Constructors
Create a RGBA value
from 16bit (UInt16)
values for red, green, blue and
optionally alpha.
Alpha defaults to 100% opacity.
Create a RGBA value
from 16bit (UInt16)
values for grayscale (gray = red = green = blue)
and optionally alpha.
Alpha defaults to 100% opacity.
Class methods
Create a RGBA struct from a n-bit grayscale value
Create a RGBA struct from n-bit grayscale + alpha values
Create a RGBA struct from a tuple of n-bit grayscale + alpha values
Create a RGBA struct from a hex color string.
Formats:
- "#rgb"
- "#rrggbb"
- "#argb"
- "#aarrggbb"
Same as from_hsla(h, s, l, a), but without the alpha component.
(a defaults to 1.0)
Same as from_hsl(h, s, l), but from a tuple {h, s, l}.
Create a RGBA struct from HLS values and an alpha component.
Range of the values:
- __h__ue = 0..360
- __s__aturaiton = 0..100
- __l__ightness = 0..100
- __a__lpha = 0.0..1.0
Same as from_hsla(h, s, l, a), but from a tuple {h, s, l, a}.
Same as from_hsva(h, s, v, a), but without the alpha component.
(a defaults to 1.0)
Same as from_hsl(h, s, l), but from a tuple {h, s, l}.
Create a RGBA struct from HLV values and an alpha component.
Range of the values:
- __h__ue = 0..360
- __s__aturaiton = 0..100
- __v__value = 0..100
- __a__lpha = 0.0..1.0
Same as from_hsva(h, s, v, a), but from a tuple {h, s, v, a}.
Create a RGBA struct from
float values r, g, b, a
ranging from 0.0 to 1.0.
{1.0, 0.0, 0.0, 0.5} would be the color red
with an opacity of 50%.
Create a RGBA struct from a tuple of floats
{r, g, b, a}, each ranging from 0.0 to 1.0.
{1.0, 0.0, 0.0, 0.5} would be the color red
with an opacity of 50%.
Shorthand for from_rgb_n(r, g, b, 8)
Shorthand for from_rgb_n(values, 8)
Shorthand for from_rgb_n(r, g, b, 8)
Shorthand for from_rgb_n(values, 8)
Create a RGBA struct from n-bit red, green and blue values
Create a RGBA struct from a tuple of n-bit red, green and blue values
Shorthand for from_rgba_n(r, g, b, a, 8)
Shorthand for from_rgba_n(values, 8)
Shorthand for from_rgba_n(r, g, b, a, 8)
Shorthand for from_rgba_n(values, 8)
Create a RGBA struct from n-bit red, green, blue and alpha values
Create a RGBA struct from a tuple of n-bit
red, green, blue and alpha values
Instance methods
Linear interpolation
(mixing) of two colors.
t ranges from 0.0 to 1.0.
a.mix(b, 0.0) == a
a.mix(b, 1.0) == b
Mix two colors by multiplying their values
Mix two colors by using Alhpa Compositing
Create a tuple {r, g, b, a},
each ranging from 0.0 to 1.0
from this color.
Create a 8-bit {r, g, b} tuple,
the alpha component is just omitted.
Create a 8-bit {r, g, b, a} tuple.