mattacosta/php-colorspace

Convert, compare, and animate colors.

v1.0.0 2022-03-07 00:30 UTC

This package is auto-updated.

Last update: 2024-06-07 06:58:06 UTC


README

CI

Convert, compare, and animate colors.

Features

Color spaces

Color difference metrics

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