mattacosta / php-colorspace
Convert, compare, and animate colors.
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/mattacosta/php-colorspace
Requires
- php: >=8.1
Requires (Dev)
- phpunit/phpunit: ^9.5
README
Convert, compare, and animate colors.
Features
Color spaces
Color difference metrics
- CIELAB ΔE
- CIE 1976
- CIE 1994
- CIE 2000
- CMC l:c
Illuminants (part of the CieXyzColor class)
- D50
- D65
Animation
- Linear interpolation between colors
Requirements
- PHP 8.1 or later
Installation
composer require mattacosta/php-colorspace
Usage
Example: Converting between color spaces (or alternate representations) using
the ColorConverter class:
$hsl_color = ColorConverter::rgbToHsl($rgb_color);
Example: Computing the difference between two colors using the ColorDifference
class:
$deltaE = ColorDifference::deltaE2000($reference, $sample);
Example: Transitioning from one color to another:
// Tip: Use a cylindrical representation for best results. $yellow = HsvColor::lerp($red, $green, 0.5);