MCPcopy Index your code
hub / github.com/Canop/coolor

github.com/Canop/coolor @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
65 symbols 142 edges 10 files 16 documented · 25%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

MIT Latest Version docs Chat on Miaou

Definition of ANSI, RGB and HSL color types and all the conversions between them.

There are many other color conversion crates. This one is no-std and pure-rust and may be useful when you're interested into

  • variations of an ANSI color for your TUI application, for example fading, lightening, darkening, with compatibility with terminals that don't support RGB.
  • translations of color schemes
  • automatic downgrading of RGB color schemes for non RGB terminals
  • automated building of harmonious color schemes with guarantees of contrast
  • etc.

Coolor is used in SafeCloset to dynamically fade the background behind a dialog:

img

Be warned that the ANSI range is intrinsically limited to 240 colors and that not all intuitive operations will give good results.

Coolor doesn't contain functions to print on the terminal, but the colors can be used in other crates. There's an optional feature for conversion from and into Crossterm colors. You'll see it used in the included examples.

Included Examples

ansi-variations

Luminosity and saturation variations of all 240 ANSI colors, with all variants still ANSI colors.

ansi-variations

ansi-mix

Several ways to mix colors

ansi-mix

rgb-to-ansi

Finding the nearest ANSI color from a RGB one

rgb-to-ansi

Core symbols most depended-on inside this repo

into
called by 30
src/color.rs
to_ansi
called by 11
src/hsl.rs
to_rgb
called by 11
src/hsl.rs
to_hsl
called by 8
src/rgb.rs
nearest_ansi_in_range
called by 6
src/rgb.rs
dist
called by 5
src/hsl.rs
print_ansi
called by 5
examples/ansi-mix/main.rs
to_hsl
called by 4
src/ansi.rs

Shape

Method 38
Function 22
Class 3
Enum 2

Languages

Rust100%

Modules by API surface

src/rgb.rs15 symbols
src/hsl.rs14 symbols
src/color.rs12 symbols
src/ansi.rs9 symbols
examples/rgb-to-ansi/main.rs4 symbols
examples/ansi-mix/main.rs4 symbols
examples/ansi-grey/main.rs4 symbols
examples/ansi-variations/main.rs2 symbols
src/error.rs1 symbols

For agents

$ claude mcp add coolor \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact