public static function interpolate(Color $color1, Color $color2, $part = 0.5) { $color = new Color(); $hsv = ['h' => null, 's' => null, 'v' => null]; $color1Hsv = $color1->getHsv(); $color2Hsv = $color2->getHsv(); foreach ($hsv as $key => $value) { if ($color1Hsv[$key] < $color2Hsv[$key]) { $outLength = 1 - $color2Hsv[$key] + $color1Hsv[$key]; if ($key == 'h' && $outLength < 0.5) { $hsv[$key] = $color2Hsv[$key] + $outLength * $part; if ($hsv[$key] > 1) { $hsv[$key]--; } } else { $hsv[$key] = ($color2Hsv[$key] - $color1Hsv[$key]) * $part + $color1Hsv[$key]; } } else { $outLength = 1 - $color1Hsv[$key] + $color2Hsv[$key]; if ($key == 'h' && $outLength < 0.5) { $hsv[$key] = $color1Hsv[$key] + $outLength * $part; if ($hsv[$key] > 1) { $hsv[$key]--; } } else { $hsv[$key] = ($color1Hsv[$key] - $color2Hsv[$key]) * $part + $color2Hsv[$key]; } } } $color->setHsv($hsv); return $color; }
/** * * @param Color $c * * @return string */ public function getColorValue(Color $c = null) { if ($c) { return $c->toString(); } return null; }
/** * Getting a color palette * For now we only have a hsv palette, could be extended with more options * * Potential options: * Standard CKEditor color palette * http://stackoverflow.com/questions/13455922/display-only-few-desired-colors-in-a-ckeditor-palette * 000,800000,8B4513,2F4F4F,008080,000080,4B0082,696969,B22222,A52A2A,DAA520,006400,40E0D0,0000CD,800080,808080,F00,FF8C00,FFD700,008000,0FF,00F,EE82EE,A9A9A9,FFA07A,FFA500,FFFF00,00FF00,AFEEEE,ADD8E6,DDA0DD,D3D3D3,FFF0F5,FAEBD7,FFFFE0,F0FFF0,F0FFFF,F0F8FF,E6E6FA,FFF * * Consider adding color names like this: * http://stackoverflow.com/questions/2993970/function-that-converts-hex-color-values-to-an-approximate-color-name * * Color variation: * http://stackoverflow.com/questions/1177826/simple-color-variation * * @param int $numColors Number of colors - default: 30 * @return null */ public static function get_palette($numColors = 50, $type = 'hsv') { //overwriting with the palette from the calendar settings $s = CalendarConfig::subpackage_settings('colors'); $arr = $s['basepalette']; return $arr; if ($type == 'hsv') { $s = 1; $v = 1; $arr = array(); for ($i = 0; $i <= $numColors; $i++) { $c = new Color(); $h = $i / $numColors; $hex = $c->fromHSV($h, $s, $v)->toHexString(); $arr[$hex] = $hex; } return $arr; } elseif ($type == 'websafe') { //websafe colors $cs = array('00', '33', '66', '99', 'CC', 'FF'); $arr = array(); for ($i = 0; $i < 6; $i++) { for ($j = 0; $j < 6; $j++) { for ($k = 0; $k < 6; $k++) { $c = $cs[$i] . $cs[$j] . $cs[$k]; $arr["{$c}"] = "#{$c}"; } } } return $arr; } }
public function testColor() { $redColor = new Color('red'); $blueColor = new Color('blue'); $this->assertSame('red', (string) $redColor); $this->assertSame(100, $redColor->compareTo($redColor)); $this->assertSame(29, $redColor->compareTo($blueColor)); }
function PageContent() { ?> <div class="layout center-flex"> <?php $aLabels = array(); $aLinks = array(); $aLabels[0] = 'Home'; $aLinks[0] = 'mainpage.php'; $aLabels[1] = 'Category List'; $aLinks[1] = 'category_list.php'; $aLabels[2] = 'Color'; $aLinks[2] = ''; echo Helpers::CreateBreadCrumbs($aLabels, $aLinks); ?> <div class="bigbotspace flex-container space-between"> <p class="larger auto heading">Color</p> <!-- <a href="category_admin.php" class="button_link"><button class="">Add New Color</button></a> --> </div> </div> <div class="layout"> <table class="tablestyle" id="list_table"> <thead> <tr> <th>ID</th> <th>Overview Text</th> <th>Images</th> <th class="mid">Actions</th> </tr> </thead> <tbody> <?php $objColor = new Color(); $oColor = $objColor->GetAllColorByCategoryId($_REQUEST['cat']); $objColorImage = new ColorImage(); foreach ($oColor as $color) { echo '<tr id="img_' . $color->Id . '">' . PHP_EOL; echo '<td>' . $color->Id . '</td>' . PHP_EOL; echo '<td>' . substr($color->OverviewText, 0, 200) . '</td>' . PHP_EOL; echo '<td>(<a href="colorimage_list.php?cat=' . $_REQUEST['cat'] . '&color=' . $color->Id . '">' . $objColorImage->getCountColorImageByColorId($color->Id) . '</a>)</td>' . PHP_EOL; echo '<td class="mid"><a href="color_admin.php?cat=' . $_REQUEST['cat'] . '&id=' . $color->Id . '"><img src="img/edit-icon.png" /></a></td>' . PHP_EOL; echo '</tr>' . PHP_EOL; } ?> </tbody> </table> </div> <!-- layout --> <?php }
/** * Creates new image instance * * @param integer $width * @param integer $height * @param string $background * @return \Intervention\Image\Image */ public function newImage($width, $height, $background = null) { // create empty resource $core = imagecreatetruecolor($width, $height); $image = new \Intervention\Image\Image(new static(), $core); // set background color $background = new Color($background); imagefill($image->getCore(), 0, 0, $background->getInt()); return $image; }
public function __construct() { $this->measure = 0; $this->title = Marker::$defaultTitle; $color = new Color(); $color->setR(Marker::$defaultColor[0]); $color->setG(Marker::$defaultColor[1]); $color->setB(Marker::$defaultColor[2]); $this->color = $color; }
function __construct(Color $color1, Color $color2, $direction = 0) { $this->direction = $direction; $cs = $color1->getRGBA(); $cd = $color2->getRGBA(); $cf = array($cs[0], $cs[1], $cs[2]); $cl = array($cd[0], $cd[1], $cd[2]); $cd = array($cl[0] - $cf[0], $cl[1] - $cf[1], $cl[2] - $cf[2]); $this->colors = array('first' => $cf, 'last' => $cl, 'delta' => $cd); }
public static function colorGradientPalette(Color $color1, Color $color2, $shades) { $palette = new Palette(); $RFactor = ($color2->getR() - $color1->getR()) / $shades; $GFactor = ($color2->getG() - $color1->getG()) / $shades; $BFactor = ($color2->getB() - $color1->getB()) / $shades; for ($i = 0; $i <= $shades - 1; $i++) { $palette->colors[$i] = new Color($color1->getR() + $RFactor * $i, $color1->getG() + $GFactor * $i, $color1->getB() + $BFactor * $i); } return $palette; }
public function postAgregacolor() { $color = new Color(); $color->nombre = Input::get('nombre_color'); $color->save(); $material_color = new MaterialColor(); $material_color->color_id = $color->id; $material_color->material_id = Input::get('material_id'); $material_color->save(); return Redirect::action('InventarioRecubControlador@getColores'); }
private function _configure() { TileCache::$daysToRemember = $this->_conf->get('tile_cache_days_of_memory'); TileCache::$numberOfFilesToDelete = $this->_conf->get('tile_cache_number_of_files_to_delete'); TilesGetter::$limitOfTiles = $this->_conf->get('max_number_of_tiles_per_map'); $defaultColor = new Color(); $defaultColor->setColor($this->_conf->get('default_drawings_color')); DrawRequest::$defaultColor = $defaultColor; DrawRequest::$defaultThickness = new ParamThickness($this->_conf->get('default_path_thickness')); DrawRequest::$defaultTransparency = new ParamTransparency($this->_conf->get('default_drawings_transparency')); ParamPatternUrl::$patternMap = $this->_conf->get('pattern_point_image_map'); }
function hsl2hex(Rule $rule) { $hsl_patt = Regex::make('~{{ LB }}hsl({{ parens }})~i'); foreach ($rule->declarations->filter(array('skip' => false)) as $declaration) { if (isset($declaration->functions['hsl'])) { $declaration->value = preg_replace_callback($hsl_patt, function ($m) { $color = new Color($m[0]); return $color->getHex(); }, $declaration->value); } } }
/** * Creates new image instance * * @param integer $width * @param integer $height * @param string $background * @return \Intervention\Image\Image */ public function newImage($width, $height, $background = null) { $background = new Color($background); // create empty core $core = new \Imagick(); $core->newImage($width, $height, $background->getPixel(), 'png'); $core->setType(\Imagick::IMGTYPE_UNDEFINED); $core->setImageType(\Imagick::IMGTYPE_UNDEFINED); $core->setColorspace(\Imagick::COLORSPACE_UNDEFINED); // build image $image = new \Intervention\Image\Image(new static(), $core); return $image; }
public function makeHue() { if ($this->hasErrors() || (string) $this->hue != '') { return; } if (!is_array($this->rgb) || count($this->rgb) !== 3) { return; } list($r, $g, $b) = $this->rgb; $color = new \Color(); $color->fromRgbInt($r, $g, $b); $hsv = $color->toHsvFloat(); $this->hue = (int) round($hsv['hue']); }
function _admin_color($loff = 0, $satc = null, $sat_abs = false) { // nacteni a uprava barev $h = $GLOBALS['hue']; if ($GLOBALS['dark']) { $l = $GLOBALS['light'] - $loff; } else { $l = $GLOBALS['light'] + $loff; } $s = isset($satc) ? $sat_abs ? $satc : $GLOBALS['sat'] * $satc : $GLOBALS['sat']; // vytvoreni hex kodu barvy $color = new Color(array($h, $l, $s), 1); return $color->getRGBStr(); }
/** * Get hash code * * @return string Hash code */ public function getHashCode() { if ($this->isSupervisor) { return $this->getSharedComponent()->getHashCode(); } return md5($this->borderStyle . $this->color->getHashCode() . __CLASS__); }
public static function search_data($vehicle_data, $driver = NULL) { if (!empty($vehicle_data)) { $vehicles_vin = $vehicle_data->vehicles_vin; $vehicles_model_id = $vehicle_data->vehicles_model_id; $vehicles_use_type_id = $vehicle_data->vehicles_use_type; $vehicle_color = Color::find($vehicle_data->vehicles_color)->colors_name; $owner = $vehicle_data->owners; foreach ($owner as $own) { $owner_names['name'][] = $own->drivers_fname . " " . $own->drivers_lname; } if (!isset($owner_names)) { $owner_names = null; } $model = Model::find($vehicles_model_id); $model_make_id = $model->model_make_id; $model_name = $model->model_name; $vehicle_use_types_name = VehicleUseType::find($vehicles_use_type_id)->vehicle_use_types_name; $result_data[] = array('id' => $vehicle_data->id, 'vin_number' => $vehicles_vin, 'model_make_id' => $model_make_id, 'model_name' => $model_name, 'color' => $vehicle_color, 'owner' => $owner_names, 'vehicle_use_types_name' => $vehicle_use_types_name); if ($driver) { return $result_data; } Helpers::response_data('200', 'success', $result_data); } else { Helpers::response_data('404', 'No record found', NULL); } }
public static function replace($full_text, $search_regexp, $color) { $new_text = preg_replace_callback("/({$search_regexp})/", function ($matches) use($color) { return Color::set($matches[1], $color); }, $full_text); return is_null($new_text) ? $full_text : $new_text; }
/** * Create a new awimage */ function create() { if ($this->resource === NULL) { // Create image $this->resource = imagecreatetruecolor($this->width, $this->height); if (!$this->resource) { trigger_error("Unable to create a graph", E_USER_ERROR); } imagealphablending($this->resource, TRUE); if ($this->antiAliasing and function_exists('imageantialias')) { imageantialias($this->resource, TRUE); } $this->drawer = new awDrawer($this->resource); $this->drawer->setImageSize($this->width, $this->height); // Original color $this->drawer->filledRectangle(new awWhite(), new awLine(new awPoint(0, 0), new awPoint($this->width, $this->height))); $shadow = $this->shadow->getSpace(); $p1 = new awPoint($shadow->left, $shadow->top); $p2 = new awPoint($this->width - $shadow->right - 1, $this->height - $shadow->bottom - 1); // Draw image background $this->drawer->filledRectangle($this->background, new awLine($p1, $p2)); $this->background->free(); // Draw image border $this->border->rectangle($this->drawer, $p1, $p2); } }
function values(array $v = NULL) { if ($v !== NULL) { if (isset($v['bgcolors']) && is_array($v['bgcolors'])) { $this->values['bgcolors'] = array_filter($v['bgcolors'], function ($a) { return $a instanceof Color; }); } if (isset($v['fgcolors']) && is_array($v['fgcolors'])) { $this->values['fgcolors'] = array_filter($v['fgcolors'], function ($a) { return $a instanceof Color; }); } if (isset($v['font']) && $v['font'] instanceof Font) { $this->values['font'] = $v['font']; } if (isset($v['labels'])) { $this->values['labels'] = $v['labels']; } if (count($this->values['bgcolors']) == 0) { $this->values['bgcolors'][] = Color::getDefault(); } if (count($this->values['fgcolors']) == 0) { $this->values['fgcolors'][] = Color::getDefault(); } } return $this->values; }
public function __construct() { $this->color = Color::create('000000'); $this->type = GoogleChartLabelStyleNumberType::create(); $this->size = 10; $this->dataPoint = -1; }
/** * @covers Image\Helper\Color::differs */ public function testDiffers() { $color1 = array('red' => 127, 'green' => 255, 'blue' => 0, 'alpha' => 0); $color2 = array('red' => 255, 'green' => 0, 'blue' => 127, 'alpha' => 50); $this->assertTrue($this->object->differs($color1, $color2)); $this->assertFalse($this->object->differs($color1, $color1)); }
public static function getDyeColor($id) { if (isset(self::$dyeColors[$id])) { return clone self::$dyeColors[$id]; } return Color::getRGB(0, 0, 0); }
function loop_color_range() { $args = func_get_args(); $source_colors = array(); while ($args && ($color = Color::parse($args[0]))) { $source_colors[] = $color; array_shift($args); } $steps = max(1, isset($args[0]) ? (int) $args[0] : 1); $generated_colors = array(); foreach ($source_colors as $index => $source_color) { $generated_colors[] = new Color($source_color); // Generate the in-between colors. $next_source_color = isset($source_colors[$index + 1]) ? $source_colors[$index + 1] : null; if (!$next_source_color) { break; } for ($i = 0; $i < $steps; $i++) { $rgba = array(); foreach ($source_color as $component_index => $component_value) { if ($component_diff = $next_source_color[$component_index] - $component_value) { $component_step = $component_diff / ($steps + 1); $rgba[] = min(round($component_value + $component_step * ($i + 1), 2), 255); } else { $rgba[] = $component_value; } } $generated_colors[] = new Color($rgba); } } return $generated_colors; }
/** * Returns the color index as used by PHP * * @return int */ public function getColorIndex() { if (!$this->index) { $this->index = Color::createColorIndex($this->rgb['r'], $this->rgb['g'], $this->rgb['b'], $this->rgb['a']); } return $this->index; }
public function getColorAt($x, $y) { if ($x < 0 || $x > $this->mWidth - 1 || $y < 0 || $y > $this->mHeight - 1) { return null; } $color = @imagecolorsforindex($this->mImage, @imagecolorat($this->mImage, $x, $y)); return Color::createFromRGBA($color['red'], $color['green'], $color['blue'], $color['alpha']); }
function printCard($cfg) { $suit = self::$suits[$cfg->charset][$this->suit]; if ($cfg->charset == CHARSET_REAL) { $suit = html_entity_decode($suit, ENT_COMPAT, 'UTF-8'); } $val = $this->face; $ret = " {$val}{$suit}"; if ($this->suit > 2) { $col = 'red'; } if ($cfg->color && $col) { $c = new Color(); $ret = $c->red($ret); } return $ret; }
/** * The default action - show the home page */ public function indexAction() { $this->view->Title = 'Màu xe - Phong thủy'; $this->view->headTitle($this->view->Title); $condition = array(); $page = $this->getRequest()->getParam('page'); list($this->view->Pager, $this->view->Color) = Color::getAll($condition, $page, 40, $order = 'id DESC'); }
public function testFind() { self::assertEquals(Shell::GNOME, Shell::find('Gnome')); self::assertEquals(Shell::UNITY, Shell::find('Cinnamon')); self::assertNull(Color::find(Shell::GNOME)); self::assertEquals(Color::GREY, Color::find('#808080')); self::assertNotEquals(Color::GRAY, Color::find('#808080')); }
public static function prefixOutput($prefix, $text, $color = null) { $prefix = " " . str_pad($prefix, 8); if ($color) { $prefix = Color::makeColor($prefix, $color); } static::output($prefix . "" . self::PREFIX . "\t" . $text); }