當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ImagickDraw::bezier方法代碼示例

本文整理匯總了PHP中ImagickDraw::bezier方法的典型用法代碼示例。如果您正苦於以下問題:PHP ImagickDraw::bezier方法的具體用法?PHP ImagickDraw::bezier怎麽用?PHP ImagickDraw::bezier使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ImagickDraw的用法示例。


在下文中一共展示了ImagickDraw::bezier方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: draw

 /**
  * @param ImageInterface $image
  * @return Image
  */
 public function draw($image)
 {
     // Localize vars
     $width = $image->getWidth();
     $height = $image->getHeight();
     $imagick = $image->getCore();
     $draw = new \ImagickDraw();
     $strokeColor = new \ImagickPixel($this->getColor()->getHexString());
     $fillColor = new \ImagickPixel('rgba(0,0,0,0)');
     $draw->setStrokeOpacity(1);
     $draw->setStrokeColor($strokeColor);
     $draw->setFillColor($fillColor);
     $points = array(array('x' => $this->point1[0], 'y' => $this->point1[1]), array('x' => $this->control1[0], 'y' => $this->control1[1]), array('x' => $this->control2[0], 'y' => $this->control2[1]), array('x' => $this->point2[0], 'y' => $this->point2[1]));
     $draw->bezier($points);
     // Render the draw commands in the ImagickDraw object
     $imagick->drawImage($draw);
     $type = $image->getType();
     $file = $image->getImageFile();
     return new Image($imagick, $file, $width, $height, $type);
     // Create new image with updated core
 }
開發者ID:kosinix,項目名稱:grafika,代碼行數:25,代碼來源:CubicBezier.php

示例2: bezier

function bezier($strokeColor, $fillColor, $backgroundColor)
{
    $draw = new \ImagickDraw();
    $strokeColor = new \ImagickPixel($strokeColor);
    $fillColor = new \ImagickPixel($fillColor);
    $draw->setStrokeOpacity(1);
    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);
    $draw->setStrokeWidth(2);
    $smoothPointsSet = [[['x' => 10.0 * 5, 'y' => 10.0 * 5], ['x' => 30.0 * 5, 'y' => 90.0 * 5], ['x' => 25.0 * 5, 'y' => 10.0 * 5], ['x' => 50.0 * 5, 'y' => 50.0 * 5]], [['x' => 50.0 * 5, 'y' => 50.0 * 5], ['x' => 75.0 * 5, 'y' => 90.0 * 5], ['x' => 70.0 * 5, 'y' => 10.0 * 5], ['x' => 90.0 * 5, 'y' => 40.0 * 5]]];
    foreach ($smoothPointsSet as $points) {
        $draw->bezier($points);
    }
    $disjointPoints = [[['x' => 10 * 5, 'y' => 10 * 5], ['x' => 30 * 5, 'y' => 90 * 5], ['x' => 25 * 5, 'y' => 10 * 5], ['x' => 50 * 5, 'y' => 50 * 5]], [['x' => 50 * 5, 'y' => 50 * 5], ['x' => 80 * 5, 'y' => 50 * 5], ['x' => 70 * 5, 'y' => 10 * 5], ['x' => 90 * 5, 'y' => 40 * 5]]];
    $draw->translate(0, 200);
    foreach ($disjointPoints as $points) {
        $draw->bezier($points);
    }
    //Create an image object which the draw commands can be rendered into
    $imagick = new \Imagick();
    $imagick->newImage(500, 500, $backgroundColor);
    $imagick->setImageFormat("png");
    //Render the draw commands in the ImagickDraw object
    //into the image.
    $imagick->drawImage($draw);
    //Send the image to the browser
    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}
開發者ID:sdmmember,項目名稱:Imagick-demos,代碼行數:29,代碼來源:functions.php


注:本文中的ImagickDraw::bezier方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。