Esempio n. 1
0
 /** Returns an array containing the two web safe colors closest to the
  *actual color represented by the current ColorChip.
  *@return array An array containing the two ColorChip objects of the closest web safe colors to the original
  *@see RenderWebSafeDither
  *@access public
  */
 function getWebSafeDither()
 {
     $color1 = $this->getNearestWebSafe();
     $color2 = $this->clone();
     $color2->r = ColorChip::getNearestWebSafeComponent($color2->r, CC_WEBSAFE_ALT);
     $color2->g = ColorChip::getNearestWebSafeComponent($color2->g, CC_WEBSAFE_ALT);
     $color2->b = ColorChip::getNearestWebSafeComponent($color2->b, CC_WEBSAFE_ALT);
     $color2->_updateHsv();
     $color2->_updateHex();
     return array($color1, $color2);
 }
Esempio n. 2
0
    echo <<<END
    <p>To switch to a new color, click on the hex value of any color below, or enter a new one of your own at the bottom of the page.</p>

<ul>
    <li><a href='#websafe'>Nearest Web Safe</a></li>
    <li><a href='#complement'>Complementary Color</a></li>
    <li><a href='#triad'>Triad Colors</a></li>
    <li><a href='#lighttodark'>Light to Dark</a></li>
    <li><a href='#hues'>Nearby Hues</a></li>
    <li><a href='#sat'>Saturation Range</a></li>
    <li><a href='#form'>Enter a New Color</a></li>
</ul>

END;
    $userColor = strtoupper($_GET['userColor']);
    $color = new ColorChip($userColor, null, null, CC_HEX);
    $complement = $color->getComplementary();
    $triad = $color->getTriad();
    echo "<h2>Original Color:</h2>";
    makeColorDiv($color);
    //Show the nearest web safe color
    $webSafe = $color->getNearestWebSafe();
    echo "<a name='websafe'/>\n<h2>Nearest Web Safe</h2>";
    makeColorDiv($webSafe);
    //Show complementary color:
    echo "<a name='complement'/>\n<h2>Complementary Color:</h2>";
    makeColorDiv($complement);
    //Show color triad:
    echo "<a name='triad'/>\n<h2>Triad</h2>";
    echo "<table>\n<tr>\n";
    echo "<td>";