baraja-core / color
There is no license information available for the latest version (v1.0.0) of this package.
Normalize HTML colors.
v1.0.0
2021-09-10 09:29 UTC
Requires
- php: ^8.0
Requires (Dev)
- phpstan/extension-installer: ^1.0
- phpstan/phpstan: ^0.12.94
- phpstan/phpstan-deprecation-rules: ^0.12.6
- phpstan/phpstan-nette: ^0.12.14
- phpstan/phpstan-strict-rules: ^0.12.10
- roave/security-advisories: dev-master
- spaze/phpstan-disallowed-calls: ^1.1
- tracy/tracy: ^2.8
This package is auto-updated.
Last update: 2024-11-08 18:29:41 UTC
README
Normalize HTML colors.
Idea
On websites, we often need to manipulate the colours we get in different ways. For example, from the user or from another application layer.
This package provides a simple way to normalize the received color to a canonical shape.
When normalizing, you can choose to convert to short or long notation:
Examples:
Color::normalize('#aaA'); // '#aaa' Color::normalize('#abcd'); // '#abc' Color::normalize('#aaAAaa'); // '#aaa' Color::normalize('#aaA', Color::FORMAT_LONG); // '#aaaaaa'
A second parameter can be used for formatting, which has possible values:
Color::FORMAT_SHORT
prefers short notation (if possible)Color::FORMAT_LONG
always returns a long notation