Pigment
All the colors of the web, by name – case-/space-/snake-insensitive.
Pigment is a Rust library that provides access to hundreds of named colors, with a forgiving lookup system that ignores case, spaces, and other non-alphanumeric characters.
Installation
Add this to your Cargo.toml:
[]
= "0.1.2"
Features
- Extensive color database: Hundreds of named colors from Wikipedia
- Forgiving lookups: Case-insensitive, ignores spaces and special characters
- Multiple formats: Access colors as hex codes or RGB tuples
- ANSI terminal support: Built-in support for ANSI color codes
- Multiple library integrations: Optional integrations with popular color libraries:
Usage
Basic Usage
use color;
ANSI Terminal Colors
use color;
Library Integrations
Pigment can integrate with several popular Rust color libraries. Here are some examples:
owo-colors
Enable the owo feature in your Cargo.toml:
[]
= { = "0.1.2", = ["owo"] }
= "4"
Then use it like this:
use OwoColorize;
use color;
termcolor
Enable the termcolor feature in your Cargo.toml:
[]
= { = "0.1.2", = ["termcolor"] }
= "1.2"
Then use it like this:
use Write;
use ;
use color;
colored
Enable the colored feature in your Cargo.toml:
[]
= { = "0.1.2", = ["colored"] }
= "2"
Then use it like this:
use Colorize;
use color;
Other supported libraries include anstyle, nu-ansi-term, yansi, and crossterm.
See the examples directory for more detailed usage examples.
License
This project is licensed under the MIT License - see the LICENSE file for details.