当前位置: 首页>>代码示例>>PHP>>正文


PHP ImageFilledRectangle函数代码示例

本文整理汇总了PHP中ImageFilledRectangle函数的典型用法代码示例。如果您正苦于以下问题:PHP ImageFilledRectangle函数的具体用法?PHP ImageFilledRectangle怎么用?PHP ImageFilledRectangle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ImageFilledRectangle函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: drawRating

function drawRating($rating)
{
    $width = 300;
    $height = 15;
    $ratingbar = $rating / 100 * $width - 2;
    $image = imagecreate($width, $height);
    $fill = ImageColorAllocate($image, 67, 219, 0);
    if ($rating > 74) {
        $fill = ImageColorAllocate($image, 233, 233, 0);
    }
    if ($rating > 89) {
        $fill = ImageColorAllocate($image, 197, 6, 6);
    }
    if ($rating > 100) {
        echo "Overload Error!";
        exit;
    }
    $back = ImageColorAllocate($image, 255, 255, 255);
    $border = ImageColorAllocate($image, 151, 151, 151);
    ImageFilledRectangle($image, 0, 0, $width - 1, $height - 1, $back);
    ImageFilledRectangle($image, 1, 1, $ratingbar, $height - 1, $fill);
    ImageRectangle($image, 0, 0, $width - 1, $height - 1, $border);
    imagePNG($image);
    imagedestroy($image);
}
开发者ID:jamiebatch452,项目名称:Open-Game-Panel,代码行数:25,代码来源:bar.php

示例2: drawRating

function drawRating()
{
    $width = $_GET['width'];
    $height = $_GET['height'];
    if ($width == 0) {
        $width = 200;
    }
    if ($height == 0) {
        $height = 7;
    }
    $rating = $_GET['rating'];
    $ratingbar = $rating / 100 * $width - 2;
    $image = imagecreate($width, $height);
    $fill = ImageColorAllocate($image, 0, 255, 0);
    if ($rating > 49) {
        $fill = ImageColorAllocate($image, 255, 255, 0);
    }
    if ($rating > 74) {
        $fill = ImageColorAllocate($image, 255, 128, 0);
    }
    if ($rating > 89) {
        $fill = ImageColorAllocate($image, 255, 0, 0);
    }
    $back = ImageColorAllocate($image, 205, 205, 205);
    $border = ImageColorAllocate($image, 0, 0, 0);
    ImageFilledRectangle($image, 0, 0, $width - 1, $height - 1, $back);
    ImageFilledRectangle($image, 1, 1, $ratingbar, $height - 1, $fill);
    ImageRectangle($image, 0, 0, $width - 1, $height - 1, $border);
    imagePNG($image);
    imagedestroy($image);
}
开发者ID:SheppeR,项目名称:rapidleech,代码行数:31,代码来源:bar.php

示例3: weldMaps2PNG

 function weldMaps2PNG($urls, $filename, $encode = true)
 {
     if (!$urls || $urls == "") {
         $e = new mb_exception("weldMaps2PNG: no maprequests delivered");
     }
     $url = explode("___", $urls);
     $obj1 = new stripRequest($url[0]);
     $width = $obj1->get("width");
     $height = $obj1->get("height");
     $image = imagecreatetruecolor($width, $height);
     $white = ImageColorAllocate($image, 255, 255, 255);
     ImageFilledRectangle($image, 0, 0, $width, $height, $white);
     for ($i = 0; $i < count($url); $i++) {
         $obj = new stripRequest($url[$i]);
         $url[$i] = $obj->setPNG();
         $url[$i] = $obj->encodeGET($encode);
         $img = $this->loadpng($url[$i]);
         if ($img != false) {
             imagecopy($image, $img, 0, 0, 0, 0, $width, $height);
             @imagedestroy($img);
         } else {
             $e = new mb_exception("weldMaps2PNG: unable to load image: " . $url[$i]);
         }
     }
     imagepng($image, $filename);
     imagedestroy($image);
 }
开发者ID:bfpi,项目名称:klarschiff-frontend-mit-mapbender,代码行数:27,代码来源:class_weldMaps2PNG.php

