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


PHP Image\PointInterface类代码示例

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


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

示例1: crop

 /**
  * (non-PHPdoc)
  * @see Imagine\ImageInterface::crop()
  */
 public function crop(PointInterface $start, BoxInterface $size)
 {
     if (!$start->in($size)) {
         throw new OutOfBoundsException('Crop coordinates must start at minimum 0, 0 position from ' . 'top left corner, crop height and width must be positive ' . 'integers and must not exceed the current image borders');
     }
     try {
         $this->gmagick->cropimage($size->getWidth(), $size->getHeight(), $start->getX(), $start->getY());
     } catch (\GmagickException $e) {
         throw new RuntimeException('Crop operation failed', $e->getCode(), $e);
     }
     return $this;
 }
开发者ID:nicodmf,项目名称:Imagine,代码行数:16,代码来源:Image.php

示例2: crop

 public function crop(PointInterface $start, BoxInterface $size)
 {
     if ($this->image === null) {
         $this->load();
     }
     $width = $size->getWidth();
     $height = $size->getHeight();
     try {
         $this->image->getGmagick()->cropimage($width, $height, $start->getX(), $start->getY());
     } catch (\GmagickException $e) {
         throw new \Imagine\Exception\RuntimeException("Gmagick: Crop operation failed. {$e->getMessage()}", $e->getCode(), $e);
     }
     $this->size = array($width, $height);
     return $this;
 }
开发者ID:raadhuis,项目名称:modx-basic,代码行数:15,代码来源:RImage.php

示例3: crop

 /**
  * {@inheritdoc}
  */
 public function crop(PointInterface $start, BoxInterface $size)
 {
     if (!$start->in($this->getSize())) {
         throw new OutOfBoundsException('Crop coordinates must start at minimum 0, 0 position from top left corner, crop height and width ' . 'must be positive integers and must not exceed the current image borders');
     }
     $this->fixViewBox();
     $svg = $this->document->documentElement;
     $svg->setAttribute('x', -$start->getX());
     $svg->setAttribute('y', -$start->getY());
     $svgWrap = $this->document->createElementNS('http://www.w3.org/2000/svg', 'svg');
     $svgWrap->setAttribute('version', '1.1');
     $svgWrap->setAttribute('width', $size->getWidth());
     $svgWrap->setAttribute('height', $size->getHeight());
     $svgWrap->appendChild($svg);
     $this->document->appendChild($svgWrap);
     return $this;
 }
开发者ID:contao,项目名称:imagine-svg,代码行数:20,代码来源:Image.php

示例4: getColorAt

 /**
  * {@inheritdoc}
  */
 public function getColorAt(PointInterface $point)
 {
     if (!$point->in($this->getSize())) {
         throw new RuntimeException(sprintf('Error getting color at point [%s,%s]. The point must be inside the image of size [%s,%s]', $point->getX(), $point->getY(), $this->getSize()->getWidth(), $this->getSize()->getHeight()));
     }
     try {
         $cropped = clone $this->gmagick;
         $histogram = $cropped->cropImage(1, 1, $point->getX(), $point->getY())->getImageHistogram();
     } catch (\GmagickException $e) {
         throw new RuntimeException('Unable to get the pixel');
     }
     $pixel = array_shift($histogram);
     unset($histogram, $cropped);
     return $this->pixelToColor($pixel);
 }
开发者ID:luoshulin,项目名称:falcon,代码行数:18,代码来源:Image.php

示例5: text

 /**
  * {@inheritdoc}
  */
 public function text($string, AbstractFont $font, PointInterface $position, $angle = 0)
 {
     try {
         $pixel = $this->getColor($font->getColor());
         $text = new \GmagickDraw();
         $text->setfont($font->getFile());
         /**
          * @see http://www.php.net/manual/en/imagick.queryfontmetrics.php#101027
          *
          * ensure font resolution is the same as GD's hard-coded 96
          */
         $text->setfontsize((int) ($font->getSize() * (96 / 72)));
         $text->setfillcolor($pixel);
         $info = $this->gmagick->queryfontmetrics($text, $string);
         $rad = deg2rad($angle);
         $cos = cos($rad);
         $sin = sin($rad);
         $x1 = round(0 * $cos - 0 * $sin);
         $x2 = round($info['textWidth'] * $cos - $info['textHeight'] * $sin);
         $y1 = round(0 * $sin + 0 * $cos);
         $y2 = round($info['textWidth'] * $sin + $info['textHeight'] * $cos);
         $xdiff = 0 - min($x1, $x2);
         $ydiff = 0 - min($y1, $y2);
         $this->gmagick->annotateimage($text, $position->getX() + $x1 + $xdiff, $position->getY() + $y2 + $ydiff, $angle, $string);
         $pixel = null;
         $text = null;
     } catch (\GmagickException $e) {
         throw new RuntimeException('Draw text operation failed', $e->getCode(), $e);
     }
     return $this;
 }
