decodelabs / spectrum
Bring colour to PHP
Installs: 1 128
Dependents: 1
Suggesters: 1
Security: 0
Stars: 3
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: ^8.1
- decodelabs/coercion: ^0.2
- decodelabs/exceptional: ^0.4
- decodelabs/glitch-support: ^0.4
Requires (Dev)
README
Parse and manipulate colors
Spectrum offers a simple but powerful system for parsing, inspecting, manipulating and exporting colors.
Get news and updates on the DecodeLabs blog.
Installation
composer require decodelabs/spectrum
Usage
Load and manipulate any color with ease through RGB, HSL and HSV formats.
use DecodeLabs\Spectrum\Color; $color = Color::create('#5AB3CD'); $color = Color::create('darkblue'); $color = Color::create('rgba(25,25,25,0.4)'); $color = Color::random(); $color->toHsl(); $color->lighten(0.3); // 30% lighter $color->setAlpha(0.5); // 50% opacity $color->toMidtone(); // Medium saturation and lightness echo $color; // Converts to appropriate CSS value $contrastColor = $color->contrastAgainst('pink'); $textColor = $color->getTextContrastColor();
Licensing
Spectrum is licensed under the MIT License. See LICENSE for the full license text.