Code Monkey home page Code Monkey logo

dub-color's Introduction

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:

Example Usage

<?php

use ericpugh\DubColor\Palette\Css4;
use ericpugh\DubColor\ColorDubber;
use ericpugh\DubColor\Color;

// Create instance of DubColor and set color palette to use.
$palette = Css4::getColors();
$dubber = new ColorDubber($palette);
$total_num_colors = $dubber->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('<span>Found 1 in %d colors</span>', $total_num_colors);
$color_span = sprintf('<span style="background-color:%s">Name: %s</span>', $closest, $name);
echo $label . $color_span;

?>

dub-color's People

Contributors

ericpugh avatar

Stargazers

 avatar

Watchers

 avatar  avatar

dub-color's Issues

Add optional setting of Color in constructor

Add setColor as method and optional param in the constructor, so you could:
$name = new ColorDubber('css4', '#83F600')->getColorName()
or
$name = new ColorDubber()->setColor('#83F600)->getColorName()

Convert Palette to YAML

Get color palettes from yml files in Resources/config, to make it easier to add new color palettes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.