PHP code example of fonil / coloreeze

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

    

fonil / coloreeze example snippets


ColorFactory::fromString('rgb(0,100,200)'); // Returns a `ColorRGBA` instance
ColorFactory::fromString('#336699'); // Returns a `ColorHex` instance
ColorFactory::fromString('unknown(1,2,3)'); // Throws an `InvalidInput` exception

echo ColorRGBA::fromString('rgba(0,100,200,1.0)');
echo ColorHex::fromString('#336699');

'rgba(0,100,200,1.0)'
'#336699'

$hex = ColorHex::fromString('#336699');
$rgba = ColorRGBA::fromString('rgba(0,100,200,1.0)');
...

$int = ColorInt::fromString('int(100)');
var_dump($int->getValue());

int(100)

$rgba = ColorRGBA::fromString('rgba(0, 100, 200)');
var_dump($int->getValue());

array(3) {
  [0]=>
  int(0)
  [1]=>
  int(100)
  [2]=>
  int(200)
}

$hex = ColorHex::fromString('#336699');
var_dump($int->getValue());

string(7) "#336699"

$lab = ColorHex::fromString('#336699')->toCIELab();

$cmyk = ColorHex::fromString('#336699')->toCMYK();

$hex = ColorRGBA::fromString('rgba(100,200,200,1.0)')->toHex();

$hsb = ColorHex::fromString('#336699')->toHSB();

$hsl = ColorHex::fromString('#336699')->toHSL();

$int = ColorHex::fromString('#336699')->toInt();

$rgba = ColorInt::fromString('int(255)')->toRGBA();

$rgba = ColorCMYK::fromString('cmyk(0,0,0,0)')->toXYZ();

$complementary = ColorRGBA::fromString('hsl(182,25,50)')->toComplementary();

$greyscale = ColorInt::fromString('int(4278255615)')->toGreyscale();

$dark = ColorInt::fromString('int(4278255615)')->adjustBrightness(-10);
$light = ColorInt::fromString('int(4278255615)')->adjustBrightness(10);

$distance = ColorInt::fromString('int(4278255615)')->distanceCIE76(ColorInt::fromString('int(0)'));
bash
Code Coverage Report:
  2022-07-22 06:32:15

 Summary:
  Classes: 100.00% (11/11)
  Methods: 100.00% (135/135)
  Lines:   100.00% (475/475)
bash
> vendor/bin/phpstan analyse --level 9 --memory-limit 1G --ansi ./src ./tests
 29/29 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 [OK] No errors