Terminal color profile detection + ANSI conversion
Detect the terminal's color capability (ANSI / ANSI256 / TrueColor), convert between formats, and write StandardColors compatible with the Charm ecosystem.
composer require sugarcraft/candy-palette
use SugarCraft\Palette\Palette;
$profile = Palette::detect();
echo $profile->type(); // "truecolor" | "256" | "ansi"
$hex = Palette::fromHex('#ff6b6b')->toProfile($profile)->ansi();
$rgb = Palette::fromHex('#ff6b6b')->rgb(); // [255, 107, 107]
| Class | Method | Description |
|---|---|---|
| Palette | detect() | Detect terminal color profile |
| Palette | fromHex(hex) | Create color from hex |
| Palette | fromRgb(r, g, b) | Create color from RGB |
| Palette | toProfile(profile) | Convert to profile |
| Palette | ansi(), ansi256(), truecolor() | Output as ANSI format |
| StandardColors | black(), red(), green()... | 16 ANSI standard colors |
| ProfileWriter | write(profile) | Output terminal profile |
VHS-recorded GIFs of every example shipped with the library. Regenerated automatically on every push that touches the source.