PHP code example of kachnitel / color-converter

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

    

kachnitel / color-converter example snippets


use Kachnitel\ColorConverter\ColorConverter;

$converter = new ColorConverter();

// Convert hex to RGB
$rgb = $converter->hex2rgb('#ff5733');
// ['r' => 255, 'g' => 87, 'b' => 51]

// Convert hex to HSL
$hsl = $converter->hex2hsl('#ff5733');
// ['h' => 11, 's' => 100, 'l' => 60]

// Check if color is light or dark
$isLight = $converter->isLight('#ff5733');
// false (dark color)

// Custom threshold for light/dark detection
$isLight = $converter->isLight('#ff5733', 70);
// true (with higher threshold)