Skip to content

Commit afe5800

Browse files
committed
Color: add help
1 parent bccd426 commit afe5800

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed

doc/vital/Color.txt

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
*vital/Color.txt* RGB/HSL/terminal code conversion library
2+
3+
Maintainer: tyru <[email protected]>
4+
5+
==============================================================================
6+
CONTENTS *Vital.Color-contents*
7+
8+
INTRODUCTION |Vital.Color-introduction|
9+
INTERFACE |Vital.Color-interface|
10+
FUNCTIONS |Vital.Color-functions|
11+
TODO |Vital.Color-todo|
12+
13+
==============================================================================
14+
INTRODUCTION *Vital.Color-introduction*
15+
16+
*Vital.Color* is a color conversion library between RGB/HSL/terminal code.
17+
18+
==============================================================================
19+
INTERFACE *Vital.Color-interface*
20+
21+
------------------------------------------------------------------------------
22+
FUNCTIONS *Vital.Color-functions*
23+
24+
parse({str}) *Vital.Color.parse()*
25+
Parses various color text formats and creates |Vital.Color-Color-object|.
26+
Supported format is:
27+
* Hex RGB format
28+
* e.g. `#FFF`
29+
* e.g. `#000000`
30+
* CSS RGB format
31+
* e.g. `rgb(100,100,100)`
32+
* CSS HSL format
33+
* e.g. `hsl(0,50%,100%)`
34+
* `%` is mandatory
35+
* Color name
36+
* See $VIMRUNTIME/rgb.txt for color names
37+
>
38+
let c1 = s:Color.parse('#012')
39+
let c2 = s:Color.parse('#c0ffee')
40+
let c3 = s:Color.parse('rgb(100,100,100)')
41+
let c4 = s:Color.parse('hsl(0,50%,100%)')
42+
let c5 = s:Color.parse('ForestGreen')
43+
<
44+
rgb({red}, {green}, {blue}) *Vital.Color.rgb()*
45+
Creates |Vital.Color-Color-object| with given parameters.
46+
>
47+
echo s:Color.rgb(0x00, 0x11, 0x22).as_rgb_hex() == '#001122'
48+
echo s:Color.rgb(0x00, 0x11, 0x22).as_rgb_str() == 'rgb(0,17,34)'
49+
echo s:Color.rgb(0x00, 0x11, 0x22).as_rgb() == [0.0, 17.0, 34.0]
50+
<
51+
hsl({red}, {green}, {blue}) *Vital.Color.hsl()*
52+
Creates |Vital.Color-Color-object| with given parameters.
53+
>
54+
echo s:Color.hsl(0, 50, 100).as_hsl_str() == 'hsl(0,50%,100%)'
55+
echo s:Color.hsl(0, 50, 100).as_hsl() == [0.0, 50.0, 100.0]
56+
<
57+
xterm({code}) *Vital.Color.xterm()*
58+
Creates |Vital.Color-Color-object| with given parameters.
59+
This converts color name to RGB values internally (so `.as_rgb()`,
60+
`.as_rgb_str()`, `.as_rgb_hex()` doesn't lose the precision).
61+
>
62+
echo s:Color.xterm(0).as_rgb_hex() == '#000000'
63+
echo s:Color.xterm(15).as_rgb_hex() == '#FFFFFF'
64+
<
65+
==============================================================================
66+
COLOR OBJECT *Vital.Color-Color-object*
67+
68+
*Vital.Color-Color.eq()*
69+
Color.eq({color})
70+
Returns |TRUE| if this object is equal to {color}.
71+
Returns |FALSE| otherwise.
72+
73+
*Vital.Color-Color.distance()*
74+
Color.distance({color})
75+
Returns the distance of 3D vector (r, g, b).
76+
77+
*Vital.Color-Color.as_rgb()*
78+
Color.as_rgb()
79+
Converts this object if necessary, and returns `[r, g, b]` value.
80+
r, g, b are |Float| values.
81+
82+
*Vital.Color-Color.as_rgb_str()*
83+
Color.as_rgb_str()
84+
Converts this object if necessary, and returns a string like
85+
`rgb({r},{g},{b})`. r, g, b are |Float| values.
86+
87+
*Vital.Color-Color.as_rgb_hex()*
88+
Color.as_rgb_hex()
89+
Converts this object if necessary, and returns a string like
90+
`#{r}{g}{b}` (e.g. `#000000`, always 7 digits).
91+
92+
*Vital.Color-Color.as_hsl()*
93+
Color.as_hsl()
94+
Converts this object if necessary, and returns `[h, s, l]` value.
95+
h, s, l are |Float| values.
96+
97+
*Vital.Color-Color.as_hsl_str()*
98+
Color.as_hsl_str()
99+
Converts this object if necessary, and returns a string like
100+
`hsl({h},{s}%,{l}%)`. h, s, l are |Float| values.
101+
102+
==============================================================================
103+
TODO *Vital.Color-todo*
104+
105+
- Add more terminal codes like Color.xterm()
106+
107+
==============================================================================
108+
vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl

0 commit comments

Comments
 (0)