开发者ID:noorafree,项目名称:makmakan,代码行数:34,代码来源:Drawer.php

示例6: getColorAt

 /**
  * {@inheritdoc}
  */
 public function getColorAt(PointInterface $point)
 {
     if (!$point->in($this->getSize())) {
         throw new RuntimeException(sprintf('Error getting color at point [%s,%s]. The point must be inside the image of size [%s,%s]', $point->getX(), $point->getY(), $this->getSize()->getWidth(), $this->getSize()->getHeight()));
     }
     $pixel = $this->imagick->getImagePixelColor($point->getX(), $point->getY());
     return new Color(array($pixel->getColorValue(\Imagick::COLOR_RED) * 255, $pixel->getColorValue(\Imagick::COLOR_GREEN) * 255, $pixel->getColorValue(\Imagick::COLOR_BLUE) * 255), (int) round($pixel->getColorValue(\Imagick::COLOR_ALPHA) * 100));
 }
开发者ID:rachelleannmorales,项目名称:aboitiz,代码行数:11,代码来源:Image.php

示例7: getColorAt

 /**
  * {@inheritdoc}
  */
 public function getColorAt(PointInterface $point)
 {
     if (!$point->in($this->getSize())) {
         throw new RuntimeException(sprintf('Error getting color at point [%s,%s]. The point must be inside the image of size [%s,%s]', $point->getX(), $point->getY(), $this->getSize()->getWidth(), $this->getSize()->getHeight()));
     }
     $index = imagecolorat($this->resource, $point->getX(), $point->getY());
     $info = imagecolorsforindex($this->resource, $index);
     return new Color(array($info['red'], $info['green'], $info['blue']), (int) round($info['alpha'] / 127 * 100));
 }
开发者ID:jewelhuq,项目名称:fraym,代码行数:12,代码来源:Image.php

示例8: text

 /**
  * (non-PHPdoc)
  * @see Imagine\Draw\DrawerInterface::text()
  */
 public function text($string, AbstractFont $font, PointInterface $position, $angle = 0)
 {
     try {
         $pixel = $this->getColor($font->getColor());
         $text = new \ImagickDraw();
         $text->setFont($font->getFile());
         $text->setFontSize($font->getSize());
         $text->setFillColor($pixel);
         $text->setTextAntialias(true);
         $info = $this->imagick->queryFontMetrics($text, $string);
         $rad = deg2rad($angle);
         $cos = cos($rad);
         $sin = sin($rad);
         $x1 = round(0 * $cos - 0 * $sin);
         $x2 = round($info['textWidth'] * $cos - $info['textHeight'] * $sin);
         $y1 = round(0 * $sin + 0 * $cos);
         $y2 = round($info['textWidth'] * $sin + $info['textHeight'] * $cos);
         $xdiff = 0 - min($x1, $x2);
         $ydiff = 0 - min($y1, $y2);
         $this->imagick->annotateImage($text, $position->getX() + $x1 + $xdiff, $position->getY() + $y2 + $ydiff, $angle, $string);
         $pixel->clear();
         $pixel->destroy();
         $text->clear();
         $text->destroy();
     } catch (\ImagickException $e) {
         throw new RuntimeException('Draw text operation failed', $e->getCode(), $e);
     }
 }
开发者ID:nicodmf,项目名称:Imagine,代码行数:32,代码来源:Drawer.php

示例9: text

 /**
  * {@inheritdoc}
  */
 public function text($string, AbstractFont $font, PointInterface $position, $angle = 0, $width = null)
 {
     try {
         $pixel = $this->getColor($font->getColor());
         $text = new \ImagickDraw();
         $text->setFont($font->getFile());
         /**
          * @see http://www.php.net/manual/en/imagick.queryfontmetrics.php#101027
          *
          * ensure font resolution is the same as GD's hard-coded 96
          */
         if (version_compare(phpversion("imagick"), "3.0.2", ">=")) {
             $text->setResolution(96, 96);
             $text->setFontSize($font->getSize());
         } else {
             $text->setFontSize((int) ($font->getSize() * (96 / 72)));
         }
         $text->setFillColor($pixel);
         $text->setTextAntialias(true);
         $info = $this->imagick->queryFontMetrics($text, $string);
         $rad = deg2rad($angle);
         $cos = cos($rad);
         $sin = sin($rad);
         // round(0 * $cos - 0 * $sin)
         $x1 = 0;
         $x2 = round($info['characterWidth'] * $cos - $info['characterHeight'] * $sin);
         // round(0 * $sin + 0 * $cos)
         $y1 = 0;
         $y2 = round($info['characterWidth'] * $sin + $info['characterHeight'] * $cos);
         $xdiff = 0 - min($x1, $x2);
         $ydiff = 0 - min($y1, $y2);
         if ($width !== null) {
             $string = $this->wrapText($string, $text, $angle, $width);
         }
         $this->imagick->annotateImage($text, $position->getX() + $x1 + $xdiff, $position->getY() + $y2 + $ydiff, $angle, $string);
         $pixel->clear();
         $pixel->destroy();
         $text->clear();
         $text->destroy();
     } catch (\ImagickException $e) {
         throw new RuntimeException('Draw text operation failed', $e->getCode(), $e);
     }
     return $this;
 }
