Download the PHP package villfa/invert-color without Composer
On this page you can find all versions of the php package villfa/invert-color. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Please rate this library. Is it a good library?
Informations about the package invert-color
php-invert-color
invert hex color code
Installation
Usage
Here a basic example:
Color::fromHex(string $color): Color - throws InvalidColorFormatException
$color
:string
Color in HEX string. Accepted formats: #000000, #000, 000000, 000
Color::fromRGB(array $rgb): Color - throws InvalidRGBException
$rgb
:array
Color as an array of RGB values.
Color::invert([bool $bw]): string
$bw
:bool
Optional. A boolean value indicating whether the output should be amplified to black (#000000
) or white (#ffffff
), according to the luminance of the original color.
Color::invertAsRGB([bool $bw]): array
$bw
:bool
Optional. A boolean value indicating whether the output should be amplified to black or white, according to the luminance of the original color.
Color::invertAsObj([bool $bw]): Color
$bw
:bool
Optional. A boolean value indicating whether the output should be amplified to black or white, according to the luminance of the original color.
Color::getHex(): string
Color::getRGB(): array
Color::getLuminance(): float
Color::isBright(): bool
Color::isDark(): bool
Tests
To validate and test the library:
Acknowledgement
This library is a port of the JS package invert-color.
More resources:
- https://stackoverflow.com/questions/35969656/how-can-i-generate-the-opposite-color-according-to-current-color
- https://stackoverflow.com/questions/3942878/how-to-decide-font-color-in-white-or-black-depending-on-background-color/3943023#3943023
License
MIT
All versions of invert-color with dependencies
PHP Build Version
Package Version
Requires
php Version
>=7.1
The package villfa/invert-color contains the following files
Loading the files please wait ....