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


PHP ImagickDraw::line方法代码示例

本文整理汇总了PHP中ImagickDraw::line方法的典型用法代码示例。如果您正苦于以下问题:PHP ImagickDraw::line方法的具体用法?PHP ImagickDraw::line怎么用?PHP ImagickDraw::line使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ImagickDraw的用法示例。


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

示例1: histogram

 public function histogram()
 {
     for ($i = 0; $i <= 256; $i++) {
         $this->data[$i] = array('r' => 0, 'g' => 0, 'b' => 0, 'y' => 0);
     }
     $this->iterate('hist_prepare');
     $maxPixelCount = 0;
     foreach ($this->data as $k => $v) {
         $maxPixelCount = max($maxPixelCount, $v['r'], $v['g'], $v['b'], $v['y']);
     }
     $this->img->newImage(512, 512, new ImagickPixel('white'));
     $this->img->setImageFormat('png');
     $draw = new ImagickDraw();
     for ($i = 0; $i < 257; $i++) {
         $draw->setStrokeColor('#ff0000');
         $draw->line($i * 2, 512, $i * 2, 512 - $this->data[$i]['r'] / $maxPixelCount * 512);
         $draw->setStrokeColor('#00ff00');
         $draw->line($i * 2, 512, $i * 2, 512 - $this->data[$i]['g'] / $maxPixelCount * 512);
         $draw->setStrokeColor('#0000ff');
         $draw->line($i * 2, 512, $i * 2, 512 - $this->data[$i]['b'] / $maxPixelCount * 512);
         $draw->setStrokeColor('#aaaaaa');
         $draw->line($i * 2, 512, $i * 2, 512 - $this->data[$i]['y'] / $maxPixelCount * 512);
     }
     $this->img->drawImage($draw);
 }
开发者ID:Atiragram,项目名称:poit-labs,代码行数:25,代码来源:fksistagram.php

示例2: drawChartBackground

 function drawChartBackground()
 {
     $this->draw->line(25, $this->chartHeight / 2, $this->chartWidth - 25, $this->chartHeight / 2);
     $this->draw->line($this->chartWidth / 2, 25, $this->chartWidth / 2, $this->chartHeight - 25);
     $this->draw->setFillColor('none');
     $this->draw->circle($this->chartWidth / 2, $this->chartHeight / 2, $this->chartWidth / 2, $this->chartHeight / 2 + 200);
     $this->draw->circle($this->chartWidth / 2, $this->chartHeight / 2, $this->chartWidth / 2, $this->chartHeight / 2 + 100);
 }
开发者ID:sdmmember,项目名称:Imagick-demos,代码行数:8,代码来源:smoothSpiderGraph.php

示例3: border

 /**
  * Add border
  * @param integer $width Border width
  * @param string $color Border color
  * @return Imagick
  */
 public function border($width, $color)
 {
     $border = new \ImagickDraw();
     $border->setFillColor('none');
     $border->setStrokeColor(new \ImagickPixel($color));
     $border->setStrokeWidth($width);
     $widthPart = $width / 2;
     $border->line(0, 0 + $widthPart, $this->width, 0 + $widthPart);
     $border->line(0, $this->height - $widthPart, $this->width, $this->height - $widthPart);
     $border->line(0 + $widthPart, 0, 0 + $widthPart, $this->height);
     $border->line($this->width - $widthPart, 0, $this->width - $widthPart, $this->height);
     $this->image->drawImage($border);
     return $this;
 }
开发者ID:tpmanc,项目名称:yii2-imagick,代码行数:20,代码来源:Imagick.php

示例4: drawLine

 /**
  * Draw line between points
  * Нарисовать линии между указанными точками
  * @param int $sx
  * @param int $sy
  * @param int $ex
  * @param int $ey
  */
 public function drawLine($sx, $sy, $ex, $ey)
 {
     $draw = new \ImagickDraw();
     $draw->setStrokeColor($this->black);
     $draw->setStrokeWidth(1);
     $draw->line($sx, $sy, $ex, $ey);
     $this->drawImage($draw);
 }
开发者ID:Cherkesov,项目名称:GFB-MosaicBundle,代码行数:16,代码来源:ImagickExt.php

