struct StumpyCore::RGBA
- StumpyCore::RGBA
- Struct
- Value
- Object
Overview
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.
Defined in:
stumpy_core/rgba.crstumpy_core/rgba/css_constants.cr
stumpy_core/rgba/from_grayscale.cr
stumpy_core/rgba/from_hex.cr
stumpy_core/rgba/from_hsl_hsv.cr
stumpy_core/rgba/from_relative.cr
stumpy_core/rgba/from_rgba.cr
stumpy_core/rgba/mixing.cr
Constant Summary
-
ALICEBLUE =
RGBA.from_hex("#F0F8FF")
-
ANTIQUEWHITE =
RGBA.from_hex("#FAEBD7")
-
AQUA =
RGBA.from_hex("#00FFFF")
-
AQUAMARINE =
RGBA.from_hex("#7FFFD4")
-
AZURE =
RGBA.from_hex("#F0FFFF")
-
BEIGE =
RGBA.from_hex("#F5F5DC")
-
BISQUE =
RGBA.from_hex("#FFE4C4")
-
BLACK =
RGBA.from_hex("#000000")
-
BLANCHEDALMOND =
RGBA.from_hex("#FFEBCD")
-
BLUE =
RGBA.from_hex("#0000FF")
-
BLUEVIOLET =
RGBA.from_hex("#8A2BE2")
-
BROWN =
RGBA.from_hex("#A52A2A")
-
BURLYWOOD =
RGBA.from_hex("#DEB887")
-
CADETBLUE =
RGBA.from_hex("#5F9EA0")
-
CHARTREUSE =
RGBA.from_hex("#7FFF00")
-
CHOCOLATE =
RGBA.from_hex("#D2691E")
-
CORAL =
RGBA.from_hex("#FF7F50")
-
CORNFLOWERBLUE =
RGBA.from_hex("#6495ED")
-
CORNSILK =
RGBA.from_hex("#FFF8DC")
-
CRIMSON =
RGBA.from_hex("#DC143C")
-
CYAN =
RGBA.from_hex("#00FFFF")
-
DARKBLUE =
RGBA.from_hex("#00008B")
-
DARKCYAN =
RGBA.from_hex("#008B8B")
-
DARKGOLDENROD =
RGBA.from_hex("#B8860B")
-
DARKGRAY =
RGBA.from_hex("#A9A9A9")
-
DARKGREEN =
RGBA.from_hex("#006400")
-
DARKGREY =
RGBA.from_hex("#A9A9A9")
-
DARKKHAKI =
RGBA.from_hex("#BDB76B")
-
DARKMAGENTA =
RGBA.from_hex("#8B008B")
-
DARKOLIVEGREEN =
RGBA.from_hex("#556B2F")
-
DARKORANGE =
RGBA.from_hex("#FF8C00")
-
DARKORCHID =
RGBA.from_hex("#9932CC")
-
DARKRED =
RGBA.from_hex("#8B0000")
-
DARKSALMON =
RGBA.from_hex("#E9967A")
-
DARKSEAGREEN =
RGBA.from_hex("#8FBC8F")
-
DARKSLATEBLUE =
RGBA.from_hex("#483D8B")
-
DARKSLATEGRAY =
RGBA.from_hex("#2F4F4F")
-
DARKSLATEGREY =
RGBA.from_hex("#2F4F4F")
-
DARKTURQUOISE =
RGBA.from_hex("#00CED1")
-
DARKVIOLET =
RGBA.from_hex("#9400D3")
-
DEEPPINK =
RGBA.from_hex("#FF1493")
-
DEEPSKYBLUE =
RGBA.from_hex("#00BFFF")
-
DIMGRAY =
RGBA.from_hex("#696969")
-
DIMGREY =
RGBA.from_hex("#696969")
-
DODGERBLUE =
RGBA.from_hex("#1E90FF")
-
FIREBRICK =
RGBA.from_hex("#B22222")
-
FLORALWHITE =
RGBA.from_hex("#FFFAF0")
-
FORESTGREEN =
RGBA.from_hex("#228B22")
-
FUCHSIA =
RGBA.from_hex("#FF00FF")
-
GAINSBORO =
RGBA.from_hex("#DCDCDC")
-
GHOSTWHITE =
RGBA.from_hex("#F8F8FF")
-
GOLD =
RGBA.from_hex("#FFD700")
-
GOLDENROD =
RGBA.from_hex("#DAA520")
-
GRAY =
RGBA.from_hex("#808080")
-
GREEN =
RGBA.from_hex("#008000")
-
GREENYELLOW =
RGBA.from_hex("#ADFF2F")
-
GREY =
RGBA.from_hex("#808080")
-
HONEYDEW =
RGBA.from_hex("#F0FFF0")
-
HOTPINK =
RGBA.from_hex("#FF69B4")
-
INDIANRED =
RGBA.from_hex("#CD5C5C")
-
INDIGO =
RGBA.from_hex("#4B0082")
-
IVORY =
RGBA.from_hex("#FFFFF0")
-
KHAKI =
RGBA.from_hex("#F0E68C")
-
LAVENDER =
RGBA.from_hex("#E6E6FA")
-
LAVENDERBLUSH =
RGBA.from_hex("#FFF0F5")
-
LAWNGREEN =
RGBA.from_hex("#7CFC00")
-
LEMONCHIFFON =
RGBA.from_hex("#FFFACD")
-
LIGHTBLUE =
RGBA.from_hex("#ADD8E6")
-
LIGHTCORAL =
RGBA.from_hex("#F08080")
-
LIGHTCYAN =
RGBA.from_hex("#E0FFFF")
-
LIGHTGOLDENRODYELLOW =
RGBA.from_hex("#FAFAD2")
-
LIGHTGRAY =
RGBA.from_hex("#D3D3D3")
-
LIGHTGREEN =
RGBA.from_hex("#90EE90")
-
LIGHTGREY =
RGBA.from_hex("#D3D3D3")
-
LIGHTPINK =
RGBA.from_hex("#FFB6C1")
-
LIGHTSALMON =
RGBA.from_hex("#FFA07A")
-
LIGHTSEAGREEN =
RGBA.from_hex("#20B2AA")
-
LIGHTSKYBLUE =
RGBA.from_hex("#87CEFA")
-
LIGHTSLATEGRAY =
RGBA.from_hex("#778899")
-
LIGHTSLATEGREY =
RGBA.from_hex("#778899")
-
LIGHTSTEELBLUE =
RGBA.from_hex("#B0C4DE")
-
LIGHTYELLOW =
RGBA.from_hex("#FFFFE0")
-
LIME =
RGBA.from_hex("#00FF00")
-
LIMEGREEN =
RGBA.from_hex("#32CD32")
-
LINEN =
RGBA.from_hex("#FAF0E6")
-
MAGENTA =
RGBA.from_hex("#FF00FF")
-
MAROON =
RGBA.from_hex("#800000")
-
MEDIUMAQUAMARINE =
RGBA.from_hex("#66CDAA")
-
MEDIUMBLUE =
RGBA.from_hex("#0000CD")
-
MEDIUMORCHID =
RGBA.from_hex("#BA55D3")
-
MEDIUMPURPLE =
RGBA.from_hex("#9370DB")
-
MEDIUMSEAGREEN =
RGBA.from_hex("#3CB371")
-
MEDIUMSLATEBLUE =
RGBA.from_hex("#7B68EE")
-
MEDIUMSPRINGGREEN =
RGBA.from_hex("#00FA9A")
-
MEDIUMTURQUOISE =
RGBA.from_hex("#48D1CC")
-
MEDIUMVIOLETRED =
RGBA.from_hex("#C71585")
-
MIDNIGHTBLUE =
RGBA.from_hex("#191970")
-
MINTCREAM =
RGBA.from_hex("#F5FFFA")
-
MISTYROSE =
RGBA.from_hex("#FFE4E1")
-
MOCCASIN =
RGBA.from_hex("#FFE4B5")
-
NAVAJOWHITE =
RGBA.from_hex("#FFDEAD")
-
NAVY =
RGBA.from_hex("#000080")
-
OLDLACE =
RGBA.from_hex("#FDF5E6")
-
OLIVE =
RGBA.from_hex("#808000")
-
OLIVEDRAB =
RGBA.from_hex("#6B8E23")
-
ORANGE =
RGBA.from_hex("#FFA500")
-
ORANGERED =
RGBA.from_hex("#FF4500")
-
ORCHID =
RGBA.from_hex("#DA70D6")
-
PALEGOLDENROD =
RGBA.from_hex("#EEE8AA")
-
PALEGREEN =
RGBA.from_hex("#98FB98")
-
PALETURQUOISE =
RGBA.from_hex("#AFEEEE")
-
PALEVIOLETRED =
RGBA.from_hex("#DB7093")
-
PAPAYAWHIP =
RGBA.from_hex("#FFEFD5")
-
PEACHPUFF =
RGBA.from_hex("#FFDAB9")
-
PERU =
RGBA.from_hex("#CD853F")
-
PINK =
RGBA.from_hex("#FFC0CB")
-
PLUM =
RGBA.from_hex("#DDA0DD")
-
POWDERBLUE =
RGBA.from_hex("#B0E0E6")
-
PURPLE =
RGBA.from_hex("#800080")
-
REBECCAPURPLE =
RGBA.from_hex("#663399")
-
RED =
RGBA.from_hex("#FF0000")
-
ROSYBROWN =
RGBA.from_hex("#BC8F8F")
-
ROYALBLUE =
RGBA.from_hex("#4169E1")
-
SADDLEBROWN =
RGBA.from_hex("#8B4513")
-
SALMON =
RGBA.from_hex("#FA8072")
-
SANDYBROWN =
RGBA.from_hex("#F4A460")
-
SEAGREEN =
RGBA.from_hex("#2E8B57")
-
SEASHELL =
RGBA.from_hex("#FFF5EE")
-
SIENNA =
RGBA.from_hex("#A0522D")
-
SILVER =
RGBA.from_hex("#C0C0C0")
-
SKYBLUE =
RGBA.from_hex("#87CEEB")
-
SLATEBLUE =
RGBA.from_hex("#6A5ACD")
-
SLATEGRAY =
RGBA.from_hex("#708090")
-
SLATEGREY =
RGBA.from_hex("#708090")
-
SNOW =
RGBA.from_hex("#FFFAFA")
-
SPRINGGREEN =
RGBA.from_hex("#00FF7F")
-
STEELBLUE =
RGBA.from_hex("#4682B4")
-
TAN =
RGBA.from_hex("#D2B48C")
-
TEAL =
RGBA.from_hex("#008080")
-
THISTLE =
RGBA.from_hex("#D8BFD8")
-
TOMATO =
RGBA.from_hex("#FF6347")
-
TURQUOISE =
RGBA.from_hex("#40E0D0")
-
VIOLET =
RGBA.from_hex("#EE82EE")
-
WHEAT =
RGBA.from_hex("#F5DEB3")
-
WHITE =
RGBA.from_hex("#FFFFFF")
-
WHITESMOKE =
RGBA.from_hex("#F5F5F5")
-
YELLOW =
RGBA.from_hex("#FFFF00")
-
YELLOWGREEN =
RGBA.from_hex("#9ACD32")
Constructors
-
.new(r : UInt16, g : UInt16, b : UInt16, a : UInt16 = UInt16::MAX)
Create a RGBA value from 16bit (
UInt16
) values for red, green, blue and optionally alpha. -
.new(gray : UInt16, a : UInt16 = UInt16::MAX)
Create a RGBA value from 16bit (
UInt16
) values for grayscale (gray = red = green = blue) and optionally alpha.
Class Method Summary
-
.from_gray_n(value, n)
Create a
RGBA
struct from a n-bit grayscale value -
.from_graya_n(g, a, n)
Create a
RGBA
struct from n-bit grayscale + alpha values -
.from_graya_n(values, n)
Create a
RGBA
struct from a tuple of n-bit grayscale + alpha values -
.from_hex(hex : String)
Create a
RGBA
struct from a hex color string. -
.from_hsl(h, s, l)
Same as
.from_hsla(h, s, l, a)
, but without the alpha component. -
.from_hsl(values)
Same as
.from_hsl(h, s, l)
, but from a tuple{h, s, l}
. -
.from_hsla(h, s, l, alpha)
Create a RGBA struct from HLS values and an alpha component.
-
.from_hsla(values)
Same as
.from_hsla(h, s, l, a)
, but from a tuple{h, s, l, a}
. -
.from_hsv(h, s, v)
Same as
.from_hsva(h, s, v, a)
, but without the alpha component. -
.from_hsv(values)
Same as
.from_hsl(h, s, l)
, but from a tuple{h, s, l}
. -
.from_hsva(h, s, v, alpha)
Create a RGBA struct from HLV values and an alpha component.
-
.from_hsva(values)
Same as
.from_hsva(h, s, v, a)
, but from a tuple{h, s, v, a}
. - .from_relative(r, g, b, a)
-
.from_relative(values)
Create a RGBA struct from a tuple of floats
{r, g, b, a}
, each ranging from0.0
to1.0
. -
.from_rgb(r, g, b)
Shorthand for
.from_rgb_n(r, g, b, 8)
-
.from_rgb(values)
Shorthand for
.from_rgb_n(values, 8)
-
.from_rgb8(r, g, b)
Shorthand for
.from_rgb_n(r, g, b, 8)
-
.from_rgb8(values)
Shorthand for
.from_rgb_n(values, 8)
-
.from_rgb_n(r, g, b, n)
Create a
RGBA
struct from n-bit red, green and blue values -
.from_rgb_n(values, n)
Create a
RGBA
struct from a tuple of n-bit red, green and blue values -
.from_rgba(r, g, b, a)
Shorthand for
.from_rgba_n(r, g, b, a, 8)
-
.from_rgba(values)
Shorthand for
.from_rgba_n(values, 8)
-
.from_rgba8(r, g, b, a)
Shorthand for
.from_rgba_n(r, g, b, a, 8)
-
.from_rgba8(values)
Shorthand for
.from_rgba_n(values, 8)
-
.from_rgba_n(r, g, b, a, n)
Create a
RGBA
struct from n-bit red, green, blue and alpha values -
.from_rgba_n(values, n)
Create a
RGBA
struct from a tuple of n-bit red, green, blue and alpha values
Instance Method Summary
- #a : UInt16
- #alpha : UInt16
- #b : UInt16
- #blue : UInt16
- #g : UInt16
- #green : UInt16
-
#mix(other, t)
Linear interpolation (mixing) of two colors.
-
#multiply(other : RGBA) : RGBA
Mix two colors by multiplying their values
-
#over(other : RGBA) : RGBA
Mix two colors by using Alhpa Compositing
- #r : UInt16
- #red : UInt16
-
#to_relative
Create a tuple
{r, g, b, a}
, each ranging from0.0
to1.0
from this color. -
#to_rgb8
Create a 8-bit
{r, g, b}
tuple, the alpha component is just omitted. -
#to_rgba
Create a 8-bit
{r, g, b, a}
tuple.
Constructor Detail
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 Method Detail
Create a RGBA
struct from a tuple of n-bit grayscale + alpha values
Same as .from_hsla(h, s, l, a)
, but without the alpha component.
(#a
defaults to 1.0
)
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_hsva(h, s, v, a)
, but without the alpha component.
(#a
defaults to 1.0
)
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
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%.
Create a RGBA
struct from a tuple of n-bit red, green and blue values
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 Method Detail
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