https://github.com/artack/color
🎨 Color helper library for converting between RGB, CMYK, HSV, HST and HEX and create interpolation
https://github.com/artack/color
cmyk color convertion hex hsv interpolation php rgb
Last synced: about 2 months ago
JSON representation
🎨 Color helper library for converting between RGB, CMYK, HSV, HST and HEX and create interpolation
- Host: GitHub
- URL: https://github.com/artack/color
- Owner: artack
- License: mit
- Created: 2017-12-11T10:50:53.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-03-21T13:11:03.000Z (about 1 year ago)
- Last Synced: 2025-03-24T23:51:26.605Z (2 months ago)
- Topics: cmyk, color, convertion, hex, hsv, interpolation, php, rgb
- Language: PHP
- Homepage:
- Size: 41 KB
- Stars: 4
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
artack/color
============> color conversions and transitions (e.g. interpolation).
[](https://packagist.org/packages/artack/color)
[](http://opensource.org/licenses/MIT)
[](https://packagist.org/packages/artack/color)Developed by [ARTACK WebLab GmbH](https://www.artack.ch) in Zurich, Switzerland.
Features
--------- Provides class representation for **RGB**, **CMYK**, **HSV**, **HSL** and **HEX**.
- Provides conversion between all class representation
- Provides transitions between colors (e.g. interpolation)
- Provides clear exceptions to be able to handle library exceptions
- Compatible with PHP >= 7 and >= 8.Installation
------------You can install this color library through [Composer](https://getcomposer.org):
```shell
$ composer require artack/color
```Usage
-----
Creating a RGB class representation:```php
$RGB = new RGB(0, 255, 0);
echo $RGB->getGreen(); // 255
```Translate RGR class representation to HSV:
```php
$converter = Factory::createConverter();
$RGB = new RGB(0, 255, 0);$HSV = $converter->convert($RGB, HSV::class);
```Get an interpolation color between two colors with the value (and max) given:
```php
$transition = Factory::createTransition();
$RGBRed = new RGB(255, 0, 0); // red
$RGBGreen = new RGB(0, 255, 0); // green$RGBInterpolated = $transition->interpolate(RGB::class, $RGBRed, $RGBGreen, 100, 200); // should be ~yellow
// Interpolation will give better results when using HSV Transition. Colors get converted automatically if needed.
$HSVInterpolated = $transition->interpolate(HSV::class, $RGBRed, $RGBGreen, 100, 200); // should be ~yellow
```