示例5: analyzeImage

 /**
  * @param \Imagick $imagick
  * @param int $graphWidth
  * @param int $graphHeight
  */
 public static function analyzeImage(\Imagick $imagick, $graphWidth = 255, $graphHeight = 127)
 {
     $sampleHeight = 20;
     $border = 2;
     $imagick->transposeImage();
     $imagick->scaleImage($graphWidth, $sampleHeight);
     $imageIterator = new \ImagickPixelIterator($imagick);
     $luminosityArray = [];
     foreach ($imageIterator as $row => $pixels) {
         /* Loop through pixel rows */
         foreach ($pixels as $column => $pixel) {
             /* Loop through the pixels in the row (columns) */
             /** @var $pixel \ImagickPixel */
             if (false) {
                 $color = $pixel->getColor();
                 $luminosityArray[] = $color['r'];
             } else {
                 $hsl = $pixel->getHSL();
                 $luminosityArray[] = $hsl['luminosity'];
             }
         }
         /* Sync the iterator, this is important to do on each iteration */
         $imageIterator->syncIterator();
         break;
     }
     $draw = new \ImagickDraw();
     $strokeColor = new \ImagickPixel('red');
     $fillColor = new \ImagickPixel('red');
     $draw->setStrokeColor($strokeColor);
     $draw->setFillColor($fillColor);
     $draw->setStrokeWidth(0);
     $draw->setFontSize(72);
     $draw->setStrokeAntiAlias(true);
     $previous = false;
     $x = 0;
     foreach ($luminosityArray as $luminosity) {
         $pos = $graphHeight - 1 - $luminosity * ($graphHeight - 1);
         if ($previous !== false) {
             /** @var $previous int */
             //printf ( "%d, %d, %d, %d <br/>\n" , $x - 1, $previous, $x, $pos);
             $draw->line($x - 1, $previous, $x, $pos);
         }
         $x += 1;
         $previous = $pos;
     }
     $plot = new \Imagick();
     $plot->newImage($graphWidth, $graphHeight, 'white');
     $plot->drawImage($draw);
     $outputImage = new \Imagick();
     $outputImage->newImage($graphWidth, $graphHeight + $sampleHeight, 'white');
     $outputImage->compositeimage($plot, \Imagick::COMPOSITE_ATOP, 0, 0);
     $outputImage->compositeimage($imagick, \Imagick::COMPOSITE_ATOP, 0, $graphHeight);
     $outputImage->borderimage('black', $border, $border);
     $outputImage->setImageFormat("png");
     App::cachingHeader("Content-Type: image/png");
     echo $outputImage;
 }
开发者ID:danack,项目名称:imagick-demos,代码行数:62,代码来源:Image.php

示例6: applyToImage

 /**
  * Draw current instance of line to given endpoint on given image
  *
  * @param  Image   $image
  * @param  integer $x
  * @param  integer $y
  * @return boolean
  */
 public function applyToImage(Image $image, $x = 0, $y = 0)
 {
     $line = new \ImagickDraw();
     $color = new Color($this->color);
     $line->setStrokeColor($color->getPixel());
     $line->setStrokeWidth($this->width);
     $line->line($this->x, $this->y, $x, $y);
     $image->getCore()->drawImage($line);
     return true;
 }
开发者ID:hilmysyarif,项目名称:sic,代码行数:18,代码来源:LineShape.php

示例7: perform

 /**
  * Draw a line on the image, returns the GD-handle
  *
  * @param  Zend_Image_Adapter_ImageMagick image resource    $handle Image to work on
  * @param  Zend_Image_Action_DrawLine   $lineObject The object containing all settings needed for drawing a line.
  * @return void
  */
 public function perform(Zend_Image_Adapter_ImageMagick $adapter, Zend_Image_Action_DrawLine $lineObject)
 {
     $handle = $adapter->getHandle();
     $draw = new ImagickDraw();
     $draw->setStrokeWidth($lineObject->getStrokeWidth());
     $color = $lineObject->getStrokeColor();
     $draw->setStrokeColor((string) $color);
     $draw->setStrokeOpacity($lineObject->getStrokeAlpha());
     $draw->line($lineObject->getPointStart()->getX(), $lineObject->getPointStart()->getY(), $lineObject->getPointEnd()->getX(), $lineObject->getPointEnd()->getY());
     $handle->drawImage($draw);
 }
开发者ID:BGCX262,项目名称:zym-svn-to-git,代码行数:18,代码来源:DrawLine.php

