PHP code example of gubler / color

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

    

gubler / color example snippets


// with hex value
$color = new Color('#F4E204');
// with short hex value
$color = new Color('#ccc');
// with RGB
$color = new Color('rgb(10, 20, 30)');
// with RGBA
$color = new Color('rgba(10, 20, 30, 0.5)');
// with HSL
$color = new Color('hsl(30.5, 100%, 50%)');
// with HSLA
$color = new Color('hsla(30.5, 100%, 50%, 1.0)');

$color = new Color('#F4E204');
$color->rgba();
$color->hsla();
$color->hex();

$color->setHex('#fff000');
$color->setRgba(120, 0, 75, 0.9);
$color->setHsla(50.5, 70, 60, 1);

$textColor = $color->contractTextColor();
$textColor->rgba() // either rgba(0, 0, 0, 1) or rgba(255, 255, 255, 1)