Ejemplo n.º 1
0
 /**
  * 画一条线
  * @param int $sx     起始坐标x
  * @param int $sy     起始坐标y
  * @param int $ex     终止坐标y
  * @param int $ey     终止坐标y
  * @param int $border 线条宽度
  */
 public function drawLine($sx, $sy, $ex, $ey, $property = array())
 {
     $width = $this->getWidth();
     $height = $this->getHeight();
     $color = NewPixelWand(isset($property['color']) ? $property['color'] : 'black');
     $fillColor = NewPixelWand(isset($property['fillColor']) ? $property['fillColor'] : 'none');
     $backgroundColor = NewPixelWand(isset($property['fillColor']) ? $property['backgroundColor'] : 'none');
     $picWand = NewMagickWand();
     MagickNewImage($picWand, $width, $height, $backgroundColor);
     $drawWand = NewDrawingWand();
     DrawSetFillColor($drawWand, $fillColor);
     DrawSetStrokeWidth($drawWand, isset($property['borderWidth']) ? $property['borderWidth'] : 1);
     DrawSetStrokeColor($drawWand, $color);
     if (isset($property['stroke'])) {
         DrawSetStrokeDashArray($drawWand, $property['stroke']);
     }
     DrawLine($drawWand, $sx, $sy, $ex, $ey);
     MagickDrawImage($picWand, $drawWand);
     return MagickCompositeImage(self::$resource, $picWand, MW_OverCompositeOp, $x, $y);
 }
Ejemplo n.º 2
0
 public function setFont($para = array())
 {
     $textColor = "#000000";
     $textWeight = 120;
     $textSize = 12;
     $textFont = "simsun.ttc";
     $textAlpha = 1;
     $textAlign = 1;
     $textStrokeColor = "#FFFFFF";
     $textStrokeWidth = 1;
     $textStrokeOpacity = 0.2;
     if (count($para) > 1) {
         extract($para, EXTR_OVERWRITE);
     }
     $imgFont = NewDrawingWand();
     $fontColor = $this->getColor($textColor);
     DrawSetTextEncoding($imgFont, "UTF-8");
     DrawSetFont($imgFont, $textFont);
     DrawSetFontWeight($imgFont, $textWeight);
     DrawSetFillColor($imgFont, $fontColor);
     DrawSetFontSize($imgFont, $textSize);
     DrawSetGravity($imgFont, $textAlign);
     DrawSetFillAlpha($imgFont, $textAlpha);
     if ($textStrokeWidth > 0 && $textStrokeOpacity > 0) {
         $strokeColor = $this->getColor($textStrokeColor);
         DrawSetStrokeColor($imgFont, $strokeColor);
         DrawSetStrokeWidth($imgFont, $textStrokeWidth);
         DrawSetStrokeOpacity($imgFont, $textStrokeOpacity);
     }
     if (WandHasException($imgFont)) {
         $this->Error($imgFont);
     }
     $this->destoryWand($fontColor);
     return $imgFont;
 }