sharkdp / pastel Goto Github PK
View Code? Open in Web Editor NEWA command-line tool to generate, analyze, convert and manipulate colors
License: Apache License 2.0
A command-line tool to generate, analyze, convert and manipulate colors
License: Apache License 2.0
pastel gradient -n 10 royalblue orchid
pastel gradient --colorspace lab royalblue orchid
Provide a way to:
pastel paint red "ERROR: ..."
pastel paint red --bold "ERROR: ..."
pastel paint black --on yellow "WARNING: ..."
pastel red | pastel lighten 0.2 | pastel paint - "ERROR: ..."
echo "$(pastel ansi salmon)colored text$(pastel ansi reset)"
hue
, chroma
, luminance
LCh
Lab
name
- format as closest matching X11 nameour current choice for orangered #ff4500
is not great :-/
e.g.:
pastel random -n 1000000 | pastel format hex
Check other sources for more "named" colors:
SandyBrown
? https://www.youtube.com/watch?v=HmStJQzclHc'b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'
... to force color output (e.g. -f
/--force-color
).
see
pastel random -s uniform_rgb -n $(insect '255*255*255') | pastel format hex | grep 000000
.. this should work even if we are in interactive mode.
To do things like:
pastel darken 0.2 red
# okay, let's compare it to the original color:
pastel darken 0.2 red | pastel show red -
echo red | pastel show
echo red | pastel mix RGB green
We distinguish 3 modes:
\x1b[38;5;167m
)\x1b[38;2;255;0;127m
)Note that we ignore the 16-color ANSI mode, as we can't really predict how the 16 colors look like.
We choose the mode in the following way:
--mode=24bit
or --mode=8bit
=> use the given mode.PASTEL_MODE=8bit
, use 8 bit modePASTEL_MODE==24bit
or COLORTERM==truecolor
or COLORTERM==24bit
=> use 24 bit modeFurther literature: https://gist.github.com/XVilka/8346728
Which computes contrast, color difference, etc.
in the interactive version, we could show a-colored text on a b-colored background. Also, show two color panels (like in pastel color
) directly next to each other.
To print the color in rgb(…)
, hsl(…)
, #rrggbb
etc format
pastel random -n 20 | pastel sort --by luminance
pastel list | pastel sort --by chroma
Also, add a --reverse
/-r
flag.
Think about whether we still need the --sort
option on pastel list
.
Using the similar_colors
function.
Basically like a "reactive" web page: choose a smaller output width if the terminal width is too small to display the full canvas width.
e.g.: print #RRGGBB
with red, green, and blue components
… otherwise, this does not work:
pastel show blue | pastel desaturate 1.0 | pastel saturate 1.0
In non-interactive mode, pastel
should simply print the color as #rrggbb
string in order to allow for things like this:
echo salmon | pastel darken 0.2 | pastel saturate 0.1
pastel darken 0.1 red | pastel mix RGB green | pastel saturate 0.1
See https://developer.mozilla.org/en-US/docs/Web/CSS/color_value for all details and test cases
#ff0000
)#f00
)rgb(0, 0, 255)
rgb(0%, 50%, 100%)
hsl(120, 100%, 75%)
hsl(…,…,…)
in all variations
°
signrebeccapurple
)optional:
rgb(R G B[ A])
- only a draftgray(0.3)
gray(30%)
rad
instead of degreesturn
s instead of degreespastel list | pastel rotate 180 | pastel list
pastel pick
=> any supported tools?pastel gradient red orange yellow white
Reading input is currently really slow:
▶ pastel random -n 1000 > colors
▶ hyperfine 'pastel format hex < colors'
Benchmark #1: pastel format hex < colors
Time (mean ± σ): 313.8 ms ± 5.9 ms [User: 309.8 ms, System: 3.5 ms]
Range (min … max): 307.8 ms … 327.9 ms 10 runs
The main reason is that we compile the regexes in each iteration:
Actual use cases:
pastel format hsl ff8000
)pastel color "rgb(255,50,127)"
)pastel pick
)pastel pick
)pastel paint
to print colorized text from shell scripts (with automatic mode detection) ==> actually try this (how to switch off colors?)!pastel distinct -n 5
)pastel gradient pick pick | pastel format hex
)pastel sample magma 0.3
)Some ideas for cool demos / snippets:
(see https://www.colourlovers.com/colors/most-loved/all-time/meta for some cool colors 😄)
# basics
pastel show 0077ff
# https://www.colourlovers.com/palette/1930/cheer_up_emo_kid
pastel color 556270 4ecdc4 c7f484 ff6b6b c44d58
pastel show salmon
pastel show salmon | pastel darken 0.2
pastel show salmon | pastel darken 0.2 | pastel desaturate 0.5
my_color=$(pastel show salmon | pastel darken 0.2 | pastel desaturate 0.5)
pastel show red blue green
pastel random
pastel random | pastel format
pastel random -n 30 | pastel sort-by hue | pastel format
pastel random -n 100 -s lch_hue | pastel sort-by hue | \
xargs -L1 -I{} pastel paint black --on "{}" " "
pastel random -s gray | pastel mix cyan | pastel format
(pastel gradient ffffcc fd8d3c;
pastel gradient fd8d3c 800026) | \
xargs -L1 -I{} pastel paint black --on "{}" " " -n
echo
pastel gradient -n 20 -s hsl pick pick | pastel format hex
bg="hotpink"
fg="$(pastel textcolor "$bg")"
pastel paint "$fg" --on "$bg" "well readable text"
Integration with other Unix tools:
seq
:
LANG=en seq 0 0.04 1 | sed -e 's/^/gray(/' -e 's/$/)/' | pastel format hex
xargs
, xargs -L1
head
, tail
sed
sort
Other points:
Literature:
pastel paint -n black --on red --bold " ERROR! "
echo " A serious error"
pastel paint -n black --on yellow --bold " WARNING! "
echo " A warning message"
pastel paint -n black --on limegreen --bold " INFO "
echo -n " Informational message with a "
echo -n "highlighted" | pastel paint -n default --underline
echo " word"
For example
pastel random | pastel set luminance 0.4
we could even think about replacing saturate
, lighten
, etc. with:
pastel modify saturation +0.3
pastel set saturation 0.5
...
pastel black
pastel cyan
...
There are many ways to generate random colors. Sampling uniformly in RGB space is probably not very interesting as it will likely produce a lot of dull, grayish and brownish colors.
Sampling in HSL space with a restricted range on saturation and lightness could be more interesting if we are interested in more vivid colors.
Using Lab or LCH space could be even better because we are now sampling "correctly" with respect to perceived color distances.
We could probably add an argument to the pastel random
command for the sampling strategy.
e.g.:
pastel list | pastel sortby luminance | head -n20 | pastel darken 0.2
pastel random 20 | pastel show
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.