function handleState($state, $map, $red, $green, $blue, $figure, $rank) { $color = rgb2html($red, $green, $blue); $map = textReplace($map, $state, $figure, $rank); $map = boxReplace($map, $state, $color); $map = colorReplace($map, $state, $color); return $map; }
function embroidery2svg($embroidery, $scale = 1) { // header('Content-Type: image/svg+xml'); $xml = new SimpleXMLElement('<svg />'); $xml->addAttribute('xmlns', 'http://www.w3.org/2000/svg'); $xml->addAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink'); $xml->addAttribute('xmlns:ev', 'http://www.w3.org/2001/xml-events'); $xml->addAttribute('version', '1.1'); $xml->addAttribute('baseProfile', 'full'); $xml->addAttribute('width', $embroidery->imageWidth * $scale); $xml->addAttribute('height', $embroidery->imageHeight * $scale); foreach ($embroidery->blocks as $block) { $line = $xml->addChild('path'); $line->addAttribute('stroke', rgb2html($block->color->r, $block->color->g, $block->color->b)); $line->addAttribute('fill', 'none'); $points = ''; foreach ($block->stitches as $stitch) { $points .= ($points ? ' L ' : 'M ') . ($stitch->x - $embroidery->min->x) * $scale . ' ' . ($stitch->y - $embroidery->min->y) * $scale; } $line->addAttribute('d', $points); } return $xml->asXML(); }
rvBytes.addRows(<?php echo count($breakdownRv); ?> ); <?php $index = 0; ksort($breakdownRv); foreach ($breakdownRv as $type => $data) { echo "dataRv.setValue({$index}, 0, '{$type}');\n"; echo "dataRv.setValue({$index}, 1, {$data['requests']});\n"; echo "dataRv.setValue({$index}, 2, {$data['bytes']});\n"; echo "rvRequests.setValue({$index}, 0, '{$type}');\n"; echo "rvRequests.setValue({$index}, 1, {$data['requests']});\n"; echo "rvBytes.setValue({$index}, 0, '{$type}');\n"; echo "rvBytes.setValue({$index}, 1, {$data['bytes']});\n"; $color = rgb2html($data['color'][0], $data['color'][1], $data['color'][2]); echo "rvColors.push('{$color}');\n"; $index++; } ?> var viewRequestsRv = new google.visualization.DataView(dataRv); viewRequestsRv.setColumns([0, 1]); var tableRequestsRv = new google.visualization.Table(document.getElementById('tableRequestsRv_div')); tableRequestsRv.draw(viewRequestsRv, {showRowNumber: false, sortColumn: 1, sortAscending: false}); var viewBytesRv = new google.visualization.DataView(dataRv); viewBytesRv.setColumns([0, 2]); var tableBytesRv = new google.visualization.Table(document.getElementById('tableBytesRv_div'));
} $r = hexdec($r); $g = hexdec($g); $b = hexdec($b); return array($r, $g, $b); } function rgb2html($r, $g = -1, $b = -1) { if (is_array($r) && sizeof($r) == 3) { list($r, $g, $b) = $r; } $r = intval($r); $g = intval($g); $b = intval($b); $r = dechex($r < 0 ? 0 : ($r > 255 ? 255 : $r)); $g = dechex($g < 0 ? 0 : ($g > 255 ? 255 : $g)); $b = dechex($b < 0 ? 0 : ($b > 255 ? 255 : $b)); $color = (strlen($r) < 2 ? '0' : '') . $r; $color .= (strlen($g) < 2 ? '0' : '') . $g; $color .= (strlen($b) < 2 ? '0' : '') . $b; return '<div style="background:#' . $color . ';"><a href="#">#' . $color . '</a></div>'; } $a = html2rgb('ffffe0'); $b = html2rgb('ff9480'); $size = 9; echo '<link rel="stylesheet" href="css/style.css" />'; echo '<div class="contenttable">'; for ($i = 0; $i <= 100; $i += 100 / ($size - 1)) { echo rgb2html(array($a[0] + ($b[0] - $a[0]) * $i / 100, $a[1] + ($b[1] - $a[1]) * $i / 100, $a[2] + ($b[2] - $a[2]) * $i / 100)) . "\n"; } echo '</div>';
function random_color() { mt_srand((double) microtime() * 1000000); /* $color = ''; while(strlen($color)<6){ $color .= sprintf("%02X", mt_rand(0, 255)); } */ $r = mt_rand(0, 200); $g = mt_rand(0, 200); $b = mt_rand(0, 200); return rgb2html($r, $g, $b); }
function get_bottom_color_from_image($imagepath) { // get a sample color from the image, for matching CSS color $image = imagecreatefromgif($imagepath); $imageheight = imagesy($image); $colorindex = imagecolorat($image, 1, $imageheight - 1); $color = imagecolorsforindex($image, $colorindex); $color = rgb2html($color['red'], $color['green'], $color['blue']); return $color; }
} echo "<tr>"; echo "<td>"; echo $racename; echo "</td><td><a href='http://www.ownageclan.com/plot/?raceshort=" . $raceshort . "' target='_blank'>" . $raceshort . "</a></td><td></td>"; echo "<td>" . $kills . "</td>"; echo "<td>" . $deaths . "</td>"; $hex = rgb2html(abs($kdr - 1) / 0.3 * 255, 255 - abs($kdr - 1) / 0.4 * 255, (1 - $kdr) / 0.3 * 155); echo "<td><FONT COLOR='{$hex}'>" . $kdr . "</FONT></td>"; $kdr = '-'; if ($wins > 50 && $losses > 50) { echo "<td></td>"; echo "<td>" . $wins . "</td>"; echo "<td>" . $losses . "</td>"; $kdr = number_format($wins / $losses, 2); $hex = rgb2html(abs($kdr - 1) / 0.3 * 255, 255 - abs($kdr - 1) / 0.4 * 255, (1 - $kdr) / 0.3 * 155); echo "<td><FONT COLOR='{$hex}'>" . $kdr . "</FONT></td>"; // } else { echo "<td></td><td></td><td></td><td></td>"; } if ($timeplayed) { echo "<td></td>"; if (isset($all[$raceshort]['timeplayed'])) { echo "<td>" . round($all[$raceshort]['timeplayed'] / 10) . "</td>"; //10 days } else { echo "<td></td>"; } } echo "</tr>";
$b = intval($b); $r = dechex($r < 0 ? 0 : ($r > 255 ? 255 : $r)); $g = dechex($g < 0 ? 0 : ($g > 255 ? 255 : $g)); $b = dechex($b < 0 ? 0 : ($b > 255 ? 255 : $b)); $color = (strlen($r) < 2 ? '0' : '') . $r; $color .= (strlen($g) < 2 ? '0' : '') . $g; $color .= (strlen($b) < 2 ? '0' : '') . $b; return '#' . $color; } $hue = $_POST["hue"]; $dataclasses = $_POST["classes"]; $colors = $_POST["colorstring"]; $colorobject = json_decode($colors); $colors = stripslashes($colors); $obj = json_decode($colors); $min = 17; $max = 32; $ranges = (int) $dataclasses - 2; $delta = ($max - $min) / $ranges; echo "// Colors by ColorBrewer.org, Cynthia A. Brewer, Penn State.\n"; echo "// Profile: '" . $hue . "' with " . $dataclasses . " data classes\n"; echo "var col = function(v) {\n"; for ($i = 1; $i <= (int) $dataclasses; $i++) { $hex = rgb2html($obj->{(string) $i}); $valu = $min + $delta * ($i - 1); if ($i != (int) $dataclasses) { echo "if (v < " . $valu . ") return '" . $hex . "';\n"; } else { echo "return '" . $hex . "';\n};"; } }
$g = intval($g); $b = intval($b); $r = dechex($r < 0 ? 0 : ($r > 255 ? 255 : $r)); $g = dechex($g < 0 ? 0 : ($g > 255 ? 255 : $g)); $b = dechex($b < 0 ? 0 : ($b > 255 ? 255 : $b)); $color = (strlen($r) < 2 ? '0' : '') . $r; $color .= (strlen($g) < 2 ? '0' : '') . $g; $color .= (strlen($b) < 2 ? '0' : '') . $b; return '#' . $color; } $table2 = ""; if ($rid > 0) { $rs = pg_prepare($mesosite, "-SELECT", "SELECT * from iemrasters_lookup" . " WHERE iemraster_id = \$1 ORDER by coloridx ASC"); $rs = pg_execute($mesosite, "-SELECT", array($rid)); for ($i = 0; $row = @pg_fetch_assoc($rs, $i); $i++) { $table2 .= sprintf("<tr><td>%s</td><td>%s</td><td>%s</td>" . "<td>%s</td><td>%s</td><td>%s</td></tr>\n", $row["coloridx"], $row["value"] == null ? 'Missing' : $row["value"], $row["r"], $row["g"], $row["b"], rgb2html($row["r"], $row["g"], $row["b"])); } } $t->content = <<<EOF <ol class="breadcrumb"> <li><a href="/GIS/">GIS Mainpage</a></li> <li class="active">IEM RASTER Lookup Tables</li> </ol> <h3>IEM RASTER Lookup Tables</h3> <p>The IEM produces a number of RASTER images meant for GIS use. These RASTERs are typically provided on the IEM website as 8 bit PNG images. This means there are 256 slots available for a binned value to be placed. This page attempts to document these RASTER images and provide the lookup table of PNG index to an actual value. Click on the item in the "Label" column to get the lookup
function et_customizer_print_styles() { if (current_user_can('manage_options') && !is_admin()) { et_enqueue_gfont(); wp_register_style('et_colorpicker', TEMPLATEURL . '/customizer/css/colorpicker.css', array('custom')); wp_enqueue_style('et_colorpicker'); wp_register_style('et_customizer_css', TEMPLATEURL . '/customizer/css/customizer.css', array('custom')); wp_enqueue_style('et_customizer_css'); ?> <script type="text/javascript" id="ae-customizer-script"> var customizer = {}; <?php $style = et_get_customization(); foreach ($style as $key => $value) { $variable = $key; //$variable = str_replace('-', '_', $key); if (preg_match('/^rgb/', $value)) { preg_match('/rgb\\(([0-9]+), ([0-9]+), ([0-9]+)\\)/', $value, $matches); $val = rgb2html($matches[1], $matches[2], $matches[3]); echo "customizer['{$variable}'] = '{$val}';\n"; } else { echo "customizer['{$variable}'] = '" . stripslashes($value) . "';\n"; } } ?> </script> <?php } }
#!/usr/bin/php <?php require_once 'pes.php'; $embroidery = new PesFile($argv[1]); $xml = new SimpleXMLElement('<svg />'); $xml->addAttribute('xmlns', 'http://www.w3.org/2000/svg'); $xml->addAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink'); $xml->addAttribute('xmlns:ev', 'http://www.w3.org/2001/xml-events'); $xml->addAttribute('version', '1.1'); $xml->addAttribute('baseProfile', 'full'); $xml->addAttribute('width', $embroidery->imageWidth); $xml->addAttribute('height', $embroidery->imageHeight); foreach ($embroidery->blocks as $block) { $line = $xml->addChild('path'); $line->addAttribute('stroke', rgb2html($block->color->r, $block->color->g, $block->color->b)); $line->addAttribute('fill', 'none'); $points = ''; foreach ($block->stitches as $stitch) { $points .= ($points ? ' L ' : 'M ') . ($stitch->x - $embroidery->min->x) . ' ' . ($stitch->y - $embroidery->min->y); } $line->addAttribute('d', $points); } header('Content-Type: image/svg+xml'); echo $xml->asXML(); exit(0); function rgb2html($r, $g, $b) { return '#' . substr('0' . dechex($r), -2) . substr('0' . dechex($g), -2) . substr('0' . dechex($b), -2); }