示例4: SaveLegend

 function SaveLegend($url, $legend_filename)
 {
     if (!$url || $url == "") {
         $e = new mb_exception("SaveLegend: no legendurl delivered");
     }
     $x = new connector($url);
     //save file in tmp folder to extract right size - sometimes the size could not be detected by url!
     if ($legendFileHandle = fopen($legend_filename, "w")) {
         fwrite($legendFileHandle, $x->file);
         fclose($legendFileHandle);
         $e = new mb_notice("SaveLegend: new legend file created: " . $legend_filename);
     } else {
         $e = new mb_exception("SaveLegend: legend file " . $legend_filename . " could not be created!");
     }
     //get size of image
     $size = getimagesize($legend_filename);
     $width = $size[0];
     $height = $size[1];
     $image = imagecreatetruecolor($width, $height);
     $white = ImageColorAllocate($image, 255, 255, 255);
     ImageFilledRectangle($image, 0, 0, $width, $height, $white);
     //load image from url to create new image
     $img = $this->loadpng($url);
     if ($img != false) {
         imagecopy($image, $img, 0, 0, 0, 0, $width, $height);
     } else {
         $e = new mb_exception("SaveLegend: unable to load image: " . $url);
     }
     //save image to same filename as before
     imagepng($image, $legend_filename);
     imagedestroy($img);
 }
开发者ID:bfpi,项目名称:klarschiff-frontend-mit-mapbender,代码行数:32,代码来源:class_SaveLegend.php

示例5: drawRating

function drawRating($rating, $max, $type)
{
    if ($type == 0) {
        $image = imagecreatetruecolor(102, 15);
        $back = ImageColorAllocate($image, 250, 250, 250);
        $border = ImageColorAllocate($image, 0, 0, 0);
        $fill = ImageColorAllocate($image, 0, 235, 0);
        ImageFilledRectangle($image, 0, 0, 101, 14, $back);
        ImageFilledRectangle($image, 1, 1, $rating / $max * 100, 14, $fill);
        ImageRectangle($image, 0, 0, 101, 14, $border);
        $textcolor = imagecolorallocate($image, 0, 0, 0);
        imagestring($image, 5, 35, 0, $rating / $max * 100 . '%', $textcolor);
    } else {
        if ($rating > $max) {
            $rating = $max;
        }
        $image = imagecreatetruecolor(10 * ($rating + 2) + 2, 15);
        $back = ImageColorAllocate($image, 250, 250, 250);
        $border = ImageColorAllocate($image, 0, 0, 0);
        $fill = ImageColorAllocate($image, 235, 0, 0);
        ImageFilledRectangle($image, 0, 0, 10 * ($rating + 2) + 1, 14, $back);
        ImageFilledRectangle($image, 1, 1, 10 * $rating, 14, $fill);
        ImageRectangle($image, 0, 0, 10 * $rating + 1, 14, $border);
        $textcolor = imagecolorallocate($image, 0, 0, 0);
        imagestring($image, 5, 10 * ($rating + 1), 0, $rating, $textcolor);
    }
    imagepng($image);
    imagedestroy($image);
}
开发者ID:noahrichards,项目名称:pb,代码行数:29,代码来源:pngbar.php

示例6: weldOverview2PNG

 function weldOverview2PNG($url_overview, $url_extent, $filename)
 {
     if (!$url_overview || $url_overview == "") {
         $e = new mb_exception("weldOverview2PNG: no maprequests delivered");
     }
     $url = $url_overview;
     $obj1 = new stripRequest($url);
     $width = $obj1->get("width");
     $height = $obj1->get("height");
     /*
     $e = new mb_exception("--------overview-----------------");
     $e = new mb_exception("-----width ".$width." / height: ".$height."--------------------");
     $e = new mb_exception("url_overview: ".$url_overview);
     $e = new mb_exception("url_extent: ".$url_extent);
     */
     $image = imagecreatetruecolor($width, $height);
     $white = ImageColorAllocate($image, 255, 255, 255);
     ImageFilledRectangle($image, 0, 0, $width, $height, $white);
     //overview
     $obj = new stripRequest($url_overview);
     $xurl_overview = $obj->setPNG();
     $xurl_overview = $obj->encodeGET();
     $img = $this->loadpng($xurl_overview);
     if ($img != false) {
         imagecopy($image, $img, 0, 0, 0, 0, $width, $height);
     } else {
         $e = new mb_exception("weldMaps2PNG: unable to load image: " . $url_overview);
     }
     // rectangle - position of the map in the overview
     $objx = new stripRequest($url_extent);
     $ex_width = $objx->get("width");
     $ex_height = $objx->get("height");
     $extent = explode(",", $objx->get("BBOX"));
     $lowerleft = $this->makeRealWorld2mapPos($url_overview, round($extent[0]), round($extent[1]));
     $upperright = $this->makeRealWorld2mapPos($url_overview, $extent[2], $extent[3]);
     /*
     $e = new mb_exception("ex_width: " .$ex_width);
     $e = new mb_exception("ex_height: " . $ex_height);
     $e = new mb_exception("bbox:".$extent[0]."--".$extent[1]."--".$extent[2]."--------".$extent[3]);
     $e = new mb_exception("ll: " . $lowerleft[0]." / ".$lowerleft[1]);
     $e = new mb_exception("ur: " . $upperright[0]." / ".$upperright[1]);
     */
     $lowerleft[0] = round($lowerleft[0]);
     $lowerleft[1] = round($lowerleft[1]);
     $upperright[0] = round($upperright[0]);
     $upperright[1] = round($upperright[1]);
     $red = ImageColorAllocate($image, 255, 0, 0);
     imageline($image, $lowerleft[0], $upperright[1], $upperright[0], $upperright[1], $red);
     imageline($image, $upperright[0], $upperright[1], $upperright[0], $lowerleft[1], $red);
     imageline($image, $upperright[0], $lowerleft[1], $lowerleft[0], $lowerleft[1], $red);
     imageline($image, $lowerleft[0], $lowerleft[1], $lowerleft[0], $upperright[1], $red);
     // black frame - size of the overview
     $black = ImageColorAllocate($image, 0, 0, 0);
     imageline($image, 0, 0, $width - 1, 0, $black);
     imageline($image, $width - 1, 0, $width - 1, $height - 1, $black);
     imageline($image, $width - 1, $height - 1, 0, $height - 1, $black);
     imageline($image, 0, $height - 1, 0, 0, $black);
     imagepng($image, $filename);
     imagedestroy($image);
 }
