Skip to content

MarcBrillault/namedColors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 

Repository files navigation

NamedColors

Find a color's hexadecimal value from its name.

This library does not only list all the HTML colors, but also :

Installation

With composer :

composer require brio/named-colors

Usage

use Brio\NamedColors;

// Find a color from its name or reference
// Note that, if multiple matches are possible, the first match is returned
// html colors are always first to be matched
$color = NamedColors::findHexByName('red'); // returns #FF0000
$color = NamedColors::findHexByName('Google Red'); // returns #EA4335

// Find a color from its name, with a specific color set
$color = NamedColors::findHexByName('red', 'xkcd'); // returns #E50000

Contributing

Feel free to add your own color schemes, as soon as they meet these requirements :

  • All colors schemes should be created in the src/colors directory
  • They must only contain one array, named $colors
  • Each item of this array must have one key, and these three values :
    • reference
    • name
    • hexa
  • The key should be a camelCase version of the color's name
  • reference and name are not mandatory
  • The hexa key is mandatory, it should contain the hexadecimal value of the color, prefixed with a sharp (#).

Credit

The first release's colors all come from the W3Schools website, thanks to them !