/** * build the epocLevel Array automatically by calculating an array of colors * * @param string $latestColor color of latest epocLevel (usually dark) * @param string $earliestColor color of earliest epocLevel (usually light) * @param int $thresholds number of levels to generate colors for * * @return array epocLevel * * @since Method available since Release 0.2.0 */ private function _generateEpocLevel($latestColor, $earliestColor, $thresholds) { include_once 'Image/Color.php'; $imageColor = new Image_Color(); $imageColor->setWebSafe(false); $imageColor->setColors($latestColor, $earliestColor); $epocLevel = array(); foreach ($imageColor->getRange($thresholds) as $key => $color) { $epocLevel[]['epocLevel' . $key] = array('link' => $color, 'visited' => $color); } return array_reverse($epocLevel); }
/** * getRange * Given a degree, you can get the range of colors between one color and * another color. * * @param string $degrees How much each 'step' between the colors we should take. * * @return array Array of all the colors, one element for each color. * @access public */ function getRange($degrees) { $tempColors = parent::getRange($degrees); // now add alpha-channel information $steps = count($tempColors); for ($counter = 0; $counter < $steps; $counter++) { $tempColors[$counter] = parent::hex2rgb($tempColors[$counter]); unset($tempColors[$counter]['hex']); $tempColors[$counter][3] = (int) round(((double) $this->color1[3] * ($steps - $counter) + (double) $this->color2[3] * $counter) / $steps); } return $tempColors; }
/** * Get nearest colors between mask color and unmask color using * antialias factor. * * @return array Colors range. * @access private */ function _getNearestColors() { $imcolor = new Image_Color(); $imcolor->setColors($this->options['mask_color'], $this->options['unmask_color']); return $imcolor->getRange($this->options['antialias_factor']); }
break; case 'h24': return_ofc_24(); break; case 'cc': return_ofc_cc(); break; } exit; } // generate some colors for the activity bar $colors = ''; if ($ps->conf['theme']['map']['google_key']) { $c = new Image_Color(); $c->setColors('cc0000', '00cc00'); $range = $c->getRange(100, 1); foreach ($range as $i => $col) { $colors .= sprintf("<span id='color-%s'>%s</span>\n", $i, $col); } $colors .= "<span id='color-100'>00CC00</span>\n"; } // assign variables to the theme $cms->theme->assign(array('page' => basename($PHP_SELF, '.php'), 'activity_colors' => $colors)); // display the output $basename = basename(__FILE__, '.php'); if ($ps->conf['theme']['map']['google_key']) { $cms->theme->add_js('http://maps.google.com/maps?file=api&v=2&key=' . $ps->conf['theme']['map']['google_key']); // $cms->theme->add_js('http://www.google.com/jsapi?key=' . $ps->conf['theme']['map']['google_key']); $cms->theme->add_js('js/map.js'); } $cms->full_page($basename, $basename, $basename . '_header', $basename . '_footer');
function pct_bar($args = array()) { global $cms; require_once dirname(__FILE__) . "/class_Color.php"; $args += array('pct' => 0, 'color1' => 'cc0000', 'color2' => '00cc00', 'degrees' => 1, 'width' => null, 'class' => 'pct-bar', 'styles' => '', 'title' => null); static $colors = array(); if (!empty($args['width']) and (!is_numeric($args['width']) or $args['width'] < 1)) { $args['width'] = 100; } $w = $args['width'] ? $args['width'] : 100; // $width = $args['pct'] / 100 * $w; // scaled width $key = $args['color1'] . ':' . $args['color2']; if (!$colors[$key]) { $c = new Image_Color(); $c->setColors($args['color1'], $args['color2']); $colors[$key] = $c->getRange(100, $args['degrees']); // 100 colors, no matter the width /** foreach ($colors[$key] as $col) { printf("<div style='color: white; background-color: %s'>%s</div>", $col, $col); } /**/ } $styles = !empty($args['styles']) ? $args['styles'] : ''; if (!empty($args['width'])) { $styles = " width: " . $args['width'] . "px;"; } if (!empty($styles)) { $styles = " style='{$styles}'"; } $out = sprintf("<span %s title='%s'%s><span style='width: %s; background-color: #%s'></span></span>", !empty($args['class']) ? "class='" . $args['class'] . "'" : "", !empty($args['title']) ? $args['title'] : (int) $args['pct'] . '%', $styles, (int) $args['pct'] . '%', $colors[$key][intval($args['pct']) - 1]); return $out; }