jalaljaberi/negarity-color 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jalaljaberi/negarity-color

Composer 安装命令:

composer require jalaljaberi/negarity-color

包简介

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

README 文档

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;
use Negarity\Color\Registry\ColorSpaceRegistry;

// Register built-in color spaces (required before use)
ColorSpaceRegistry::registerBuiltIn();

// 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);

Color Spaces

Color spaces must be registered before use. Register all built-in color spaces:

use Negarity\Color\Registry\ColorSpaceRegistry;

ColorSpaceRegistry::registerBuiltIn();

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

References

  • Martin Krzywinski color table - A comprehensive list of 9,284 named colors with conversions across multiple color spaces (RGB, HSV, XYZ, Lab, LCH, CMYK)

License

MIT

统计信息

  • 总下载量: 10
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固