开发者ID:jmstan,项目名称:craft-website,代码行数:47,代码来源:Drawer.php

示例10: testShouldGetCenterCoordinates

 /**
  * @covers Imagine\Image\Point\Center::getX
  * @covers Imagine\Image\Point\Center::getY
  *
  * @dataProvider getSizesAndCoordinates
  *
  * @param Imagine\Image\BoxInterface   $box
  * @param Imagine\Image\PointInterface $expected
  */
 public function testShouldGetCenterCoordinates(BoxInterface $box, PointInterface $expected)
 {
     $point = new Center($box);
     $this->assertEquals($expected->getX(), $point->getX());
     $this->assertEquals($expected->getY(), $point->getY());
 }
开发者ID:BeerMan88,项目名称:yii,代码行数:15,代码来源:CenterTest.php

示例11: getColorAt

 /**
  * (non-PHPdoc)
  * @see Imagine\Image\ImageInterface::getColorAt()
  */
 public function getColorAt(PointInterface $point)
 {
     if (!$point->in($this->getSize())) {
         throw new RuntimeException(sprintf('Error getting color at point [%s,%s]. The point must be inside the image of size [%s,%s]', $point->getX(), $point->getY(), $this->getSize()->getWidth(), $this->getSize()->getHeight()));
     }
     throw new RuntimeException('Not Implemented!');
 }
开发者ID:SerdarSanri,项目名称:laravel-imagine-bundle,代码行数:11,代码来源:Image.php

示例12: translatePoint

 private function translatePoint(PointInterface $point, $x, $y)
 {
     return new Point($x - $point->getX(), $y - $point->getY());
 }
开发者ID:zhangxiaoliu,项目名称:PHPPdf,代码行数:4,代码来源:GraphicsContext.php

示例13: getDistance

 /**
  * {@inheritdoc}
  */
 public function getDistance(PointInterface $position)
 {
     return $position->getY();
 }
开发者ID:noorafree,项目名称:makmakan,代码行数:7,代码来源:Vertical.php

示例14: text

 /**
  * {@inheritdoc}
  */
 public function text($string, AbstractFont $font, PointInterface $position, $angle = 0)
 {
     if (!$this->info['FreeType Support']) {
         throw new RuntimeException('GD is not compiled with FreeType support');
     }
     $angle = -1 * $angle;
     $fontsize = $font->getSize();
     $fontfile = $font->getFile();
     $x = $position->getX();
     $y = $position->getY() + $fontsize;
     if (false === imagealphablending($this->resource, true)) {
         throw new RuntimeException('Font mask operation failed');
     }
     if (false === imagefttext($this->resource, $fontsize, $angle, $x, $y, $this->getColor($font->getColor()), $fontfile, $string)) {
         throw new RuntimeException('Font mask operation failed');
     }
     if (false === imagealphablending($this->resource, false)) {
         throw new RuntimeException('Font mask operation failed');
     }
     return $this;
 }
开发者ID:momoim,项目名称:momo-api,代码行数:24,代码来源:Drawer.php

示例15: getColorAt

 /**
  * {@inheritdoc}
  */
 public function getColorAt(PointInterface $point)
 {
     if (!$point->in($this->getSize())) {
         throw new RuntimeException(sprintf('Error getting color at point [%s,%s]. The point must be inside the image of size [%s,%s]', $point->getX(), $point->getY(), $this->getSize()->getWidth(), $this->getSize()->getHeight()));
     }
     try {
         $pixel = $this->imagick->getImagePixelColor($point->getX(), $point->getY());
     } catch (\ImagickException $e) {
         throw new RuntimeException('Error while getting image pixel color', $e->getCode(), $e);
     }
     return $this->pixelToColor($pixel);
 }
开发者ID:scisahaha,项目名称:generator-craft,代码行数:15,代码来源:Image.php


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