shahonseven / php-color-hash
Generate color based on the given string. Backported from the Javascript library color-hash
Installs: 60 881
Dependents: 0
Suggesters: 0
Security: 0
Stars: 11
Watchers: 2
Forks: 4
Open Issues: 4
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2022-08-06 16:02:10 UTC
README
Generate color based on the given string. PHP Port of ColorHash Javascript Library.
Requires 64-bit PHP build.
Usage
Composer
composer require shahonseven/php-color-hash
Basic
$colorHash = new Shahonseven\ColorHash(); // in HSL, Hue ∈ [0, 360), Saturation ∈ [0, 1], Lightness ∈ [0, 1] $colorHash->hsl('Hello World'); // [ 225, 0.65, 0.35 ] // in RGB, R, G, B ∈ [0, 255] $colorHash->rgb('Hello World'); // [ 135, 150, 197 ] // in HEX $colorHash->hex('Hello World'); // '#8796c5'