示例8: draw

 /**
  * @param Image $image
  *
  * @return Image
  */
 public function draw($image)
 {
     $strokeColor = new \ImagickPixel($this->getColor()->getHexString());
     $draw = new \ImagickDraw();
     $draw->setStrokeColor($strokeColor);
     $draw->setStrokeWidth($this->thickness);
     list($x1, $y1) = $this->point1;
     list($x2, $y2) = $this->point2;
     $draw->line($x1, $y1, $x2, $y2);
     $image->getCore()->drawImage($draw);
     return $image;
 }
开发者ID:kosinix,项目名称:grafika,代码行数:17,代码来源:Line.php

示例9: GetView

 function GetView()
 {
     global $TMP_PATH;
     $tmp_file = ADEI::GetTmpFile();
     $im = new Imagick();
     $tmp = new Imagick();
     $image = new Imagick();
     $final = new Imagick();
     $with_axes = new Imagick();
     $output = new Imagick();
     $tick = new ImagickDraw();
     $ceiling = new ImagickDraw();
     $color = new ImagickPixel('#666666');
     $background = new ImagickPixel('none');
     // Transparent
     date_default_timezone_set('UTC');
     $servername = "localhost";
     $username = "cube";
     $password = "cube";
     $dbname = "HDCP10";
     $req = $this->req->CreateGroupRequest();
     $req = $this->req->CreateDataRequest();
     $fstart = $req->GetProp("view_pb_start", 0);
     $width = $req->GetProp("control_width", 800);
     $height = $req->GetProp("control_height", 600);
     $height = $height - 180;
     // 60px for the xaxis (50px)
     $start = 1367366400000000.0;
     // GMT: Wed, 01 May 2013 00:00:00 GMT
     $end = 1367452800000000.0;
     // GMT: Thu, 02 May 2013 00:00:00 GMT
     //$end = 1367539200000000; // GMT: Fri, 03 May 2013 00:00:00 GMT
     $current = $start;
     $step = 3600000000.0;
     try {
         $conn = new PDO("mysql:host={$servername};dbname={$dbname}", $username, $password);
         // set the PDO error mode to exception
         $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         while (true) {
             if ($current >= $end) {
                 break;
             }
             $start_interval = $current;
             $end_interval = $start_interval + $step;
             $sql = "SELECT img_id, image, timestamp FROM Profiles_060_WTH_STATIC_EL90_Images_Stitch_Im1_3600 WHERE timestamp >= " . $start_interval . " AND timestamp < " . $end_interval;
             $stmt = $conn->query($sql);
             $row = $stmt->fetchObject();
             if ($row == false) {
                 $im->newImage($width, $height - $height * 20 / 100, "white");
             } else {
                 if (is_null($row->image)) {
                     $im->newImage($width, $height - $height * 20 / 100, "white");
                 } else {
                     $im->readimageblob($row->image);
                     $im->resizeImage($width, $height - $height * 20 / 100, Imagick::FILTER_LANCZOS, 1);
                 }
             }
             #$text = date('H:s', ($current / 1000000));
             #$draw = new ImagickDraw();
             $tick = new ImagickDraw();
             $ceiling = new ImagickDraw();
             /* Font properties */
             #$draw->setFont('Arial');
             #$draw->setFontSize(200);
             #$draw->setFillColor($color);
             #$draw->setStrokeAntialias(true);
             #$draw->setTextAntialias(true);
             /* Get font metrics */
             #$metrics = $image->queryFontMetrics($draw, $text);
             /* Create text */
             #$draw->annotation(0, $metrics['ascender']+20, $text);
             $tick->setStrokeWidth(10);
             $tick->setStrokeColor($color);
             $tick->setFillColor($color);
             $tick->line(0, 0, 0, 20);
             //imageline($image, $width/2, 0, $width/2, 50, $color);
             $ceiling->setStrokeColor($color);
             $ceiling->setFillColor($color);
             $ceiling->line(0, 0, $width, 0);
             /* Create image */
             $image->newImage($width, 20, $background);
             $image->setImageFormat('png');
             #$image->drawImage($draw);
             $image->drawImage($tick);
             $image->drawImage($ceiling);
             $im->addImage($image);
             $im->resetIterator();
             $tmp = $im->appendImages(true);
             $final->addImage($tmp);
             $current = $end_interval;
             $im->clear();
             $image->clear();
             $tmp->clear();
             $tick->clear();
             $ceiling->clear();
         }
     } catch (PDOException $e) {
         //echo "Connection failed: " . $e->getMessage();
     }
     /* Append the images into one */
//.........这里部分代码省略.........
开发者ID:nicolaisi,项目名称:adei,代码行数:101,代码来源:pbview.php

示例10: imagickLine

 /**
  * 在图片上划线
  * @param  object  $image             Imagick的实例
  * @param  integer $num               画线的数量
  * @return object  Imagick的实例
  */
 protected function imagickLine($image, $num = 4)
 {
     $draw = new \ImagickDraw();
     for ($i = 0; $i < $num; $i++) {
         $color = $this->randColor();
         $startx = rand(0, $this->width);
         $endx = rand(0, $this->width);
         $starty = rand(0, $this->height);
         $endy = rand(0, $this->height);
         $draw->setStrokeColor($color);
         $draw->setFillColor($color);
         $draw->setStrokeWidth(2);
         $draw->line($startx, $starty, $endx, $endy);
     }
     $image->drawImage($draw);
     $draw->destroy();
     return $image;
 }
开发者ID:feixingbeibao,项目名称:vitexframework,代码行数:24,代码来源:Captcha.php

示例11: drawArc

 /**
  * Method to add an arc to the image.
  *
  * @param  int $x
  * @param  int $y
  * @param  int $start
  * @param  int $end
  * @param  int $w
  * @param  int $h
  * @return \Pop\Image\Imagick
  */
 public function drawArc($x, $y, $start, $end, $w, $h = null)
 {
     $wid = $w;
     $hgt = null === $h ? $w : $h;
     $draw = new \ImagickDraw();
     $draw->setFillColor($this->setColor($this->fillColor));
     $x1 = $w * cos($start / 180 * pi());
     $y1 = $h * sin($start / 180 * pi());
     $x2 = $w * cos($end / 180 * pi());
     $y2 = $h * sin($end / 180 * pi());
     $points = array(array('x' => $x, 'y' => $y), array('x' => $x + $x1, 'y' => $y + $y1), array('x' => $x + $x2, 'y' => $y + $y2));
     $draw->polygon($points);
     $draw->ellipse($x, $y, $wid, $hgt, $start, $end);
     $this->resource->drawImage($draw);
     if (null !== $this->strokeWidth) {
         $draw = new \ImagickDraw();
         $draw->setFillColor($this->setColor($this->fillColor));
         $draw->setStrokeColor($this->setColor($this->strokeColor));
         $draw->setStrokeWidth(null === $this->strokeWidth ? 1 : $this->strokeWidth);
         $draw->ellipse($x, $y, $wid, $hgt, $start, $end);
         $draw->line($x, $y, $x + $x1, $y + $y1);
         $draw->line($x, $y, $x + $x2, $y + $y2);
         $this->resource->drawImage($draw);
     }
     return $this;
 }
开发者ID:nicksagona,项目名称:PopPHP,代码行数:37,代码来源:Imagick.php

示例12: ImagickDraw

     if (is_null($row->image)) {
         $im->newImage($width, $height, "white");
     } else {
         $im->readimageblob($row->image);
         $im->resizeImage($width, $height, Imagick::FILTER_LANCZOS, 1);
     }
 }
 $tick = new ImagickDraw();
 $tick->setStrokeWidth(10);
 $tick->setStrokeColor($color);
 $tick->setFillColor($color);
 $tick->line(0, 0, 0, 20);
 $ceiling = new ImagickDraw();
 $ceiling->setStrokeColor($color);
 $ceiling->setFillColor($color);
 $ceiling->line(0, 0, $width, 0);
 /* Create image */
 $image->newImage($width, 20, $background);
 $image->setImageFormat('png');
 $image->drawImage($tick);
 $image->drawImage($ceiling);
 $im->addImage($image);
 $im->resetIterator();
 $tmp = $im->appendImages(true);
 $final->addImage($tmp);
 $current = $end_interval;
 $im->clear();
 $image->clear();
 $tmp->clear();
 $tick->clear();
 $ceiling->clear();
