Download the PHP package philiprehberger/php-color without Composer
On this page you can find all versions of the php package philiprehberger/php-color. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download philiprehberger/php-color
More information about philiprehberger/php-color
Files in philiprehberger/php-color
Download philiprehberger/php-color
More information about philiprehberger/php-color
Files in philiprehberger/php-color
Vendor philiprehberger
Package php-color
Short Description Color parsing, conversion, manipulation, and WCAG contrast checking
License MIT
Homepage https://github.com/philiprehberger/php-color
Package php-color
Short Description Color parsing, conversion, manipulation, and WCAG contrast checking
License MIT
Homepage https://github.com/philiprehberger/php-color
Please rate this library. Is it a good library?
Informations about the package php-color
PHP Color
Color parsing, conversion, manipulation, and WCAG contrast checking.
Requirements
- PHP 8.2+
Installation
Usage
Creating Colors
Converting Colors
Manipulating Colors
All manipulation methods return new Color instances (immutable).
Blending Colors
Color Analysis
WCAG Contrast Checking
Generating Palettes
Generating Gradients
API
Color
| Method | Description |
|---|---|
Color::hex(string $hex): Color |
Create from hex string (3, 4, 6, or 8 digits) |
Color::rgb(int $r, int $g, int $b, float $alpha = 1.0): Color |
Create from RGB values |
Color::hsl(float $h, float $s, float $l, float $alpha = 1.0): Color |
Create from HSL values |
Color::named(string $name): Color |
Create from CSS named color |
Color::random(): Color |
Generate a random color |
->lighten(float $percent): Color |
Lighten by percentage |
->darken(float $percent): Color |
Darken by percentage |
->saturate(float $percent): Color |
Increase saturation |
->desaturate(float $percent): Color |
Decrease saturation |
->mix(Color $other, float $weight = 0.5): Color |
Mix with another color |
->blend(Color $other, string $mode): Color |
Blend with another color using a CSS blend mode |
->invert(): Color |
Invert the color |
->grayscale(): Color |
Convert to grayscale |
->distance(Color $other): float |
CIE76 Delta E perceptual distance |
->isLight(): bool |
True if relative luminance > 0.5 |
->isDark(): bool |
True if relative luminance <= 0.5 |
->contrastRatio(Color\|string $other): float |
WCAG contrast ratio (1.0-21.0) |
->meetsWcagAA(Color\|string $background): bool |
Meets WCAG AA (4.5:1) |
->meetsWcagAAA(Color\|string $background): bool |
Meets WCAG AAA (7:1) |
->toHex(): string |
Output as hex string |
->toRgb(): string |
Output as rgb()/rgba() string |
->toHsl(): string |
Output as hsl()/hsla() string |
->toArray(): array |
Output as associative array |
Palette
| Method | Description |
|---|---|
Palette::complementary(Color $color): array |
Complementary pair |
Palette::analogous(Color $color, float $angle = 30.0): array |
Three analogous colors |
Palette::triadic(Color $color): array |
Three triadic colors |
Palette::splitComplementary(Color $color): array |
Split-complementary triad |
Palette::tetradic(Color $color): array |
Tetradic (rectangular) quartet |
Palette::gradient(Color $start, Color $end, int $steps, string $space = 'rgb'): array |
Interpolated color gradient |
Palette::shades(Color $color, int $count = 5): array |
Progressive darker shades |
Palette::tints(Color $color, int $count = 5): array |
Progressive lighter tints |
Development
Support
If you find this project useful:
License
MIT
All versions of php-color with dependencies
PHP Build Version
Package Version
Requires
php Version
^8.2
The package philiprehberger/php-color contains the following files
Loading the files please wait ...