PHP code example of ramazancetinkaya / color-code-converter

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

    

ramazancetinkaya / color-code-converter example snippets


    



amazancetinkaya\ColorConverter;

$converter = new ColorConverter();

// Convert HEX to RGB
$rgb = $converter->hexToRgb('#FF5733'); // [255, 87, 51]

# echo '<pre>' . print_r($rgb, true) . '</pre>';

// Convert RGB to HEX
$hex = $converter->rgbToHex([255, 87, 51]); // "#FF5733"

# echo $hex;

// Convert RGB to HSL
$hsl = $converter->rgbToHsl([255, 87, 51]); // [10.59, 100, 60]

# echo '<pre>' . print_r($hsl, true) . '</pre>';

// Convert HSL to RGB
$rgb2 = $converter->hslToRgb([14.29, 100, 60]); // [255, 100, 51]

# echo '<pre>' . print_r($rgb2, true) . '</pre>';

// Convert HEX to HSL
$hsl2 = $converter->hexToHsl('#FF5733'); // [10.59, 100, 60]

# echo '<pre>' . print_r($hsl2, true) . '</pre>';

// Convert HSL to HEX
$hex2 = $converter->hslToHex([14.29, 100, 60]); // "#FF5733"

# echo $hex2;
plaintext
src/
├── ColorConverter.php
composer.json
README.md
LICENSE