Skip to content

Repository files navigation

#Getting started:

ColorWorks uses the PSR-0 standards for namespaces, so there should be no trouble using with frameworks like Symfony 2.

###Autoloading

An autoloader class is provided for when loading ColorWorks yourself.

First, include the autoloader and call the static register() function.

<?phprequire_once'path/to/colorworks/lib/ColorWorks/Autoloader.php';
ColorWorks\Autoloader::register();
?>

Now all ColorWorks classes will be automatically loaded in.

###Converting between formats

ColorWorks can convert to and from any of the supported color formats:

<?phpuseColorWorks\Formats\Hex;
$red_hex = newHex(0xFF0000);
$red_cmyk = $hex->toCMYK();
echoget_class($red_cmyk); // ColorWorks\Formats\CMYKecho$red_cmyk; // 0,1,1,0?>

Any color manipulation or conversion will return a new instance of a color class, therefore your original color objects remains intact.

Color manipulation can be chained together:

<?phpuseColorWorks\Formats\Hex;
echo Hex::fromString('red')->hue(-20)->greyscale(); // 555555?>

Any color manipulation will always return the color in the same format unless you're specifically converting the format. For example:

<?phpuseColorWorks\Formats\RGB;
$red = newRGB(255, 0, 0);
echoget_class($red->hue(-20)->saturation(2)); // ColorWorks\Formats\RGB?>

###Supported formats:

<?phpnewRGB(r, g, b);
newCMY(c, m, y);
newCMYK(c, m, y, k);
newHex(0x000000);
newHSV(h, s, v);
newCIELab(l, a, b);
newCIELCh(l, c, h);
newXYZ(x, y, z);
newYxy(Y, x, y);

###Conversion functions:

<?php
->toRGB();
->toCMY();
->toCMYK();
->toHex();
->toHSV();
->toCIELab();
->toCIELCh();
->toXYZ();
->toYxy();

About

ColorWorks is a PHP library for manipulating and converting colors.

Resources

Stars

0 stars

Watchers

13 watching

Forks

Releases

Packages

Used by

Contributors

Languages