Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ericpugh/dub-color

Find the english language name of a (HEX) color
https://github.com/ericpugh/dub-color

color-palette php

Last synced: about 2 months ago
JSON representation

Find the english language name of a (HEX) color

Awesome Lists containing this project

README

        

# DubColor

Find the english language name of a (HEX) color. Names provided by one of the following color palettes, or can be extended to use a custom palette:
* [Crayola](https://www.wikiwand.com/en/List_of_Crayola_crayon_colors)
* [CSS3](https://drafts.csswg.org/css-color-3/)
* [CSS4](https://drafts.csswg.org/css-color/)
* [NCS](https://en.wikipedia.org/wiki/Natural_Color_System)

### Example Usage

```php
countColorPalette();

// An example hex color.
$example_hex = '#83F600';
$example_color = new Color($dubber::fromHexToInt($example_hex));
// Finds the closest HEX color in the current palette.
$closest = $dubber->closestColor($example_color);
// Finds the name "lawngreen".
$name = $dubber->getColorName($closest);

// Output results.
$label = sprintf('Found 1 in %d colors', $total_num_colors);
$color_span = sprintf('Name: %s', $closest, $name);
echo $label . $color_span;

?>
```