jalaljaberi/negarity-color

Negarity Color — a modern, extensible color manipulation library for PHP.

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/jalaljaberi/negarity-color

dev-main 2026-01-07 22:03 UTC

This package is not auto-updated.

Last update: 2026-01-08 21:36:51 UTC


README

Negarity Color is a modern, extensible color manipulation library for PHP 8.3+.

Installation

composer require jalaljaberi/negarity-color

Basic Usage

<?php

require_once __DIR__ . '/vendor/autoload.php';

use Negarity\Color\Color;

// Create colors
$primary = Color::rgb(255, 100, 50);
$secondary = Color::hex('#3498db');

// Convert between color spaces
$hsl = $primary->toHSL();
$cmyk = $primary->toCMYK();

// Read channels
$r = $primary->getR();        // 255
$space = $primary->getColorSpaceName(); // "rgb"

// Modify (immutable by default)
$lighter = $primary->with(['g' => 150]);

echo $primary->toHex();   // "#FF6432"
echo (string) $hsl;       // "hsl(...)"

Configuration (Optional)

Named colors

Register a named-color registry once, then use Color::{name}():

use Negarity\Color\Color;
use Negarity\Color\Registry\VGANamedColors;

Color::addRegistry(new VGANamedColors());

$red = Color::red();
$navyHsl = Color::navy(\Negarity\Color\ColorSpace\HSL::class);

Filters

Filters must be registered before they are available as methods on Color objects:

use Negarity\Color\Color;
use Negarity\Color\Filter\FilterRegistry;
use Negarity\Color\Filter\Parameterized\BrightnessFilter;
use Negarity\Color\Filter\Unary\InvertFilter;

FilterRegistry::register(new BrightnessFilter());
FilterRegistry::register(new InvertFilter());

$color = Color::rgb(255, 100, 50)
    ->brightness(20)
    ->invert();

Documentation

Getting started

License

MIT