Here are some code examples of the usage at present. Please note: Dec =
Decimals, Pc = Percentages, Frac = Fractions, Deg = Degrees
// Get RGB object from hex code
$rgb = Jack_Color::hexToRgb('#0000ff');
// Get RGB object named color
$rgb = Jack_Color::namedToRgb('LightBlue');
// Create an RGB object
$rgb = new Jack_Color_Rgb(0, 0, 255);
// Create an RGB object using percentages
$rgb = new Jack_Color_Rgb(0, 0, 100, Jack_Color_Rgb::PC);
// Get the RGB values
$rgb = new Jack_Color_Rgb(0, 0, 255);
$rgb->getDec(); // array(0, 0, 255)
$rgb->getPc(); // array(0, 0, 100)
$rgb->getFrac(); // array(0, 0, 1)
$rgb->getHex(); // "0000ff"
echo $rgb; // "#0000ff"
$rgb->getCssRgbDec(); // "rgb(0,0,255)"
$rgb->getCssRgbPc(); // "rgb(0%,0%,100%)"
// Make a colour web safe
$rgb = Jack_Color::hexToRgb('#3d3dd3');
$rgb->makeWebSafe();
$rgb->getHex(); // "3333cc"
// Check W3C visibility
$color1 = Jack_Color::hexToRgb('#ffffff');
$color2 = Jack_Color::hexToRgb('#000000');
$color1->passesW3cContrast($color2); // true
// Convert RGB to HSL
$rgb = new Jack_Color_Rgb(51, 51, 204);
$hsl = $rgb->getHsl();
// Get HSL values
$hsl->getDegPc(); // array(240, 75, 80)
$hsl->getCssHsl(); // "hsl(240,75%,80%)"
// Modify color variables
$hsl = new Jack_Color_Hsl(240, 75, 80);
$hsl->adjLightness(10);
$hsl->adjLightness(-10);
// Create a 10 step gradient from black to white
// This implements ArrayIterator
$gradient = new Jack_Color_Gradient(array(
new Jack_Color_Rgb(0, 0, 0),
new Jack_Color_Rgb(255, 255, 255)
), 10);
--
View this message in context:
http://www.nabble.com/Zend_Color-Component--tf4044723s16154.html#a11489673
Sent from the Zend Framework mailing list archive at Nabble.com.