PHP code example of renfordt / colors

1. Go to this page and download the library: Download renfordt/colors 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/ */

    

renfordt / colors example snippets


use Renfordt\Colors\HexColor;
use Renfordt\Colors\HSLColor;
use Renfordt\Colors\HSVColor;
use Renfordt\Colors\RALColor;
use Renfordt\Colors\RGBColor;

// HEX Color
$hexColor = HexColor::create('#ffffff');

// HSL Color
$hslColor = HSLColor::create([360, 100, 50]);

// HSV Color
$hsvColor = HSVColor::create([360, 100, 100]);

// RAL Color
$ralColor = RALColor::create('9010');

// RGB Color
$rgbColor = RGBColor::create([255, 255, 255]);

// Convert Hex to RGB
$rgbColor = $hexColor->toRGB();

// Convert RGB to HSL
$hslColor = $rgbColor->toHSL();

// Convert HSL to HSV
$hsvColor = $hslColor->toHSV();

// Convert HSV to RAL (this might