开发者ID:nicolaisi,项目名称:adei,代码行数:31,代码来源:test.php

示例13: pie

 /**
  * Draw a pie slice on the image.
  *
  * @param  int $x
  * @param  int $y
  * @param  int $start
  * @param  int $end
  * @param  int $w
  * @param  int $h
  * @return Imagick
  */
 public function pie($x, $y, $start, $end, $w, $h = null)
 {
     $wid = $w;
     $hgt = null === $h ? $w : $h;
     $draw = new \ImagickDraw();
     $draw->setFillColor($this->image->getColor($this->fillColor));
     $x1 = $w * cos($start / 180 * pi());
     $y1 = $h * sin($start / 180 * pi());
     $x2 = $w * cos($end / 180 * pi());
     $y2 = $h * sin($end / 180 * pi());
     $points = [['x' => $x, 'y' => $y], ['x' => $x + $x1, 'y' => $y + $y1], ['x' => $x + $x2, 'y' => $y + $y2]];
     $draw->polygon($points);
     $draw->ellipse($x, $y, $wid, $hgt, $start, $end);
     $this->image->resource()->drawImage($draw);
     if ($this->strokeWidth > 0) {
         $draw = new \ImagickDraw();
         $draw->setFillColor($this->image->getColor($this->fillColor));
         $draw->setStrokeColor($this->image->getColor($this->strokeColor));
         $draw->setStrokeWidth($this->strokeWidth);
         $draw->ellipse($x, $y, $wid, $hgt, $start, $end);
         $draw->line($x, $y, $x + $x1, $y + $y1);
         $draw->line($x, $y, $x + $x2, $y + $y2);
         $this->image->resource()->drawImage($draw);
     }
     return $this;
 }
