innmind / colour
Handle colours strictly
Installs: 49 778
Dependents: 4
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 1
pkg:composer/innmind/colour
Requires
- php: ~8.2
 - innmind/immutable: ~4.0|~5.0
 
Requires (Dev)
- innmind/black-box: ~5.0|^6.0.1
 - innmind/coding-standard: ~2.0
 - phpunit/phpunit: ~10.2|~11.0|~12.0
 - vimeo/psalm: ~5.0
 
Suggests
- innmind/black-box: For property based testing
 
Provides
Conflicts
- innmind/black-box: <5.0|~7.0
 
README
This library helps you build an object representation of a colour out of a string (all objects are immutable). You can easily extract any information out of the colors, transform their representation and modify the colours.
It supports these formats:
#39f#39ff(last hexadecimal value for the alpha)#3399ff#3399ffff(last 2 hexadecimal values for the alpha)rgb()rgba()hsl()hsla()device-cmyk()- literals (as defined by the W3C)
 
Installation
composer install innmind/colour
Usage
use Innmind\Colour\Colour; $rgba = Colour::of('39f'); $hsla = Colour::of('hsl(210, 100%, 60%)'); $cmyka = Colour::of('device-cmyk(80%, 40%, 0%, 0%)'); $rgba = Colour::blue->toRGBA();
Each representation can be represented to the other two so you can always work with your preferred format.