anthocodeur / multicolors-converter
A very simple tool to convert colors into differents formats
Installs: 9
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/anthocodeur/multicolors-converter
Requires
- php: >=8.0
Requires (Dev)
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2025-10-02 20:48:39 UTC
README
ColorConverter is a modern PHP package that provides robust and precise conversions between various color formats, including Hexadecimal, RGB, and RAL color systems. Leveraging encapsulated converters (HexConverter, RalConverter, RgbConverter), it enables easy and precise manipulation of colors.
Installation
Install this package easily via Composer:
composer require anthocodeur/multicolors-converter
Usage
You can use the static methods provided by the dedicated converter classes to convert colors between different formats.
Convert Hexadecimal to RGB
use ColorConverter\HexConverter; $hex = '#FF0000'; $rgb = HexConverter::hexToRgb($hex); print_r($rgb); // ['R' => 255, 'G' => 0, 'B' => 0]
Convert RGB to Hexadecimal
use ColorConverter\RgbConverter; $r = 255; $g = 0; $b = 0; $hex = RgbConverter::rgbToHex($r, $g, $b); echo $hex; // #ff0000
Convert RGB to RAL
use ColorConverter\RalConverter; $r = 255; $g = 0; $b = 0; $ral = RalConverter::rgbToRalValue($r, $g, $b); echo $ral; // e.g., RAL1000
Convert RAL to RGB
use ColorConverter\RalConverter; $ral = 'RAL1000'; $rgb = RalConverter::ralToRgb($ral); print_r($rgb); // ['R' => 203, 'G' => 186, 'B' => 136]
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines on how to contribute to this project.
License
This package is open-source software licensed under the MIT License. See the LICENSE file for details.