开发者ID:bfpi,项目名称:klarschiff-frontend-mit-mapbender,代码行数:60,代码来源:class_weldOverview2PNG.php

示例7: drawRating

function drawRating($rating) {
   $width = $_GET['width'];
   $height = $_GET['height'];
   if ($width == 0) {
     $width = 102;
   }
   if ($height == 0) {
     $height = 10;
   }

   $rating = $_GET['rating'];
   $ratingbar = (($rating/100)*$width)-2;

   $image = imagecreate($width,$height);
   //colors
   $back = ImageColorAllocate($image,255,255,255);
   $border = ImageColorAllocate($image,0,0,0);
   $red = ImageColorAllocate($image,255,60,75);
   $fill = ImageColorAllocate($image,44,81,150);

   ImageFilledRectangle($image,0,0,$width-1,$height-1,$back);
   ImageFilledRectangle($image,1,1,$ratingbar,$height-1,$fill);
   ImageRectangle($image,0,0,$width-1,$height-1,$border);
   imagePNG($image);
   imagedestroy($image);
}
开发者ID:jasimmk,项目名称:DeveloperSupport,代码行数:26,代码来源:image.php

示例8: ConvertToImage

function ConvertToImage($content)
{
    $imageFile = ".counter.png";
    $relativePath = ".counter.png";
    $noOfChars = strlen($content);
    $charHeight = ImageFontHeight(5);
    $charWidth = ImageFontWidth(5);
    $strWidth = $charWidth * $noOfChars;
    $strHeight = $charHeight;
    //15 padding
    $imgWidth = $strWidth + 15;
    $imgHeight = $strHeight + 15;
    $imgCenterX = $imgWidth / 2;
    $imgCenterY = $imgHeight / 2;
    $im = ImageCreate($imgWidth, $imgHeight);
    $script = ImageColorAllocate($im, 0, 255, 0);
    $outercolor = ImageColorAllocate($im, 99, 140, 214);
    $innercolor = ImageColorAllocate($im, 0, 0, 0);
    ImageFilledRectangle($im, 0, 0, $imgWidth, $imgHeight, $outercolor);
    ImageFilledRectangle($im, 3, 3, $imgWidth - 4, $imgHeight - 4, $innercolor);
    //draw string
    $drawPosX = $imgCenterX - $strWidth / 2 + 1;
    $drawPosY = $imgCenterY - $strHeight / 2;
    ImageString($im, 5, $drawPosX, $drawPosY, $content, $script);
    //save image and return
    ImagePNG($im, $imageFile);
    return $relativePath;
}
开发者ID:sahil2441,项目名称:Prolog-Problems,代码行数:28,代码来源:counter.php

示例9: bar_chart

