Skip to content

Commit 24d0434

Browse files
committed
add new color primitives doc
1 parent d9c01fd commit 24d0434

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

content/runal.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,33 @@ Ends the program execution. It also quits the JavaScript runtime.
370370
371371
### Colors
372372
373-
For every color arguments and properties (see [Draw](#draw), you can set 2 types of color values:
373+
For every color arguments and properties (see [Draw](#draw), you can set 3 types of color values:
374374
- **hexadecimal** (_ex: `#000000`_): the hexadecimal color code
375375
- **ANSI 256** (_between 0 and 255_): one of the [256 ANSI colors](https://www.ditig.com/256-colors-cheat-sheet)
376+
- **CSS colors** (_ex: `fuchsia`_): one of the [css colors](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/named-color)
377+
378+
In addition, you can use the following primitives that allows you to work with RGB, HSL and HSV color spaces.
379+
380+
#### c.colorRGB(r, g, b) <sub>since v0.10.0</sub>
381+
Returns a hex color from R, G, B values. All 3 values are range between 0 and 255.
382+
383+
```js
384+
c.strokeFg(c.colorRGB(0, 0, 255));
385+
```
386+
387+
#### c.colorHSL(h, s, l) <sub>since v0.10.0</sub>
388+
Returns a hex color from H (range 0 to 360), S (range 0 to 100), L (range 0 to 100) values.
389+
390+
```js
391+
c.strokeFg(c.colorHSL(160, 100, 50));
392+
```
393+
394+
#### c.colorHSV(h, s, v) <sub>since v0.10.0</sub>
395+
Returns a hex color from H (range 0 to 360), S (range 0 to 100), V (range 0 to 100) values.
396+
397+
```js
398+
c.strokeFg(c.colorHSL(50, 55, 100));
399+
```
376400
377401
<hr class="separator"/>
378402

0 commit comments

Comments
 (0)