PHP code example of dobby007 / mrcolor

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

    

dobby007 / mrcolor example snippets

 php


use SyHolloway\MrColor\Color;

// Create a new color object with the default value of black
$color = Color::create();

// Create a new color object setting the red, green and blue values
$color2 = Color::create(array(
    'red' => 200,
    'green' => 200,
    'blue' => 100
));
 php


use SyHolloway\MrColor\Color;

// Create a new color object setting the hue, saturation and lightness values
$color = Color::create(array(
    'hue' => 200,
    'saturation' => 0.5,
    'lightness' => 0.9
));

// The object was built with hsl, but format conversion happens on the fly
echo 'Hue = ' . $color->hue;
echo 'Red = ' . $color->red;
echo 'Hex = #' . $color->hex;

// Feel free to edit these properties...
$color->blue = 123; // Set blue to 123 on the 0-255 scale
$color->green -= 20; // 20 less green on the 0-255 scale
$color->lightness += 0.23; // 23% lighter

// ...And expect the update to happen across all formats
echo $color->hue;
 php


use SyHolloway\MrColor\Color;