function bar_chart($question, $answers)
{
    // define colors to draw the bars
    $colors = array(0xff6600, 0x9900, 0x3333cc, 0xff0033, 0xffff00, 0x66ffff, 0x9900cc);
    $total = array_sum($answers['votes']);
    // define spacing values and other magic numbers
    $padding = 5;
    $line_width = 20;
    $scale = $line_width * 7.5;
    $bar_height = 10;
    $x = $y = $padding;
    // allocate a large palette for drawing, since you don't know
    // the image length ahead of time
    $image = ImageCreateTrueColor(150, 500);
    ImageFilledRectangle($image, 0, 0, 149, 499, 0xe0e0e0);
    $black = 0x0;
    // print the question
    $wrapped = explode("\n", wordwrap($question, $line_width));
    foreach ($wrapped as $line) {
        ImageString($image, 3, $x, $y, $line, $black);
        $y += 12;
    }
    $y += $padding;
    // print the answers
    for ($i = 0; $i < count($answers['answer']); $i++) {
        // format percentage
        $percent = sprintf('%1.1f', 100 * $answers['votes'][$i] / $total);
        $bar = sprintf('%d', $scale * $answers['votes'][$i] / $total);
        // grab color
        $c = $i % count($colors);
        // handle cases with more bars than colors
        $text_color = $colors[$c];
        // draw bar and percentage numbers
        ImageFilledRectangle($image, $x, $y, $x + $bar, $y + $bar_height, $text_color);
        ImageString($image, 3, $x + $bar + $padding, $y, "{$percent}%", $black);
        $y += 12;
        // print answer
        $wrapped = explode("\n", wordwrap($answers['answer'][$i], $line_width));
        foreach ($wrapped as $line) {
            ImageString($image, 2, $x, $y, $line, $black);
            $y += 12;
        }
        $y += 7;
    }
    // crop image by copying it
    $chart = ImageCreateTrueColor(150, $y);
    ImageCopy($chart, $image, 0, 0, 0, 0, 150, $y);
    // PHP 5.5+ supports
    // $chart = ImageCrop($image, array('x' => 0, 'y' => 0,
    //                                  'width' => 150, 'height' => $y));
    // deliver image
    header('Content-type: image/png');
    ImagePNG($chart);
    // clean up
    ImageDestroy($image);
    ImageDestroy($chart);
}
开发者ID:zmwebdev,项目名称:PHPcookbook-code-3ed,代码行数:57,代码来源:poll1.php

示例10: createBase

 private function createBase()
 {
     $this->image = imagecreatetruecolor($this->size[0], $this->size[1]);
     // Creation de l'image de sortie
     // Declaration couleur
     $blanc = imagecolorallocate($this->image, $this->background[0], $this->background[1], $this->background[2]);
     // Couleur de fond
     $fond = ImageFilledRectangle($this->image, 0, 0, imagesx($this->image), imagesy($this->image), $blanc);
 }
开发者ID:pecqueurS,项目名称:hylacore,代码行数:9,代码来源:ConvertImg.php

示例11: createImage

 private function createImage()
 {
     $red = '0x' . substr($this->color, 1, 2);
     $green = '0x' . substr($this->color, 3, 2);
     $blue = '0x' . substr($this->color, 5, 2);
     $baseIMG = @imagecreatetruecolor($this->maxW, $this->maxH);
     $color = imagecolorallocate($baseIMG, $red, $green, $blue);
     ImageFilledRectangle($baseIMG, 0, 0, $this->maxW, $this->maxH, $color);
     $this->baseIMG = $baseIMG;
 }
开发者ID:villos,项目名称:tree_admin,代码行数:10,代码来源:WorkWithFotoNew.php

示例12: drawSampleImage

function drawSampleImage()
{
    echo 'drawSampleImage called';
    $im = ImageCreate(200, 200);
    $white = ImageColorAllocate($im, 0xff, 0xff, 0xff);
    $black = ImageColorAllocate($im, 0x0, 0x0, 0x0);
    ImageFilledRectangle($im, 50, 50, 150, 150, $black);
    header('Content-Type: image/png');
    ImagePNG($im);
}
开发者ID:nsatvik,项目名称:Sample,代码行数:10,代码来源:search.php

示例13: Plot

 public function Plot($Coord)
 {
     list($CoordsX, $CoordsY) = map::ss2xy($Coord);
     $p1 = ($CoordsX - 1) * $this->tc + 1;
     $p2 = $CoordsY * $this->tc + 1;
     $p3 = $p1 + $this->tc - 2;
     $p4 = $p2 + $this->tc - 2;
     ImageFilledRectangle($this->im, $p1, $p2, $p3, $p4, $this->color);
     return $this;
 }
开发者ID:google-code-backups,项目名称:eude,代码行数:10,代码来源:img.class.php

