PHPackages                             wwaz/colormodel-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. wwaz/colormodel-php

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

wwaz/colormodel-php
===================

Basic color models and conversions

v1.0.3(1mo ago)04↓100%MITPHPPHP ^8.1 || ^8.2 || ^8.3 || ^8.4 || ^8.5CI passing

Since May 20Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/WWAZ/colormodel-php)[ Packagist](https://packagist.org/packages/wwaz/colormodel-php)[ RSS](/packages/wwaz-colormodel-php/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (3)Dependencies (3)Versions (5)Used By (0)

colormodel-php
==============

[](#colormodel-php)

Convert, manipulate, and generate color schemes across all major color spaces — with a clean, chainable PHP API.

```
composer require wwaz/colormodel-php
```

---

What it does
------------

[](#what-it-does)

- **10 color models** — HEX, RGB, RGBA, HSB, HSV, HSL, CMYK, CMYKInt, CIELab, CIELCh, XYZ
- **Fluent conversions** — chain from one color space to another in a single expression
- **Color manipulation** — rotate hue, mix colors with custom weights
- **Color schemes** — Complementary, Triadic, Tetradic, Square, Analogous, Tint, Tone, Shade
- **Flexible input/output** — accept strings, arrays, integers, or named colors like `'red'`

---

Examples
--------

[](#examples)

### 1. Cross-Format Conversion Chain

[](#1-cross-format-conversion-chain)

Start with a HEX color, rotate its hue by 180°, and export as CMYK — perfect for generating print-ready complementary colors from web values:

```
use wwaz\Colormodel\Model\Hex;

$cmyk = (new Hex('#f00'))
    ->hue(180)
    ->toCMYK();

echo $cmyk->toString();    // 100,0,0,0
echo $cmyk->toHtml();      // cmyk(100,0,0,0)
echo $cmyk->toArray();     // [100, 0, 0, 0]
```

---

### 2. Mixing Colors with Custom Weight

[](#2-mixing-colors-with-custom-weight)

Blend two colors in any ratio. Great for generating palette gradients or brand color variations programmatically:

```
use wwaz\Colormodel\Model\Hex;

$red  = new Hex('#ff0000');
$blue = new Hex('#0000ff');

// 50/50 mix → purple
echo $red->mix($blue)->toString();        // 800080

// 75/25 mix (more red) → darker pink
echo $red->mix($blue, 0.25)->toString();  // BF0040
```

---

### 3. Generate a Full Color Scheme

[](#3-generate-a-full-color-scheme)

Feed in any color, get back a complete set of harmonious variations — all returned in the same color model you started with:

```
use wwaz\Colormodel\Model\RGB;
use wwaz\Colormodel\Scheme\Complementary;
use wwaz\Colormodel\Scheme\Triadic;
use wwaz\Colormodel\Scheme\Analogous;
use wwaz\Colormodel\Scheme\Tint;

$base = new RGB(255, 0, 0); // red

(new Complementary($base))->get(); // ['255,0,0', '0,255,255']
(new Triadic($base))->get();       // red + 2 harmonics
(new Analogous($base))->get();     // neighboring hues
(new Tint($base))->get();          // lighter variations

// Works with CMYK too — output stays in CMYK
use wwaz\Colormodel\Model\CMYKInt;
$cyan = new CMYKInt(100, 0, 0, 0);
(new Complementary($cyan))->get(); // ['100,0,0,0', '0,100,100,0']
```

---

Color Models
------------

[](#color-models)

ModelChannelsTypical useHEX\#RRGGBBHTML / CSSRGB0–255 per channelScreen / digitalRGBARGB + alpha (0–1)CSS with transparencyHSB/HSVHue 0–360°, Sat 0–100, Bri 0–100Color pickersHSLHue 0–360°, Sat 0–100, Lig 0–100CSS / design toolsCMYK0–1 float per channelPrint (float)CMYKInt0–100 int per channelPrint (integer)CIELabL 0–100, a, b axesPerceptual color scienceCIELChL, Chroma, HueSmooth color gradientsXYZDevice-independent referenceColor math / ICC---

Development
-----------

[](#development)

### Setup

[](#setup)

```
composer install
```

### Quality checks

[](#quality-checks)

```
composer check
```

You can also run the checks individually:

```
composer test
composer analyse
composer lint
```

### Backward compatibility policy

[](#backward-compatibility-policy)

- Existing public APIs are kept backward-compatible.
- Legacy usage with `new HEX(...)` remains supported.
- New APIs are added in an additive way to avoid breaking existing integrations.

---

Contributing
------------

[](#contributing)

Please see `CONTRIBUTING.md` for development workflow and pull request expectations.

---

License
-------

[](#license)

MIT

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance90

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~112 days

Total

4

Last Release

48d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/25566288?v=4)[WWAZ](/maintainers/WWAZ)[@WWAZ](https://github.com/WWAZ)

---

Top Contributors

[![WWAZ](https://avatars.githubusercontent.com/u/25566288?v=4)](https://github.com/WWAZ "WWAZ (21 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/wwaz-colormodel-php/health.svg)

```
[![Health](https://phpackages.com/badges/wwaz-colormodel-php/health.svg)](https://phpackages.com/packages/wwaz-colormodel-php)
```

###  Alternatives

[willvincent/feeds

Laravel Service Provider for the SimplePie library

3131.5M2](/packages/willvincent-feeds)[albertofem/rsync-lib

A simple PHP rsync wrapper library

93409.7k6](/packages/albertofem-rsync-lib)[atelierdisko/coupon_code

PHP library to generate and validate coupon code strings.

60195.8k2](/packages/atelierdisko-coupon-code)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
