PHP code example of mscharley / colourist
1. Go to this page and download the library: Download mscharley/colourist 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/ */
mscharley / colourist example snippets
$colour = \Colourist\Colour::fromHex('#ffccaa');
// Automatically conversions to calculate values you need.
$h = $colour->hue();
$l = $colour->lightness();
$b = $colour->brightness();
// Distinguish between different types of saturation.
$sl = $colour->hslSaturation();
$sb = $colour->hsbSaturation();
// Explicit conversions if you need them.
$hsl = $colour->toHSL();
$sl == $hsl->saturation();
// Colours are immutable - conversions are highly cached as a result.
// Freely convert between colour spaces as
$colour = \Colourist\Colour::fromHex('#ffccaa');
$colour2 = \Colourist\Colour::fromHex('#aaccff');
// You must use ->equals() for comparing equality.
$colour->equals($colour2); // FALSE
$colour == $colour2; // stack overflow