开发者ID:popphp,项目名称:pop-image,代码行数:37,代码来源:Imagick.php

示例14: WriteLine

 /**
  * Horizontal line insertion
  */
 protected function WriteLine()
 {
     if ($this->useImageMagick) {
         $x1 = $this->width * $this->scale * 0.15;
         $x2 = $this->textFinalX;
         $y1 = rand($this->height * $this->scale * 0.4, $this->height * $this->scale * 0.65);
         $y2 = rand($this->height * $this->scale * 0.4, $this->height * $this->scale * 0.65);
         $width = $this->lineWidth / 2 * $this->scale;
         $draw = new ImagickDraw();
         $draw->setFillColor($this->GdFgColor);
         for ($i = $width * -1; $i <= $width; $i++) {
             $draw->line($x1, $y1 + $i, $x2, $y2 + $i);
         }
         $this->im->drawImage($draw);
     } else {
         $x1 = $this->width * $this->scale * 0.15;
         $x2 = $this->textFinalX;
         $y1 = rand($this->height * $this->scale * 0.4, $this->height * $this->scale * 0.65);
         $y2 = rand($this->height * $this->scale * 0.4, $this->height * $this->scale * 0.65);
         $width = $this->lineWidth / 2 * $this->scale;
         for ($i = $width * -1; $i <= $width; $i++) {
             imageline($this->im, $x1, $y1 + $i, $x2, $y2 + $i, $this->GdFgColor);
         }
     }
 }
开发者ID:Droon99-Developer,项目名称:Mitsuba,代码行数:28,代码来源:simplecaptcha.php

示例15: Imagick

     $i++;
 }
 $xaxis = new Imagick();
 $xaxis->newImage($width, 50, $background);
 $xaxis->setImageFormat('png');
 $xaxis->drawImage($draw);
 $yaxis_top = new Imagick();
 $yaxis_top->newImage($width_yaxis, $height - 68, $background);
 $yaxis_top->setImageFormat('png');
 $ytick = new ImagickDraw();
 $ytick->setStrokeWidth(1);
 $ytick->setStrokeColor($color);
 $ytick->setFillColor($color);
 $ybox = ($height - 68) / 8;
 for ($i = 0; $i <= 8; $i++) {
     $ytick->line($width_yaxis * 0.8, $i * $ybox, $width_yaxis, $i * $ybox);
     $yaxis_top->annotateImage($draw, 10, $height - 68 - $i * $ybox - 5, 0, $i * 1000);
 }
 $yaxis_top->drawImage($ytick);
 $yaxis_bot = new Imagick();
 $yaxis_bot->newImage($width_yaxis, 68, $background);
 $yaxis_bot->setImageFormat('png');
 $yaxis->addImage($yaxis_top);
 $yaxis->addImage($yaxis_bot);
 $yaxis->resetIterator();
 $yaxis_output = $yaxis->appendImages(true);
 $with_axes->addImage($combined);
 $with_axes->addImage($xaxis);
 $with_axes->resetIterator();
 $output = $with_axes->appendImages(true);
 $path_parts = pathinfo($tmp_file);
开发者ID:nicolaisi,项目名称:adei-cube,代码行数:31,代码来源:check_mode.php


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