include '../../vendor/autoload.php'; $colors = [Color::RED, Color::BLUE, Color::GREEN, Color::YELLOW]; $palette = new SimplePalette(); foreach ($colors as $color) { //Add the tetradic scheme for each color $palette = Palette::merge($palette, new TetradicScheme($color)); } //Only take blue-ish colors $palette = Palette::filterByHueRange($palette, Color::HUE_RANGE_BLUE); //Avoid similar colors $palette = Palette::filterSimilarColors($palette, 8); //Print a nice HTML representation of the palette for debugging echo Palette::getHtml($palette, 4); exit; $hueRange = isset($_GET['hue']) ? $_GET['hue'] : 'red'; $colorNames = array_values(\Phim\color_get_names()); ?> <h1>Color palette manipulation and color finding</h1> <p> Let's take all named colors, build tetradic complements for them and filter out the coolest values of a specific hue range. <br> <br> <a href="?hue=red">Red</a> | <a href="?hue=yellow">Yellow</a> | <a href="?hue=blue">Blue</a> | <a href="?hue=cyan">Cyan</a> | <a href="?hue=green">Green</a> | <a href="?hue=magenta">Magenta</a> </p> <?php $palette = new SimplePalette(); foreach ($colorNames as $color) { $palette = $palette->add(new TetradicScheme($color)); }
$color = color_get($hex); echo \Phim\color_get_html($color); $mc = new \Phim\Color\Scheme\HueRotationScheme($color, 20, 5); foreach ($mc as $compareColor) { echo '<div style="display: inline-block; vertical-align: top; text-align: center;">'; echo \Phim\color_get_html($compareColor); echo '<br>'; echo '<span style="padding: 10px;">' . \Phim\Color::getDifference($color, $compareColor) . '</span>'; echo '</div>'; } echo '<br>'; } echo '</div>'; echo '<h1>Finding visually similar colors (Tolerance: ' . $t . ', control with <url>?t=<tolerance>)</h1>'; echo '<div style="white-space: nowrap;">'; foreach ($names as $name => $hex) { $color = color_get($hex); echo \Phim\color_get_html($color); foreach (\Phim\color_get_names() as $compareColor) { $deltaE = \Phim\Color::getDifference($color, color_get($compareColor)); if ($deltaE < $t) { echo '<div style="display: inline-block; vertical-align: top; text-align: center;">'; echo Phim\Color::getHtml(color_get($compareColor)); echo '<br>'; echo '<span style="padding: 10px;">' . $deltaE . '</span>'; echo '</div>'; } } echo '<br>'; } echo '</div>';
<?php include '../../vendor/autoload.php'; $names = array_replace(['fullred' => '#f00', 'fullgreen' => '#0f0', 'fullblue' => '#00f', 'fullyellow' => '#ff0', 'fullcyan' => '#0ff', 'fullmagenta' => '#f0f'], \Phim\color_get_names()); foreach ($names as $name => $hex) { echo \Phim\color_get_html($hex); echo $name . ' => ' . \Phim\color_get_hue_range($hex); echo '<br>'; }