Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/baraja-core/color
🎨 Normalize HTML colors.
https://github.com/baraja-core/color
color colors html-color normalizer php-color validator
Last synced: 8 days ago
JSON representation
🎨 Normalize HTML colors.
- Host: GitHub
- URL: https://github.com/baraja-core/color
- Owner: baraja-core
- License: mit
- Created: 2021-09-10T09:23:55.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-09-08T13:35:21.000Z (over 2 years ago)
- Last Synced: 2024-12-07T02:47:52.364Z (27 days ago)
- Topics: color, colors, html-color, normalizer, php-color, validator
- Language: PHP
- Homepage: https://php.baraja.cz
- Size: 6.84 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
PHP Color normalizer
====================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:
```php
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