Convert, compare, and animate colors.
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
- PHP 8.1 or later
composer require mattacosta/php-colorspace
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);