PHP code example of fyre / color

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

    

fyre / color example snippets


use Fyre\Color\Color;

$color = new Color($red, $green, $blue, $alpha);

$color = new Color($brightness, $alpha);

$color = Color::fromString($colorString);

$color = Color::fromCMY($cyan, $magenta, $yellow, $alpha);

$color = Color::fromCMYK($cyan, $magenta, $yellow, $key, $alpha);

$color = Color::fromHSL($hue, $saturation, $lightness, $alpha);

$color = Color::fromHSV($hue, $saturation, $value, $alpha);

$colorString = $color->toString();

$hexString = $color->toHexString();

$rgbString = $color->toRGBString();

$hslString = $color->toHSLString();

$label = $color->label();

$alpha = $color->getAlpha();

$brightness = $color->getBrightness();

$hue = $color->getHue();

$saturation = $color->getSaturation();

$luma = $color->luma();

$newColor = $color->setAlpha($alpha);

$newColor = $color->setBrightness($brightness);

$newColor = $color->setHue($hue);

$newColor = $color->setSaturation($saturation);

$newColor = $color->darken($amount);

$newColor = $color->invert();

$newColor = $color->lighten($amount);

$newColor = $color->shade($amount);

$newColor = $color->tint($amount);

$newColor = $color->tone($amount);

$complementary = $color->complementary();

[$secondary, $accent] = $color->split();

[$secondary, $accent] = $color->analogous();

[$secondary, $accent] = $color->triadic();

[$secondary, $alternate, $accent] = $color->tetradic();

$colorShades = $color->shades($shades);

$colorTints = $color->tints($tints);

$colorTones = $color->tones($tones);

$colorPalette = $color->palette($shades, $tints, $tones);

$contrast = Color::contrast($color1, $color2);

$distance = Color::dist($color1, $color2);

$contrastColor = Color::findContrast($color1, $color2, $minContrast, $stepSize);

$mixed = Color::mix($color1, $color2, $amount);

$multiplied = Color::multiply($color1, $color2, $amount);