public function ComRadar($Coord, $level) { list($CoordsX, $CoordsY) = map::ss2xy($Coord); $x = 1 + ($CoordsY - 1) * $this->tc + round($this->tc / 2); $y = 1 + ($CoordsX - 1) * $this->tc + round($this->tc / 2); $ray = $level * 20 * $this->tc; ImageFilledEllipse($this->im, $x, $y, $ray, $ray, $this->color); return $this; }
<?php ImageFilledEllipse($image, $size / 2, $size / 2, $size - 1, $size - 1, $black);
<?php //use existing image as a canvas $myImage = ImageCreateFromPNG("baseimage.png"); //allocate the color white $white = ImageColorAllocate($myImage, 255, 255, 255); //draw on the new canvas ImageFilledEllipse($myImage, 100, 70, 20, 20, $white); ImageFilledEllipse($myImage, 175, 70, 20, 20, $white); ImageFilledEllipse($myImage, 250, 70, 20, 20, $white); //output the image to the browser header("Content-type: image/png"); ImagePNG($myImage); //clean up after yourself ImageDestroy($myImage);
/** * Image_Graph_GradientFill [Constructor] * @param int $direction The direction of the gradient * @param int $startColor The RGB value of the starting color * @param int $endColor The RGB value of the ending color * @param int $count The number of steps to be made between the 2 colors (the more the more smooth, but more ressources are required). 100 is default. * @param int $alpha The alpha-blend (not supported yet) */ function &Image_Graph_Fill_Gradient($direction, $startColor, $endColor, $count = 100, $alpha = 0) { parent::__construct(); $this->_direction = $direction; $this->_startColor['RED'] = ($startColor >> 16) & 0xff; $this->_startColor['GREEN'] = ($startColor >> 8) & 0xff; $this->_startColor['BLUE'] = $startColor & 0xff; $this->_endColor['RED'] = ($endColor >> 16) & 0xff; $this->_endColor['GREEN'] = ($endColor >> 8) & 0xff; $this->_endColor['BLUE'] = $endColor & 0xff; $this->_count = $count; switch ($this->_direction) { case IMAGE_GRAPH_GRAD_HORIZONTAL : $width = $this->_count; $height = 1; break; case IMAGE_GRAPH_GRAD_VERTICAL : $width = 1; $height = $this->_count; break; case IMAGE_GRAPH_GRAD_HORIZONTAL_MIRRORED : $width = 2 * $this->_count; $height = 1; break; case IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED : $width = 1; $height = 2 * $this->_count; break; case IMAGE_GRAPH_GRAD_DIAGONALLY_TL_BR : case IMAGE_GRAPH_GRAD_DIAGONALLY_BL_TR : $width = $height = $this->_count / 2; break; case IMAGE_GRAPH_GRAD_RADIAL : $width = $height = sqrt($this->_count * $this->_count / 2); break; } if (isset($GLOBALS['_Image_Graph_gd2'])) { $this->_image = ImageCreateTrueColor($width, $height); } else { $this->_image = ImageCreate($width, $height); } $redIncrement = ($this->_endColor['RED'] - $this->_startColor['RED']) / $this->_count; $greenIncrement = ($this->_endColor['GREEN'] - $this->_startColor['GREEN']) / $this->_count; $blueIncrement = ($this->_endColor['BLUE'] - $this->_startColor['BLUE']) / $this->_count; for ($i = 0; $i <= $this->_count; $i ++) { if ($i == 0) { $red = $this->_startColor['RED']; $green = $this->_startColor['GREEN']; $blue = $this->_startColor['BLUE']; } else { $red = round(($redIncrement * $i) + $redIncrement + $this->_startColor['RED']); $green = round(($greenIncrement * $i) + $greenIncrement + $this->_startColor['GREEN']); $blue = round(($blueIncrement * $i) + $blueIncrement + $this->_startColor['BLUE']); } $color = ImageColorAllocate($this->_image, $red, $green, $blue); switch ($this->_direction) { case IMAGE_GRAPH_GRAD_HORIZONTAL : ImageSetPixel($this->_image, $i, 0, $color); break; case IMAGE_GRAPH_GRAD_VERTICAL : ImageSetPixel($this->_image, 0, $height - $i, $color); break; case IMAGE_GRAPH_GRAD_HORIZONTAL_MIRRORED : ImageSetPixel($this->_image, $i, 0, $color); ImageSetPixel($this->_image, $width - $i, 0, $color); break; case IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED : ImageSetPixel($this->_image, 0, $i, $color); ImageSetPixel($this->_image, 0, $height - $i, $color); break; case IMAGE_GRAPH_GRAD_DIAGONALLY_TL_BR : if ($i > $width) { $polygon = array ($width, $i - $width, $width, $height, $i - $width, $height); } else { $polygon = array (0, $i, 0, $height, $width, $height, $width, 0, $i, 0); } ImageFilledPolygon($this->_image, $polygon, count($polygon) / 2, $color); break; case IMAGE_GRAPH_GRAD_DIAGONALLY_BL_TR : if ($i > $height) { $polygon = array ($i - $height, 0, $width, 0, $width, 2 * $height - $i); } else { $polygon = array (0, $height - $i, 0, 0, $width, 0, $width, $height, $i, $height); } ImageFilledPolygon($this->_image, $polygon, count($polygon) / 2, $color); break; case IMAGE_GRAPH_GRAD_RADIAL : if (($GLOBALS['_Image_Graph_gd2']) and ($i < $this->_count)) { ImageFilledEllipse($this->_image, $width / 2, $height / 2, $this->_count - $i, $this->_count - $i, $color); } break; } } }
<?php $im = ImageCreateTruecolor(400, 300); ImageFilledRectangle($im, 0, 0, 399, 299, 0xffffff); ImageFilledEllipse($im, 200, 150, 300, 300, 0x0); ImageAlphaBlending($im, true); ImageFilledRectangle($im, 100, 0, 400, 100, 0x60ff1111); ImageFilledRectangle($im, 100, 100, 400, 200, 0x30ff1111); ImageFilledRectangle($im, 100, 200, 400, 300, 0x10ff1111); Header('Content-Type: image/png'); ImagePNG($im);
header("Content-type: image/png"); $width = 100; $height = 100; $r = 0; $g = 0; $b = 255; //$alpha = 0; if (isset($_GET['w'])) { $width = $_GET['w']; } if (isset($_GET['h'])) { $height = $_GET['h']; } if (isset($_GET['c'])) { $c = $_GET['c']; $r = hexdec($c[0] . $c[1]); $g = hexdec($c[2] . $c[3]); $b = hexdec($c[4] . $c[5]); } $im = imagecreatetruecolor($width, $height); $color = ImageColorAllocate($im, $r, $g, $b); $white = ImageColorAllocate($im, 255, 255, 255); imagefilltoborder($im, 0, 0, $white, $white); imagecolortransparent($im, $white); $cx = ceil($width / 2); $cy = ceil($height / 2); ImageFilledEllipse($im, $cx, $cy, $width - 1, $height - 1, $color); // send the new PNG image to the browser imagepng($im); // destroy the reference pointer to the image in memory to free up resources imagedestroy($im);
$code = substr($rcode, 2, NV_GFX_NUM); $image = imagecreate(NV_GFX_WIDTH, NV_GFX_HEIGHT); $bgc = imagecolorallocate($image, 240, 240, 240); imagefilledrectangle($image, 0, 0, NV_GFX_WIDTH, NV_GFX_HEIGHT, $bgc); $text_color = ImageColorAllocate($image, 50, 50, 50); /* output each character */ for ($l = 0; $l < 5; $l++) { $r = mt_rand(120, 255); $g = mt_rand(120, 255); $b = mt_rand(120, 255); $color_elipse = ImageColorAllocate($image, round($r * 0.9), round($g * 0.9), round($b * 0.9)); $cx = mt_rand(0, NV_GFX_WIDTH - NV_GFX_HEIGHT); $cy = mt_rand(0, NV_GFX_WIDTH - NV_GFX_HEIGHT); $rx = mt_rand(10, NV_GFX_WIDTH - NV_GFX_HEIGHT); $ry = mt_rand(10, NV_GFX_WIDTH - NV_GFX_HEIGHT); ImageFilledEllipse($image, $cx, $cy, $rx, $ry, $color_elipse); } $r = mt_rand(0, 100); $g = mt_rand(0, 100); $b = mt_rand(0, 100); $text_color = ImageColorAllocate($image, $r, $g, $b); $ff = mt_rand(1, 15); $font = NV_ROOTDIR . "/includes/fonts/captcha/font" . $ff . ".ttf"; if (file_exists($font) and function_exists('imagettftext')) { imagettftext($image, 15, 0, 5, NV_GFX_HEIGHT - 3, $text_color, $font, $code); } else { ImageString($image, 5, 20, 6, $code, $text_color); } Header("Content-type: image/jpeg"); header("Cache-Control:"); header("Pragma:");
protected function DrawBubbles() { if (!$this->CheckDataType('data-data-xyz')) { return FALSE; } $gcvars = array(); // For GetDataColor, which initializes and uses this. // Calculate or use supplied maximum bubble size: if (isset($this->bubbles_max_size)) { $bubbles_max_size = $this->bubbles_max_size; } else { $bubbles_max_size = min($this->plot_area_width, $this->plot_area_height) / 12; } // Calculate bubble scale parameters. Bubble_size(z) = $f_size * $z + $b_size if ($this->max_z <= $this->min_z) { // Regressive case, no Z range. $f_size = 0; $b_size = ($bubbles_max_size + $this->bubbles_min_size) / 2; // Use average size of all bubbles } else { $f_size = ($bubbles_max_size - $this->bubbles_min_size) / ($this->max_z - $this->min_z); $b_size = $bubbles_max_size - $f_size * $this->max_z; } for ($row = 0; $row < $this->num_data_rows; $row++) { $rec = 1; // Skip record #0 (data label) $x = $this->xtr($this->data[$row][$rec++]); // Get X value from data array. // Draw X Data labels? if ($this->x_data_label_pos != 'none') { $this->DrawXDataLabel($this->data[$row][0], $x, $row, TRUE); } // Proceed with Y,Z values for ($idx = 0; $rec < $this->num_recs[$row]; $rec += 2, $idx++) { if (is_numeric($y_now = $this->data[$row][$rec])) { //Allow for missing Y data $y = $this->ytr($y_now); $z = (double) $this->data[$row][$rec + 1]; // Z is required if Y is present. $size = (int) ($f_size * $z + $b_size); // Calculate bubble size // Select the color: $this->GetDataColor($row, $idx, $gcvars, $data_color); // Draw the bubble: ImageFilledEllipse($this->img, $x, $y, $size, $size, $data_color); $this->DoCallback('data_points', 'circle', $row, $idx, $x, $y, $size); } } } return TRUE; }
function dessine_champignons($x, $y, $taille, $pas, $info_text, $tab_couleur, $info, $champignons) { global $db_vue_rm, $image; $x_min = $x - $taille / 2; $x_max = $x + $taille / 2; $y_min = $y - $taille / 2; $y_max = $y + $taille / 2; $lesChampis = selectDbChampignons($x_min, $x_max, $y_min, $y_max, $champignons); $nbChampis = count($lesChampis); for ($i = 1; $i <= $nbChampis; $i++) { $res = $lesChampis[$i]; // Si l'on affiche uniquement les champignons que l'on voit // on met les couleurs suivant la positions z if ($champignons == 'vus') { if ($res['z_champi'] == '0') { $z = 0; } else { $z = $res['z_champi']; } if ($res['z_champi'] < 1) { $level = 0; } elseif ($res['z_champi'] < 2) { $level = 1; } else { if ($res['z_champi'] < 3) { $level = 2; } else { if ($res['z_champi'] < 5) { $level = 3; } else { $level = 4; } } } } else { // sinon, on met les couleurs suivant les dates $level = 2; } // Combien vaut x et y pour la map $x_map = D + TAILLE_MAP / 2 - $x * $pas + $pas * $res['x_champi']; $y_map = D + TAILLE_MAP / 2 + $y * $pas - $pas * $res['y_champi']; ImageFilledEllipse($image, $x_map, $y_map, 3, 3, $tab_couleur[$level]); // On affiche la position du champignon si la vue est <= 50, soit la taille <=100. // et que la taille de la map est >= 400 Sinon, on voit rien // c'est devenu une option nommée info_text //=> Illisible ! //if (($taille<=$info_text*2) && (TAILLE_MAP >= 400)) { // imagestring($image, 2, $x_map , $y_map, // '('.$res[x_champi].','.$res[y_champi].','.$res[z_champi].' )', $tab_couleur[0]); //} } affiche_texte_bottom($info . ":" . $nbChampis, $tab_couleur); }
$period = 24 * 3600; //création du fond de la carte $im = ImageCreate(2 * $larg + $decall + 60, 2 * $larg + $decalv + 20) or die("Erreur lors de la création de l'image"); $fond = imagecolorallocatealpha($im, 255, 255, 255, 127); ImageFill($im, 0, 0, $fond); //couleurs de base $bleu = ImageColorAllocate($im, 17, 17, 150); $bleu_c = ImageColorAllocate($im, 100, 117, 200); for ($i = 1; $i < $nb_pt; $i++) { // imageline($im, $coord[2*$i-2]*$coeff+$decall+$larg, -$coord[2*$i-1]*$coeff+$decalv+$larg, $coord[2*$i]*$coeff+$decall+$larg, -$coord[2*$i+1]*$coeff+$decalv+$larg, $bleu_c ); $dx = $coord[2 * $i] - $coord[2 * $i - 2]; $dy = $coord[2 * $i + 1] - $coord[2 * $i - 1]; //Détermination de la forme du trajet if (abs($dx) < abs($dy)) { $x_inter = $coord[2 * $i]; $y_inter = $dy < 0 ? $coord[2 * $i - 1] - abs($dx) : $coord[2 * $i - 1] + abs($dx); } else { $x_inter = $dx > 0 ? $coord[2 * $i - 2] + abs($dy) : $coord[2 * $i - 2] - abs($dy); $y_inter = $coord[2 * $i + 1]; } //Affichage des lignes imagelinethick($im, $coord[2 * $i - 2] * $coeff + $decall + $larg, -$coord[2 * $i - 1] * $coeff + $decalv + $larg, $x_inter * $coeff + $decall + $larg, -$y_inter * $coeff + $decalv + $larg, $bleu_c, 2); imagelinethick($im, $x_inter * $coeff + $decall + $larg, -$y_inter * $coeff + $decalv + $larg, $coord[2 * $i] * $coeff + $decall + $larg, -$coord[2 * $i + 1] * $coeff + $decalv + $larg, $bleu_c, 2); //affichage des points ImageFilledEllipse($im, $coord[2 * $i] * $coeff + $decall + $larg, -$coord[2 * $i + 1] * $coeff + $decalv + $larg, 6, 6, $bleu_c); } ImageFilledEllipse($im, $coord[0] * $coeff + $decall + $larg, -$coord[1] * $coeff + $decalv + $larg, 6, 6, $bleu_c); ImageColorTransparent($im, $blanc); //export image header("Content-type: image/png"); ImagePng($im);
if ($row["grain"] > 0) { ImageFilledArc($map, $row["x"], $row["y"], 30, 24, 90 - 12 * $row["grain"], 90 + 12 * $row["grain"], $grain, IMG_ARC_PIE); } // Draw hidden boomer lines for ($i = 1; $i <= $row["boomers"]; $i++) { ImageEllipse($map, $row["x"], $row["y"], 25 + $i * 4, 19 + $i * 4, $powerc); } // Draw tank or visible boomer lines for ($i = 1; $i <= $row["major"]; $i++) { ImageEllipse($map, $row["x"], $row["y"], 25 + ($row['boomers'] + $i) * 4, 19 + ($row['boomers'] + $i) * 4, $black); } // Draw inner ellipse if ($row["colour"] == 'Vuln') { ImageFilledEllipse($map, $row["x"], $row["y"], 19, 13, $white); } else { ImageFilledEllipse($map, $row["x"], $row["y"], 19, 13, $blue); } // Draw minor units if ($row["minor"] > 9) { $row["minor"] = '*'; } ImageTTFText($map, 10, 0, $row["x"] - 4, $row["y"] + 5, $black, $font, $row["minor"]); } } } // Finish colouring in // Add Game number if ($xsize >= 500) { // Get turn and phase $result = $mysqli->query("Select Distinct turnno, phaseno From sp_game Where gameno={$gameno}"); if ($result->num_rows > 0) {
<?php $size = 100; $scale = 2.5; $image = ImageCreateTrueColor($size * $scale, $size); $background_color = 0xffffff; // white ImageFilledRectangle($image, 0, 0, $size * $scale - 1, $size * $scale - 1, $background_color); $black = 0x0; ImageEllipse($image, $size / 2, $size / 2, $size - 1, $size - 1, $black); ImageFilledEllipse($image, $size / 2 + ($scale - 1) * $size, $size / 2, $size - 1, $size - 1, $black); header('Content-type: image/png'); ImagePNG($image); ImageDestroy($image);
$color_text_b = hexdec(substr($CFontColor, 5, 2)); $color_text = ImageColorAllocate($im, $color_text_r, $color_text_g, $color_text_b); break; } $noiset = mt_rand(1, 2); if ($CBackgroundType == 1) { switch ($noiset) { case '1': /* make the random background elipses */ for ($l = 0; $l < 10; $l++) { $c = 'color_elipse' . $l % 2; $cx = mt_rand(0, $image_width); $cy = mt_rand(0, $image_width); $rx = mt_rand(10, $image_width); $ry = mt_rand(10, $image_width); ImageFilledEllipse($im, $cx, $cy, $rx, $ry, ${$c}); } break; case '2': /* make the random background lines */ for ($l = 0; $l < 10; $l++) { $c = 'color_line' . $l % 2; $lx = mt_rand(0, $image_width + $image_height); $lw = mt_rand(0, 3); if ($lx > $image_width) { $lx -= $image_width; ImageFilledRectangle($im, 0, $lx, $image_width - 1, $lx + $lw, $c); } else { ImageFilledRectangle($im, $lx, 0, $lx + $lw, $image_height - 1, $c); } }
$h_opts = array(1 => 'left', 0 => 'center', -1 => 'right'); $cx = $width / 2; $cy = $height / 2; $x_off = $height / 4.0; $y_off = $width / 4.0; # Because we don't let PHPlot finish drawing, we need to set the background. imagefilledrectangle($img, 0, 0, $width, $height, $white); if (isset($tp['line_spacing'])) { $p->SetLineSpacing($tp['line_spacing']); } # Draw a title: ImageString($img, '3', 5, 5, $title, $black); # This is the rest of the text after the first line: $addl_lines = ''; $addl_text = ''; for ($i = 2; $i <= $nlines; $i++) { $addl_lines .= "\nLine {$i}" . $addl_text; $addl_text .= " E"; } # Loop over all text alignment cases: foreach ($v_opts as $v_step => $v) { foreach ($h_opts as $h_step => $h) { $text = "[{$h}, {$v}]" . $addl_lines; $x = $cx + $h_step * $x_off; $y = $cy + $v_step * $y_off; $p->DrawText($font, $angle, $x, $y, $blue, $text, $h, $v); ImageFilledEllipse($img, $x, $y, 8, 8, $red); } } # Don't have PHPlot output a graph: just do it ourselves: imagepng($img);
private function drawshape($image, $action, $color) { switch ($action % 7) { case 0: ImageFilledRectangle($image, $this->getX(), $this->getY(), $this->getX(), $this->getY(), $color); break; case 1: case 2: ImageFilledEllipse($image, $this->getX(), $this->getY(), $this->getX(), $this->getY(), $color); break; case 3: $points = array($this->getX(), $this->getY(), $this->getX(), $this->getY(), $this->getX(), $this->getY(), $this->getX(), $this->getY()); ImageFilledPolygon($image, $points, 4, $color); break; case 4: case 5: case 6: $start = $this->getInt() * 360 / 256; $end = $start + $this->getInt() * 180 / 256; ImageFilledArc($image, $this->getX(), $this->getY(), $this->getX(), $this->getY(), $start, $end, $color, IMG_ARC_PIE); break; } }
function Draw($site) { global $image, $racks, $devices, $links, $port_count, $ports; $rack_count = CountRacksInSite($site); // Define the modifiers $modifier = 3; $top_modifier = 0; $dev_modifier = array(); $side_modifier = array(); $rack_buffer = (CountLinks($site) + 2) * $modifier; // Space between racks $rack_margin = $rack_buffer; // Space between the racks and edge of page $y_top_margin = 100 + CountLinks($site) * 1.25; $y_bot_margin = 75; $page_size = 7; $page_counter = 0; $x_offset = 25; $y_offset = 50; $height = 100; $rack_width = 300; $rack_height = CountDevicesInRack($site) * $height; $width = $rack_width; $x_buffer = $width + intval($width * 0.5); $y_buffer = 50; ksort($racks); ksort($devices); $x_max = $rack_count * $rack_width + $rack_count * $rack_buffer + $rack_margin * 2; $y_max = $rack_height + $y_top_margin + intval(ImageFontHeight(2) * (CountLinks($site) * 1.25) + 0.5); $image = ImageCreate($x_max, $y_max) or die("Cannot Create image"); $background_color = imagecolorallocate($image, 255, 255, 255); $pink = ImageColorAllocate($image, 255, 105, 180); $white = ImageColorAllocate($image, 255, 255, 255); $black = ImageColorAllocate($image, 0, 0, 0); $red = ImageColorAllocate($image, 255, 0, 0); $green = ImageColorAllocate($image, 89, 200, 180); $blue = ImageColorAllocate($image, 34, 68, 228); $grey = ImageColorAllocate($image, 225, 225, 225); $title = "RackTables Visualised ({$site})"; $title_font = 5; $title_font_width = ImageFontWidth($title_font); ImageString($image, $title_font, $x_max / 2 - $title_font_width * strlen($title) / 2, $title_font_width * 2, $title, $black); // Draw racks $rc = 1; ksort($racks, SORT_STRING); foreach ($racks as $rackname => $sitename) { if ($site != $sitename) { continue; } $y = $y_top_margin; $x = $rack_margin + ($rc - 1) * $rack_width + $rc * $rack_buffer; $x = ($rc - 1) * $rack_width + $rc * $rack_buffer; ImageRectangle($image, $x, $y, $x + $rack_width, $y + $rack_height, $black); $rack_name_width = ImageFontWidth($rackname); $rack_name_font = 2; ImageString($image, $rack_name_font, $x + ($rack_width - $rack_name_width * strlen($rackname)) / 2, $y - intval(ImageFontHeight($rack_name_font) * 1.25), $rackname, $black); // Draw devices foreach ($devices as $device_name => $installed_rack) { if ($installed_rack != $rackname) { continue; } ImageRectangle($image, $x, $y, $x + $width, $y + $height, $black); ImageString($image, 2, $x + 5, $y + 3, strtoupper($device_name), $black); $unit = $width / ($port_count[$device_name] + 1); for ($i = 0; $i < $port_count[$device_name]; $i++) { $cx = $x + $unit * ($i + 1); $coord[$device_name][$ports[$device_name][$i]][0] = $cx; $coord[$device_name][$ports[$device_name][$i]][1] = intval($y + $height / 2); ImageFilledEllipse($image, $cx, $coord[$device_name][$ports[$device_name][$i]][1], 3, 3, $black); ImageStringUp($image, 1, $cx - intval(ImageFontWidth(1) / 2), $coord[$device_name][$ports[$device_name][$i]][1] - 5, $ports[$device_name][$i], $black); } $y = $y + $height; } $rc++; } unset($rc); $line_tracker = array(); $index = 0; $label = "Device Inter-Connections"; ImageString($image, 3, $rack_margin, $y_top_margin + $rack_height + 20, $label, $black); ImageLine($image, $rack_margin, $y_top_margin + $rack_height + 20 + ImageFontHeight(3) + 1, $rack_margin + ImageFontWidth(3) * strlen($label), $y_top_margin + $rack_height + 20 + ImageFontHeight(3) + 1, $black); unset($label); $y = $y_top_margin - intval(ImageFontHeight(2) * 1.25); $text_x_coord['data'] = $rack_margin; $text_x_coord['power'] = $rack_margin + 320; $text_x_coord['kvm'] = $rack_margin + 640; // Iterate through the links foreach ($links as $link) { switch ($link['Type']) { case 16: // Power $colour = $red; $type = 'power'; break; case 19: // Fast Ethernet $colour = $blue; $type = 'data'; break; case 24: // GB Ethernet $colour = $blue; $type = 'data'; break; case 1077: // SFF $colour = $blue; $type = 'data'; break; case 33: // KVM $colour = $green; $type = 'kvm'; break; case 446: // KVM $colour = $green; $type = 'kvm'; break; } // Filter out devices with un-linked ports if (isset($coord[$link['Device1']][$link['Port1']][0]) and isset($coord[$link['Device1']][$link['Port1']][1]) and isset($coord[$link['Device2']][$link['Port2']][0]) and isset($coord[$link['Device2']][$link['Port2']][1])) { $d1x = $coord[$link['Device1']][$link['Port1']][0]; $d1y = $coord[$link['Device1']][$link['Port1']][1]; $d2x = $coord[$link['Device2']][$link['Port2']][0]; $d2y = $coord[$link['Device2']][$link['Port2']][1]; // $port_list = $port_list + intval(ImageFontHeight(2) * 1.25); if (isset($text_y_coord[$type])) { $text_y_coord[$type] += intval(ImageFontHeight(2) * 1.25); } else { $text_y_coord[$type] = $y_top_margin + $rack_height + 20 + intval(ImageFontHeight(2) * 1.25); } // Print the link information and darw a simple table ImageString($image, 2, $text_x_coord[$type], $text_y_coord[$type], $link['Device1'] . ":" . $link['Port1'], $colour); ImageString($image, 2, $text_x_coord[$type] + 150, $text_y_coord[$type], $link['Device2'] . ":" . $link['Port2'], $colour); ImageLine($image, $text_x_coord[$type] - 10, $text_y_coord[$type], $text_x_coord[$type] + 300, $text_y_coord[$type], $grey); if ($text_y_coord[$type] != $y_top_margin + $rack_height + 20 + intval(ImageFontHeight(2) * 1.25)) { ImageLine($image, $text_x_coord[$type] - 10, $text_y_coord[$type] + intval(ImageFontHeight(2) * 1.25), $text_x_coord[$type] + 300, $text_y_coord[$type] + intval(ImageFontHeight(2) * 1.25), $grey); } ImageLine($image, $text_x_coord[$type] - 10, $text_y_coord[$type], $text_x_coord[$type] - 10, $text_y_coord[$type] + intval(ImageFontHeight(2) * 1.25), $grey); ImageLine($image, $text_x_coord[$type] + 150 - 10, $text_y_coord[$type], $text_x_coord[$type] + 150 - 10, $text_y_coord[$type] + intval(ImageFontHeight(2) * 1.25), $grey); ImageLine($image, $text_x_coord[$type] + 300, $text_y_coord[$type], $text_x_coord[$type] + 300, $text_y_coord[$type] + intval(ImageFontHeight(2) * 1.25), $grey); if (isset($side_modifier[$link['Rack1']])) { $side_modifier[$link['Rack1']] += $modifier; } else { $side_modifier[$link['Rack1']] = $modifier; } if (isset($side_modifier[$link['Rack2']])) { $side_modifier[$link['Rack2']] += $modifier; } else { $side_modifier[$link['Rack2']] = $modifier; } if (isset($dev_modifier[$link['Device1']])) { $dev_modifier[$link['Device1']] += $modifier; } else { $dev_modifier[$link['Device1']] = $modifier; } if (isset($dev_modifier[$link['Device2']])) { $dev_modifier[$link['Device2']] += $modifier; } else { $dev_modifier[$link['Device2']] = $modifier; } $r1x = $d1x - $rack_margin; $i = 0; while ($r1x > 0) { $r1x = $r1x - $rack_width - $rack_buffer; $i++; } $r1x = $rack_margin + $rack_width * $i + $rack_buffer * $i; $r1x = $rack_width * $i + $rack_buffer * $i; $r2x = $d2x - $rack_margin; $j = 0; while ($r2x > 0) { $r2x = $r2x - $rack_width - $rack_buffer; $j++; } $r2x = $rack_margin + $rack_width * ($j - 1) + $rack_buffer * $j; $r2x = $rack_width * ($j - 1) + $rack_buffer * $j; ImageLine($image, $d1x, $d1y, $d1x, $d1y + $dev_modifier[$link['Device1']], $colour); ImageLine($image, $d1x, $d1y + $dev_modifier[$link['Device1']], $r1x + $side_modifier[$link['Rack1']], $d1y + $dev_modifier[$link['Device1']], $colour); if ($link['Rack1'] == $link['Rack2']) { ImageLine($image, $r1x + $side_modifier[$link['Rack1']], $d1y + $dev_modifier[$link['Device1']], $r1x + $side_modifier[$link['Rack1']], $d2y + $dev_modifier[$link['Device2']], $colour); ImageLine($image, $r1x + $side_modifier[$link['Rack1']], $d2y + $dev_modifier[$link['Device2']], $d2x, $d2y + $dev_modifier[$link['Device2']], $colour); // ImageLine($image, $d2x, $d2y + $dev_modifier[$link['Device2']], $d2x, $d2y, $colour); } else { $top_modifier += $modifier; // ImageLine($image, $d1x, $d1y, $d1x, $d1y + $dev_modifier[$link['Device1']], $colour); // ImageLine($image, $d1x, $d1y + $dev_modifier[$link['Device1']], $r1x + $side_modifier[$link['Rack1']], $d1y + $dev_modifier[$link['Device1']], $colour); ImageLine($image, $r1x + $side_modifier[$link['Rack1']], $d1y + $dev_modifier[$link['Device1']], $r1x + $side_modifier[$link['Rack1']], $y - $top_modifier, $colour); ImageLine($image, $r1x + $side_modifier[$link['Rack1']], $y - $top_modifier, $d2x - ($d2x - $r2x) + $rack_width + $side_modifier[$link['Rack2']], $y - $top_modifier, $colour); ImageLine($image, $d2x - ($d2x - $r2x) + $rack_width + $side_modifier[$link['Rack2']], $y - $top_modifier, $d2x - ($d2x - $r2x) + $rack_width + $side_modifier[$link['Rack2']], $d2y + $dev_modifier[$link['Device2']], $colour); ImageLine($image, $d2x - ($d2x - $r2x) + $rack_width + $side_modifier[$link['Rack2']], $d2y + $dev_modifier[$link['Device2']], $d2x, $d2y + $dev_modifier[$link['Device2']], $colour); } ImageLine($image, $d2x, $d2y + $dev_modifier[$link['Device2']], $d2x, $d2y, $colour); unset($i, $j, $r1x, $r2x, $ry); } } ob_start(); ImagePng($image); $contents = ob_get_contents(); ob_end_clean(); $new_site = str_replace(' ', '_', $site); $fh = fopen("/tmp/{$new_site}.png", "w"); fwrite($fh, $contents); fclose($fh); }
/** * Draw an ellipse * * Parameter array: * * 'x': int X center point * * 'y': int Y center point * * 'rx': int X radius * * 'ry': int Y radius * * 'fill': mixed [optional] The fill color * * 'line': mixed [optional] The line color * * @param array $params Parameter array */ function ellipse($params) { $x = $this->_getX($params['x']); $y = $this->_getY($params['y']); $rx = $this->_getX($params['rx']); $ry = $this->_getY($params['ry']); $fillColor = isset($params['fill']) ? $params['fill'] : false; $lineColor = isset($params['line']) ? $params['line'] : false; if (($fill = $this->_getFillStyle($fillColor, $x - $rx, $y - $ry, $x + $rx, $y + $ry)) !== false) { ImageFilledEllipse($this->_canvas, $x, $y, $rx * 2, $ry * 2, $fill); } if (($line = $this->_getLineStyle($lineColor)) !== false) { ImageEllipse($this->_canvas, $x, $y, $rx * 2, $ry * 2, $line); } parent::ellipse($params); }
function draw_soleil($im, $l0, $b0, $p0, $sx, $r) { $cBlack = ImageColorAllocate($im, 0, 0, 0); $cRed = ImageColorAllocate($im, 255, 0, 0); $cBlue = ImageColorAllocate($im, 0, 0, 255); // paralleles for ($i = -80; $i <= 80; $i = $i + 10) { for ($j = -90; $j <= 90; $j++) { $coord = ToHelio($j, $i, $b0, $p0, $r, $sx); if ($i == 0) { ImageSetPixel($im, $coord['lon'], $coord['lat'], $cBlue); } else { ImageSetPixel($im, $coord['lon'], $coord['lat'], $cBlack); } } } // meridiens for ($i = -90; $i <= 90; $i = $i + 10) { for ($j = -90; $j <= 90; $j++) { $coord = ToHelio($i, $j, $b0, $p0, $r, $sx); if ($i == 0) { ImageSetPixel($im, $coord['lon'], $coord['lat'], $cBlue); } else { ImageSetPixel($im, $coord['lon'], $coord['lat'], $cBlack); } } } // ligne de partage entre 2 rotations $lon = 360 - rad2deg($l0); for ($j = -90; $j <= 90; $j++) { $coord = ToHelio($lon, $j, $b0, $p0, $r, $sx); // ImageSetPixel($im, $coord['lon'], $coord['lat'], $cRed); ImageFilledEllipse($im, $coord['lon'], $coord['lat'], 2, 2, $cRed); } }
protected function DrawDot($x_world, $y_world, $record, $color) { $index = $record % $this->point_counts; $point_size = $this->point_sizes[$index]; $half_point = (int) ($point_size / 2); $x_mid = $this->xtr($x_world); $y_mid = $this->ytr($y_world); $x1 = $x_mid - $half_point; $x2 = $x_mid + $half_point; $y1 = $y_mid - $half_point; $y2 = $y_mid + $half_point; switch ($this->point_shapes[$index]) { case 'halfline': ImageLine($this->img, $x1, $y_mid, $x_mid, $y_mid, $color); break; case 'line': ImageLine($this->img, $x1, $y_mid, $x2, $y_mid, $color); break; case 'plus': ImageLine($this->img, $x1, $y_mid, $x2, $y_mid, $color); ImageLine($this->img, $x_mid, $y1, $x_mid, $y2, $color); break; case 'cross': ImageLine($this->img, $x1, $y1, $x2, $y2, $color); ImageLine($this->img, $x1, $y2, $x2, $y1, $color); break; case 'circle': ImageArc($this->img, $x_mid, $y_mid, $point_size, $point_size, 0, 360, $color); break; case 'dot': ImageFilledEllipse($this->img, $x_mid, $y_mid, $point_size, $point_size, $color); break; case 'diamond': $arrpoints = array($x1, $y_mid, $x_mid, $y1, $x2, $y_mid, $x_mid, $y2); ImageFilledPolygon($this->img, $arrpoints, 4, $color); break; case 'triangle': $arrpoints = array($x1, $y_mid, $x2, $y_mid, $x_mid, $y2); ImageFilledPolygon($this->img, $arrpoints, 3, $color); break; case 'trianglemid': $arrpoints = array($x1, $y1, $x2, $y1, $x_mid, $y_mid); ImageFilledPolygon($this->img, $arrpoints, 3, $color); break; case 'yield': $arrpoints = array($x1, $y1, $x2, $y1, $x_mid, $y2); ImageFilledPolygon($this->img, $arrpoints, 3, $color); break; case 'delta': $arrpoints = array($x1, $y2, $x2, $y2, $x_mid, $y1); ImageFilledPolygon($this->img, $arrpoints, 3, $color); break; case 'star': ImageLine($this->img, $x1, $y_mid, $x2, $y_mid, $color); ImageLine($this->img, $x_mid, $y1, $x_mid, $y2, $color); ImageLine($this->img, $x1, $y1, $x2, $y2, $color); ImageLine($this->img, $x1, $y2, $x2, $y1, $color); break; case 'hourglass': $arrpoints = array($x1, $y1, $x2, $y1, $x1, $y2, $x2, $y2); ImageFilledPolygon($this->img, $arrpoints, 4, $color); break; case 'bowtie': $arrpoints = array($x1, $y1, $x1, $y2, $x2, $y1, $x2, $y2); ImageFilledPolygon($this->img, $arrpoints, 4, $color); break; case 'target': ImageFilledRectangle($this->img, $x1, $y1, $x_mid, $y_mid, $color); ImageFilledRectangle($this->img, $x_mid, $y_mid, $x2, $y2, $color); ImageRectangle($this->img, $x1, $y1, $x2, $y2, $color); break; case 'box': ImageRectangle($this->img, $x1, $y1, $x2, $y2, $color); break; case 'home': /* As in: "home plate" (baseball), also looks sort of like a house. */ $arrpoints = array($x1, $y2, $x2, $y2, $x2, $y_mid, $x_mid, $y1, $x1, $y_mid); ImageFilledPolygon($this->img, $arrpoints, 5, $color); break; case 'up': ImagePolygon($this->img, array($x_mid, $y1, $x2, $y2, $x1, $y2), 3, $color); break; case 'down': ImagePolygon($this->img, array($x_mid, $y2, $x1, $y1, $x2, $y1), 3, $color); break; case 'none': /* Special case, no point shape here */ break; default: /* Also 'rect' */ ImageFilledRectangle($this->img, $x1, $y1, $x2, $y2, $color); break; } return TRUE; }
function RoundedImageCorners(&$gdimg, $radius_x, $radius_y) { if ($gdimg_cornermask_triple = ImageCreateTrueColor($radius_x * 6, $radius_y * 6)) { if ($gdimg_cornermask = ImageCreateTrueColor(ImageSX($gdimg), ImageSY($gdimg))) { $color_transparent = ImageColorAllocate($gdimg_cornermask_triple, 255, 255, 255); ImageFilledEllipse($gdimg_cornermask_triple, $radius_x * 3, $radius_y * 3, $radius_x * 4, $radius_y * 4, $color_transparent); ImageFilledRectangle($gdimg_cornermask, 0, 0, ImageSX($gdimg), ImageSY($gdimg), $color_transparent); ImageCopyResampled($gdimg_cornermask, $gdimg_cornermask_triple, 0, 0, $radius_x, $radius_y, $radius_x, $radius_y, $radius_x * 2, $radius_y * 2); ImageCopyResampled($gdimg_cornermask, $gdimg_cornermask_triple, 0, ImageSY($gdimg) - $radius_y, $radius_x, $radius_y * 3, $radius_x, $radius_y, $radius_x * 2, $radius_y * 2); ImageCopyResampled($gdimg_cornermask, $gdimg_cornermask_triple, ImageSX($gdimg) - $radius_x, ImageSY($gdimg) - $radius_y, $radius_x * 3, $radius_y * 3, $radius_x, $radius_y, $radius_x * 2, $radius_y * 2); ImageCopyResampled($gdimg_cornermask, $gdimg_cornermask_triple, ImageSX($gdimg) - $radius_x, 0, $radius_x * 3, $radius_y, $radius_x, $radius_y, $radius_x * 2, $radius_y * 2); ApplyMask($gdimg_cornermask, $gdimg); ImageDestroy($gdimg_cornermask); $DebugMessage = 'RoundedImageCorners(' . $radius_x . ', ' . $radius_y . ') succeeded' . __FILE__ . __LINE__; return true; } else { $DebugMessage = 'FAILED: $gdimg_cornermask = ImageColorAllocate(' . ImageSX($gdimg) . ', ' . ImageSY($gdimg) . ')' . __FILE__ . __LINE__; } ImageDestroy($gdimg_cornermask_triple); } else { $DebugMessage = 'FAILED: $gdimg_cornermask_triple = ImageColorAllocate(' . $radius_x * 6 . ', ' . $radius_y * 6 . ')' . __FILE__ . __LINE__; } return false; }
function initimg($Nbx, $Nby, $taillex, $tailley) { global $colormap, $image, $debug_cl; $map = map::getinstance(); $image = imagecreate($Nbx * $taillex, $Nby * $tailley); $background_color = imagecolorallocate($image, 0, 0, 0); $blanc = imagecolorallocate($image, 254, 254, 254); $rouge = imagecolorallocate($image, 85, 0, 64); imagefilledrectangle($image, 0, 0, $Nbx * $taillex, $Nby * $tailley, $background_color); // Tableau des couleurs... $colormap = DataEngine::config('MapColors'); $colormap = $colormap[$map->itineraire ? 0 : $map->sc + 1]; if ($map->itineraire) { $map->load_prefs('1;0;0;0;' . $map->sc . ';' . $map->taille . ';0;0;0'); } foreach ($colormap as $k => $c) { $R = hexdec(p_substr($c, 1, 2)); $V = hexdec(p_substr($c, 3, 2)); $B = hexdec(p_substr($c, 5, 2)); $colormap[$k] = imagecolorallocate($image, $R, $V, $B); } $colormap[-1] = $debug_cl = $blanc; $colormap[-2] = $rouge; // Centre de communication... $comlevel = ownuniverse::getinstance()->get_comlevel(); if (is_array($comlevel)) { foreach ($comlevel as $k => $planet) { list($CoordsY, $CoordsX) = map::ss2xy($planet['ss']); $level = $planet['level']; if ($level > 0) { ImageFilledEllipse($image, 1 + ($CoordsY - 1) * $taillex + round($taillex / 2) + 1, 1 + ($CoordsX - 1) * $tailley + round($tailley / 2) + 1, $level * 20 * $taillex, $level * 20 * $tailley, $colormap["0"]); } } } return $image; }
function drawTimerEvent($im, $x1, $y1, $h) { $blue = imagecolorallocate($im, 160, 160, 180); $red = imagecolorallocate($im, 200, 100, 0); $gray = imagecolorallocate($im, 100, 100, 100); $black = imagecolorallocate($im, 0, 0, 0); $yellow = imagecolorallocate($im, 240, 240, 220); for ($i = $y1 + 15; $i < $h; $i += 2) { imageline($im, $x1, $i, $x1, $i, $gray); } ImageEllipse($im, $x1, $y1, 26, 26, $black); ImageEllipse($im, $x1, $y1, 22, 22, $black); ImageFilledEllipse($im, $x1, $y1, 16, 16, $yellow); ImageEllipse($im, $x1, $y1, 16, 16, $red); imageline($im, $x1, $y1 - 8, $x1, $y1 + 8, $red); //imageline($im, $x1 , $y1+8 , $x1, $y1+6, $red); imageline($im, $x1 - 8, $y1, $x1 + 8, $y1, $red); imageline($im, $x1 - 7, $y1 - 4, $x1 + 7, $y1 + 4, $red); imageline($im, $x1 - 4, $y1 - 7, $x1 + 4, $y1 + 7, $red); imageline($im, $x1 + 7, $y1 - 4, $x1 - 7, $y1 + 4, $red); imageline($im, $x1 + 4, $y1 - 7, $x1 - 4, $y1 + 7, $red); ImageFilledEllipse($im, $x1, $y1, 10, 10, $yellow); imageline($im, $x1 - 1, $y1 + 1, $x1 + 1, $y1 - 5, $red); imageline($im, $x1 - 1, $y1 + 1, $x1 + 3, $y1 + 1, $red); }
public function RoundedImageCorners(&$gdimg, $radius_x, $radius_y) { // generate mask at twice desired resolution and downsample afterwards for easy antialiasing // mask is generated as a white double-size elipse on a triple-size black background and copy-paste-resampled // onto a correct-size mask image as 4 corners due to errors when the entire mask is resampled at once (gray edges) if ($gdimg_cornermask_triple = phpthumb_functions::ImageCreateFunction($radius_x * 6, $radius_y * 6)) { if ($gdimg_cornermask = phpthumb_functions::ImageCreateFunction(ImageSX($gdimg), ImageSY($gdimg))) { $color_transparent = ImageColorAllocate($gdimg_cornermask_triple, 255, 255, 255); ImageFilledEllipse($gdimg_cornermask_triple, $radius_x * 3, $radius_y * 3, $radius_x * 4, $radius_y * 4, $color_transparent); ImageFilledRectangle($gdimg_cornermask, 0, 0, ImageSX($gdimg), ImageSY($gdimg), $color_transparent); ImageCopyResampled($gdimg_cornermask, $gdimg_cornermask_triple, 0, 0, $radius_x, $radius_y, $radius_x, $radius_y, $radius_x * 2, $radius_y * 2); ImageCopyResampled($gdimg_cornermask, $gdimg_cornermask_triple, 0, ImageSY($gdimg) - $radius_y, $radius_x, $radius_y * 3, $radius_x, $radius_y, $radius_x * 2, $radius_y * 2); ImageCopyResampled($gdimg_cornermask, $gdimg_cornermask_triple, ImageSX($gdimg) - $radius_x, ImageSY($gdimg) - $radius_y, $radius_x * 3, $radius_y * 3, $radius_x, $radius_y, $radius_x * 2, $radius_y * 2); ImageCopyResampled($gdimg_cornermask, $gdimg_cornermask_triple, ImageSX($gdimg) - $radius_x, 0, $radius_x * 3, $radius_y, $radius_x, $radius_y, $radius_x * 2, $radius_y * 2); phpthumb_filters::ApplyMask($gdimg_cornermask, $gdimg); ImageDestroy($gdimg_cornermask); $this->DebugMessage('RoundedImageCorners(' . $radius_x . ', ' . $radius_y . ') succeeded', __FILE__, __LINE__); return true; } else { $this->DebugMessage('FAILED: $gdimg_cornermask = phpthumb_functions::ImageCreateFunction(' . ImageSX($gdimg) . ', ' . ImageSY($gdimg) . ')', __FILE__, __LINE__); } ImageDestroy($gdimg_cornermask_triple); } else { $this->DebugMessage('FAILED: $gdimg_cornermask_triple = phpthumb_functions::ImageCreateFunction(' . $radius_x * 6 . ', ' . $radius_y * 6 . ')', __FILE__, __LINE__); } return false; }
function ApplyRoundedCorners(&$image, $radius = 0) { if ($radius <= 0) { $radius = Round(ImageSX($image) / 4); } /* Generate mask at twice desired resolution and downsample afterwards for * easy antialiasing mask is generated as a white double-size elipse on a * triple-size black background and copy-paste-resampled onto a * correct-size mask image as 4 corners due to errors when the entire mask * is resampled at once (gray edges). * */ $x = ImageSX($image); $y = ImageSY($image); $cornermask = ImageCreateTrueColor($x * 2, $y * 2); $cornermask3 = ImageCreateTrueColor($radius * 6, $radius * 6); $color_transparent = ImageColorAllocate($cornermask3, 255, 255, 255); ImageFilledEllipse($cornermask3, $radius * 3, $radius * 3, $radius * 4, $radius * 4, $color_transparent); ImageFilledRectangle($cornermask, 0, 0, $x * 2, $y * 2, $color_transparent); ImageCopyResampled($cornermask, $cornermask3, 0, 0, $radius, $radius, $radius, $radius, $radius * 2, $radius * 2); ImageCopyResampled($cornermask, $cornermask3, 0, $y * 2 - $radius, $radius, $radius * 3, $radius, $radius, $radius * 2, $radius * 2); ImageCopyResampled($cornermask, $cornermask3, $x * 2 - $radius, $y * 2 - $radius, $radius * 3, $radius * 3, $radius, $radius, $radius * 2, $radius * 2); ImageCopyResampled($cornermask, $cornermask3, $x * 2 - $radius, 0, $radius * 3, $radius, $radius, $radius, $radius * 2, $radius * 2); ImageDestroy($cornermask3); ApplyMask($image, $cornermask); ImageDestroy($cornermask); }