1# pastel
2
3[![Build Status](https://img.shields.io/github/workflow/status/sharkdp/pastel/CICD?style=flat-square)](https://github.com/sharkdp/pastel/actions)
4[![](https://img.shields.io/github/v/release/sharkdp/pastel?colorB=d7a400&style=flat-square)](https://github.com/sharkdp/pastel/releases)
5[![](https://img.shields.io/crates/l/pastel.svg?colorB=ff7155&style=flat-square)](https://crates.io/crates/pastel)
6[![](https://img.shields.io/crates/v/pastel.svg?colorB=ff69b4&style=flat-square)](https://crates.io/crates/pastel)
7
8
9`pastel` is a command-line tool to generate, analyze, convert and manipulate colors. It supports many different color formats and color spaces like RGB (sRGB), HSL, CIELAB, CIELCh as well as ANSI 8-bit and 24-bit representations.
10
11## In action
12
13![pastel in action](doc/pastel.gif)
14
15## Tutorial
16
17### Getting help
18
19`pastel` provides a number of commands like `saturate`, `mix` or `paint`. To see a complete list, you can simply run
20``` bash
21pastel
22```
23To get more information about a specific subcommand (say `mix`), you can call `pastel mix -h` or `pastel help mix`.
24
25### Composition
26
27Many `pastel` commands can be composed by piping the output of one command to another, for example:
28``` bash
29pastel random | pastel mix red | pastel lighten 0.2 | pastel format hex
30```
31
32### Specifying colors
33
34Colors can be specified in many different formats:
35```
36lightslategray
37'#778899'
38778899
39789
40'rgb(119, 136, 153)'
41'119,136,153'
42'hsl(210, 14.3%, 53.3%)'
43```
44
45Colors can be passed as positional arguments, for example:
46```
47pastel lighten 0.2 orchid orange lawngreen
48```
49They can also be read from standard input. So this is equivalent:
50```
51printf "%s\n" orchid orange lawngreen | pastel lighten 0.2
52```
53You can also explicitly specify which colors you want to read from the input. For example, this mixes `red` (which is read from STDIN) with `blue` (which is passed on the command line):
54```
55pastel color red | pastel mix - blue
56```
57
58### Use cases and demo
59
60#### Converting colors from one format to another
61
62``` bash
63pastel format hsl ff8000
64```
65
66#### Show and analyze colors on the terminal
67
68``` bash
69pastel color "rgb(255,50,127)"
70
71pastel color 556270 4ecdc4 c7f484 ff6b6b c44d58
72```
73
74#### Pick a color from somewhere on the screen
75
76``` bash
77pastel pick
78```
79
80#### Generate a set of N visually distinct colors
81
82```
83pastel distinct 8
84```
85
86#### Get a list of all X11 / CSS color names
87
88``` bash
89pastel list
90```
91
92#### Name a given color
93
94``` bash
95pastel format name 44cc11
96```
97
98#### Print colorized text from a shell script
99
100``` bash
101bg="hotpink"
102fg="$(pastel textcolor "$bg")"
103
104pastel paint "$fg" --on "$bg" "well readable text"
105```
106
107``` bash
108pastel paint -n black --on red --bold "   ERROR!   "
109echo " A serious error"
110
111pastel paint -n black --on yellow --bold "  WARNING!  "
112echo " A warning message"
113
114pastel paint -n black --on limegreen --bold "    INFO    "
115echo -n " Informational message with a "
116echo -n "highlighted" | pastel paint -n default --underline
117echo " word"
118```
119
120## Installation
121
122### On Debian-based systems
123
124You can download the latest Debian package from the [release page](https://github.com/sharkdp/pastel/releases) and install it via `dpkg`:
125``` bash
126wget "https://github.com/sharkdp/pastel/releases/download/v0.8.1/pastel_0.8.1_amd64.deb"
127sudo dpkg -i pastel_0.8.1_amd64.deb
128```
129
130### On Arch Linux
131
132You can install `pastel` from the [AUR package](https://aur.archlinux.org/packages/pastel/):
133```
134yay -S pastel
135```
136
137### On Nix
138
139You can install `pastel` from the [Nix package](https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/misc/pastel/default.nix):
140```
141nix-env --install pastel
142```
143
144### On MacOS
145
146You can install `pastel` via [Homebrew](https://formulae.brew.sh/formula/pastel)
147```
148brew install pastel
149```
150
151### Via snap package
152
153[Get it from the Snap Store](https://snapcraft.io/pastel):
154```
155sudo snap install pastel
156```
157
158### On NetBSD
159Using the package manager:
160```
161pkgin install pastel
162```
163
164From source:
165```
166cd /usr/pkgsrc/graphics/pastel
167make install
168```
169
170### On other distributions
171
172Check out the [release page](https://github.com/sharkdp/pastel/releases) for binary builds.
173
174### Via cargo (source)
175
176If you do not have cargo, install using [rust's installation documentation](https://doc.rust-lang.org/book/ch01-01-installation.html).
177
178If you have Rust 1.43 or higher, you can install `pastel` from source via `cargo`:
179```
180cargo install pastel
181```
182
183Alternatively, you can install `pastel` directly from this repository by using
184```
185git clone https://github.com/sharkdp/pastel
186cargo install --path ./pastel
187```
188
189## Resources
190
191Interesting Wikipedia pages:
192
193* [Color difference](https://en.wikipedia.org/wiki/Color_difference)
194* [CIE 1931 color space](https://en.wikipedia.org/wiki/CIE_1931_color_space)
195* [CIELAB color space](https://en.wikipedia.org/wiki/CIELAB_color_space)
196* [Line of purples](https://en.wikipedia.org/wiki/Line_of_purples)
197* [Impossible color](https://en.wikipedia.org/wiki/Impossible_color)
198* [sRGB](https://en.wikipedia.org/wiki/SRGB)
199* [Color theory](https://en.wikipedia.org/wiki/Color_theory)
200* [Eigengrau](https://en.wikipedia.org/wiki/Eigengrau)
201
202Color names:
203
204* [XKCD Color Survey Results](https://blog.xkcd.com/2010/05/03/color-survey-results/)
205* [Peachpuffs and Lemonchiffons - talk about named colors](https://www.youtube.com/watch?v=HmStJQzclHc)
206* [List of CSS color keywords](https://www.w3.org/TR/SVG11/types.html#ColorKeywords)
207
208Maximally distinct colors:
209
210* [How to automatically generate N "distinct" colors?](https://stackoverflow.com/q/470690/704831)
211* [Publication on two algorithms to generate (maximally) distinct colors](http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.65.2790)
212
213Other articles and videos:
214
215* [Color Matching](https://www.youtube.com/watch?v=82ItpxqPP4I)
216* [Introduction to color spaces](https://ciechanow.ski/color-spaces/)
217
218## License
219
220Licensed under either of
221
222 * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
223 * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
224
225at your option.
226