hexcolor/hexcolor-tools

Lightweight PHP color conversion utilities for HEX, RGB, HSL, and WCAG accessibility contrast ratio calculations by HexColor.ie.

dev-main 2026-08-16 20:17 UTC

This package is auto-updated.

Last update: 2026-08-16 20:19:18 UTC


README

Latest Stable Version License: MIT

A lightweight, zero-dependency PHP color conversion and WCAG 2.1 accessibility contrast calculation library powered by HexColor.ie.

🎨 Features & Live Online Tools

🚀 Installation

Install via Composer:

composer require hexcolor/hexcolor-tools

💻 Usage Example

<?php

require 'vendor/autoload.php';

use HexColor\Tools\HexColorTools;

// 1. Validate HEX Code
$isValid = HexColorTools::isValidHex('#c27e79'); // true

// 2. Convert HEX to RGB
$rgb = HexColorTools::hexToRgb('#c27e79');
// Array ( [r] => 194 [g] => 126 [b] => 121 )

// 3. Convert RGB to HEX
$hex = HexColorTools::rgbToHex(194, 126, 121);
// "#C27E79"

// 4. Calculate WCAG 2.1 Accessibility Contrast Ratio
$contrast = HexColorTools::calculateContrastRatio('#FFFFFF', '#000000');
// 21.0 (Passes AAA)

🌐 Documentation & Resources

For detailed color tools, hex code lookups, and visual gradient tools, visit https://hexcolor.ie.

📄 License

This package is licensed under the MIT License - see the LICENSE file for details.