PHP code example of artack / color

1. Go to this page and download the library: Download artack/color library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

artack / color example snippets


$RGB = new RGB(0, 255, 0);
echo $RGB->getGreen(); // 255

$converter = Factory::createConverter();
$RGB = new RGB(0, 255, 0);

$HSV = $converter->convert($RGB, HSV::class);

$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