Handbook
Glossary
>rgba ( color -- rgba )
Colors
Prev:
<rgba> ( red green blue alpha -- rgba )
Next:
>rgba-components ( object -- r g b a )
Vocabulary
colors
Inputs
color
a
color
Outputs
rgba
a
rgba
Generic word contract
Converts a color to an RGBA color.
Definition
IN:
colors
GENERIC:
>rgba
( color -- rgba )
Methods
USING:
colors
colors.lab
colors.lch
;
M:
LCHab
>rgba
>laba
>rgba
;
USING:
colors
colors.lch
colors.luv
;
M:
LCHuv
>rgba
>luva
>rgba
;
USING:
accessors
colors
colors.cmyk
kernel
math
math.order
;
M:
cmyka
>rgba
[
[
cyan>>
]
[
black>>
]
bi
+
]
[
[
magenta>>
]
[
black>>
]
bi
+
]
[
[
yellow>>
]
[
black>>
]
bi
+
]
tri
[
1.0
min
1.0
swap
-
]
tri@
1.0
<rgba>
;
inline
USING:
accessors
colors
colors.gray
kernel
;
M:
gray
>rgba
[
gray>>
dup
dup
]
[
alpha>>
]
bi
<rgba>
;
inline
USING:
accessors
colors
colors.hsl
colors.hsl.private
combinators
kernel
locals.backend
math
;
M:
hsla
>rgba
{
[
hue>>
]
[
saturation>>
]
[
lightness>>
]
[
alpha>>
]
}
cleave
[
3
load-locals
-1
get-local
zero?
0
get-local
[
load-local
0
get-local
0
get-local
0
get-local
1
drop-locals
]
curry
0
get-local
-1
get-local
-2
get-local
[
3
load-locals
-2
get-local
0.5
<
-2
get-local
-1
get-local
[
2
load-locals
-1
get-local
0
get-local
1
+
*
2
drop-locals
]
curry
curry
-2
get-local
-1
get-local
[
2
load-locals
-1
get-local
0
get-local
+
-1
get-local
0
get-local
*
-
2
drop-locals
]
curry
curry
if
load-local
-3
get-local
2
*
0
get-local
-
load-local
0
get-local
-1
get-local
-2
get-local
1/3
+
value
0
get-local
-1
get-local
-2
get-local
value
0
get-local
-1
get-local
-2
get-local
1/3
-
value
5
drop-locals
]
curry
curry
curry
if
3
drop-locals
]
dip
<rgba>
;
inline
USING:
accessors
colors
colors.hsv
colors.hsv.private
combinators
kernel
;
M:
hsva
>rgba
[
dup
Hi
{
{
0
[
[
value>>
]
[
t
]
[
p
]
tri
]
}
{
1
[
[
q
]
[
value>>
]
[
p
]
tri
]
}
{
2
[
[
p
]
[
value>>
]
[
t
]
tri
]
}
{
3
[
[
p
]
[
q
]
[
value>>
]
tri
]
}
{
4
[
[
t
]
[
p
]
[
value>>
]
tri
]
}
{
5
[
[
value>>
]
[
p
]
[
q
]
tri
]
}
}
case
]
[
alpha>>
]
bi
<rgba>
;
inline
USING:
accessors
colors
colors.gray
colors.hsl
colors.hwb
kernel
locals.backend
math
;
M:
hwba
>rgba
[
hue>>
]
keep
[
whiteness>>
]
keep
[
blackness>>
]
keep
[
alpha>>
]
keep
drop
4
load-locals
-2
get-local
-1
get-local
+
load-local
0
get-local
1
>=
-3
get-local
0
get-local
-1
get-local
[
3
load-locals
-2
get-local
-1
get-local
/
0
get-local
<gray>
3
drop-locals
]
curry
curry
curry
-4
get-local
-1
get-local
0
get-local
-3
get-local
[
4
load-locals
-3
get-local
1.0 0.5 -2
get-local
<hsla>
>rgba-components
-1
get-local
0
get-local
[
2
load-locals
-1
get-local
0
get-local
[
2
load-locals
1 -1
get-local
-
*
0
get-local
+
2
drop-locals
]
curry
curry
tri@
2
drop-locals
]
curry
curry
dip
<rgba>
4
drop-locals
]
curry
curry
curry
curry
if
5
drop-locals
;
inline
USING:
colors
colors.lab
colors.xyz
;
M:
laba
>rgba
>xyza
>rgba
;
USING:
colors
colors.luv
colors.xyz
;
M:
luva
>rgba
>xyza
>rgba
;
USING:
accessors
colors
;
M:
parsed-color
>rgba
value>>
>rgba
;
USING:
colors
;
M:
rgba
>rgba
;
inline
USING:
accessors
colors
colors.ryb
colors.ryb.private
kernel
;
M:
ryba
>rgba
[
[
red>>
]
[
yellow>>
]
[
blue>>
]
tri
[
ryb>rgb
]
normalized
]
[
alpha>>
]
bi
<rgba>
;
USING:
colors
colors.xyy
colors.xyz
;
M:
xyYa
>rgba
>xyza
>rgba
;
USING:
accessors
colors
colors.xyz
colors.xyz.private
kernel
locals.backend
math
math.order
;
M:
xyza
>rgba
[
[
x>>
]
[
y>>
]
[
z>>
]
tri
3
load-locals
-2
get-local
3.2404542
*
-1
get-local
-1.5371385
*
0
get-local
-0.4985314
*
+
+
-2
get-local
-0.969266
*
-1
get-local
1.8760108
*
0
get-local
0.041556
*
+
+
-2
get-local
0.0556434
*
-1
get-local
-0.2040259
*
0
get-local
1.0572252
*
+
+
[
srgb-compand
0.0 1.0
clamp
]
tri@
3
drop-locals
]
[
alpha>>
]
bi
<rgba>
;
USING:
accessors
colors
colors.yiq
combinators
kernel
math
math.order
;
M:
yiqa
>rgba
{
[
y>>
]
[
in-phase>>
]
[
quadrature>>
]
[
alpha>>
]
}
cleave
[
[
[
0.9468822170900693
*
]
[
0.6235565819861433
*
]
bi*
+
+
]
[
[
0.27478764629897834
*
]
[
0.6356910791873801
*
]
bi*
+
-
]
[
[
1.1085450346420322
*
]
[
1.7090069284064666
*
]
bi*
-
-
]
3tri
[
0.0 1.0
clamp
]
tri@
]
dip
<rgba>
;
inline
USING:
accessors
colors
colors.yuv
colors.yuv.private
combinators
kernel
locals.backend
math
math.order
;
M:
yuva
>rgba
{
[
y>>
]
[
u>>
]
[
v>>
]
[
alpha>>
]
}
cleave
[
3
load-locals
-2
get-local
1
Wr
-
Vmax
/
0
get-local
*
+
-2
get-local
Wb
1
Wb
-
*
Umax
Wg
*
/
neg
-1
get-local
*
Wr
1
Wr
-
*
Vmax
Wg
*
/
neg
0
get-local
*
+
+
-2
get-local
1
Wb
-
Umax
/
-1
get-local
*
+
[
0.0 1.0
clamp
]
tri@
3
drop-locals
]
dip
<rgba>
;
inline