示例14: resample

 public function resample($src, $dst, $width = '', $height = '', $square = false)
 {
     if (is_file($dst)) {
         return;
         // unlink($dst);
     }
     $size = getimagesize($src);
     if (!$size[0] || !$size[1]) {
         return;
     }
     list($oldWidth, $oldHeight, $type) = getimagesize($src);
     $ext = $this->image_type_to_extension($type);
     $scale = min($width / $size[0], $height / $size[1]);
     // echo $scale;
     if ($scale == 1) {
         // return;
     }
     $newwidth = (int) ($size[0] * $scale);
     $newheight = (int) ($size[1] * $scale);
     if ($square) {
         $xpos = (int) (($width - $newwidth) / 2);
         $ypos = (int) (($height - $newheight) / 2);
     } else {
         $width = $newwidth;
         $height = $newheight;
         $xpos = 0;
         $ypos = 0;
     }
     $destImg = ImageCreateTrueColor($width, $height);
     $backColor = ImageColorAllocate($destImg, 255, 255, 255);
     ImageFilledRectangle($destImg, 0, 0, $width, $height, $backColor);
     // $sourceImg = ImageCreateFromJPEG ($src);
     switch ($ext) {
         case 'gif':
             $sourceImg = imagecreatefromgif($src);
             break;
         case 'png':
             $sourceImg = imagecreatefrompng($src);
             break;
         case 'jpg':
         case 'jpeg':
             $sourceImg = imagecreatefromjpeg($src);
             break;
         default:
             return false;
             break;
     }
     ImageCopyResampled($destImg, $sourceImg, $xpos, $ypos, 0, 0, $newwidth, $newheight, $size[0], $size[1]);
     imagejpeg($destImg, $dst, 70);
     $data['width'] = $width;
     $data['height'] = $height;
     return $data;
 }
开发者ID:beyondkeysystem,项目名称:testone,代码行数:53,代码来源:ImageupdateShell.php

示例15: setup

 function setup()
 {
     $this->map = array();
     $nthis->umStarts = 0;
     $this->numBases = 0;
     $this->numPills = 0;
     $this->img = ImageCreate(255, 255);
     $this->pens = array();
     $this->pens[0] = ImageColorAllocate($this->img, 179, 121, 15);
     /* BUILDING */
     $this->pens[1] = ImageColorAllocate($this->img, 0, 255, 255);
     /* RIVER */
     $this->pens[2] = ImageColorAllocate($this->img, 0, 128, 128);
     /* SWAMP */
     $this->pens[3] = ImageColorAllocate($this->img, 128, 64, 0);
     /* CRATER */
     $this->pens[4] = ImageColorAllocate($this->img, 0, 0, 0);
     /* ROAD */
     $this->pens[5] = ImageColorAllocate($this->img, 0, 128, 0);
     /* FOREST */
     $this->pens[6] = ImageColorAllocate($this->img, 234, 165, 123);
     /* RUBBLE */
     $this->pens[7] = ImageColorAllocate($this->img, 0, 255, 0);
     /* GRASS */
     $this->pens[8] = ImageColorAllocate($this->img, 223, 152, 19);
     /* SHOT_BUILDING */
     $this->pens[9] = ImageColorAllocate($this->img, 0, 0, 121);
     /* BOAT */
     $this->pens[10] = ImageColorAllocate($this->img, 0, 128, 128);
     /* SWAMP + MINE */
     $this->pens[11] = ImageColorAllocate($this->img, 128, 64, 0);
     /* CRATER_MINE */
     $this->pens[12] = ImageColorAllocate($this->img, 0, 0, 0);
     /* ROAD_MINE  */
     $this->pens[13] = ImageColorAllocate($this->img, 0, 128, 0);
     /* FOREST_MINE */
     $this->pens[14] = ImageColorAllocate($this->img, 234, 165, 123);
     /* RUBBLE_MINE */
     $this->pens[15] = ImageColorAllocate($this->img, 0, 255, 0);
     /* GrassMine */
     $this->pens[16] = ImageColorAllocate($this->img, 0, 0, 255);
     /* DEEP_SEA */
     $this->pens[18] = ImageColorAllocate($this->img, 255, 0, 0);
     /* PILLBOX */
     $this->pens[17] = ImageColorAllocate($this->img, 255, 255, 0);
     /* BASE */
     $this->pens[19] = ImageColorAllocate($this->img, 128, 128, 128);
     /* START */
     ImageFilledRectangle($this->img, 0, 0, 255, 255, $this->pens[16]);
     $this->water = imagecolorexact($this->img, 0, 0, 255);
 }
开发者ID:andrewroth,项目名称:winbolo,代码行数:51,代码来源:mapimageclass.php


注:本文中的ImageFilledRectangle函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。