aloso / colo Goto Github PK
View Code? Open in Web Editor NEWDisplays colors in various color spaces.
Home Page: https://aloso.github.io/colo/
License: MIT License
Displays colors in various color spaces.
Home Page: https://aloso.github.io/colo/
License: MIT License
I currently don't have access to a Windows or macOS machine, so I'd have to cross-compile from Linux, or somehow use GitHub actions. I haven't investigated this yet, if you have experience with this, please let me know!
Add a gray color space that has only one component, the luminance (which is equivalent to the 3rd component of hsl). This will make it easy to convert a color to grayscale.
For more advanced terminal features, such as a color picker, I suggest to use the console crate.
There should be different color pickers for different color spaces:
The MVP only has to implement a single color picker. It can be refactored later to use traits and generics, so it's easily extendable.
There should be two new magic keywords when parsing a list of colors:
pick
: this will read a color from the color picker-
(dash/hyphen): this will read a color from stdinExamples:
$ colo contrast rand pick # first color is random, second color is entered in the color picker
$ colo s pick # equivalent to `colo pick`
$ colo textcolor - # equivalent to `colo textcolor` when behind pipe
There should be a document where each color space is explained, with examples and external links. This can be a markdown file, linked from the README.
This is already implemented for the colo list
command
There are currently very few tests. For the next release, I'd like most modules to be unit tested.
Additionally, we should test the command-line interface in CI. I'm not sure what the easiest way to do this is, or if it's even feasible. If you have experience, let me know!
Imagine you want to make the color #aacc66
more saturated. You could do
$ colo s aacc66 -o hsl
hsl(80, 50%, 60%)
$ colo s "hsl(80, 80%, 60%)"
#b4eb47
Then you finally have the more saturated color #b4eb47
. However, colo
could offer a DSL (domain specifc language) to do this in one command, e.g.
colo s "AACC66 as hsl +0.3l"
The alternative is to use pipes, like pastel:
$ pastel color aacc66 | pastel saturate 0.3
Possible syntax:
$ colo s rand # equivalent to
$ colo s 'rgb(rand, rand, rand)'
Or more fine-grained:
$ colo s 'hsl(30..60, 0.7..1, rand)'
Something like
~ $ colo orange -t "This is printed in orange"
This is printed in orange
I think this tool would be even more powerful with the implementation of the CIELAB color space in the pick
subcommand. Thanks for this great tool. :><3
Currently, the CLI arguments are confusing, as some arguments require other arguments, and some conflict with each other. To simplify things, colo
should use subcommands for different tasks:
colo <COLOR>...
or echo <COLOR>... | colo
(no subcommand) outputs a colorcolo print <TEXT> <COLOR>...
or echo <TEXT> | colo print <COLOR>...
prints the text in a certain colorcolo term
shows the terminal colorscolo libs
shows the dependency treeThe printf
subcommand formats a text with format tags. Example:
echo "Hello {b}{fg red}world {i}Hello{/b} world" | colo printf
Format tags are:
{fg <text_color>}
sets the text (foreground) color{bg <background_color>}
sets the background color{b}
, {i}
, {u}
make the text bold, italic or underlined, respectively{/b}
, {/i}
, {/u}
, {/fg}
, {/bg}
resets the respective style to the defaultCompute the contrast between two colors according to the W3 specifciation.
When parsing a color, both decimal numbers (e.g. 0.04) and percent numbers (e.g. 4%) can be entered. When displaying it, it is always shown as a percent number.
Add command to mix an arbitrary number of colors in a given color space. The default color space should be Lab
.
For example:
$ colo oragne
Error: "oragne" is not a color
help: Did you mean "orange"?
$ colo lightgrey
Error: "lightgrey" is not a color
help: Did you mean "lightgray"?
Pipe input to colo
, for example:
$ echo "rgb(255, 0, 127), hsl(30, 1, .5)" | colo
$ echo "Hello world" | colo print red
This requires
Background color:
--on, -o <COLOR>
(set background color)Styles:
--bold, -b
--italic, -i
--underline, -u
Other options:
--no-newline, -n
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.