mattacosta / php-colorspace
Convert, compare, and animate colors.
v1.0.0
2022-03-07 00:30 UTC
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);