函式名:ImagickDraw::pathLineToHorizontalAbsolute()
適用版本:Imagick 3.0.0 及以上版本
用法:這個函式用於在imagick繪圖物件中新增水平直線路徑段。路徑段的起點是當前路徑的當前點,終點的x座標由引數指定,y座標保持不變。
語法:public ImagickDraw::pathLineToHorizontalAbsolute ( float $x )
引數:
- $x: 指定終點的x座標,必須是浮點數型別。
返回值:該函式沒有返回值。
示例:
<?php
// 建立ImagickDraw物件
$draw = new ImagickDraw();
// 設定路徑的起點
$draw->pathStart();
// 新增水平直線路徑段
$draw->pathLineToHorizontalAbsolute(200);
// 設定路徑的終點
$draw->pathFinish();
// 建立Imagick物件
$image = new Imagick();
$image->newImage(400, 200, 'white');
$image->setImageFormat("png");
// 應用繪製物件到Imagick物件
$image->drawImage($draw);
// 輸出影象
header("Content-Type: image/png");
echo $image;
?>
在上面的示例中,我們首先建立了一個ImagickDraw物件,並呼叫pathStart()
方法來設定路徑的起點。然後,使用pathLineToHorizontalAbsolute()
方法新增了一個水平直線路徑段,終點的x座標是200。最後,呼叫pathFinish()
方法設定路徑的終點。然後,我們建立了一個Imagick物件,並使用drawImage()
方法將繪製物件應用到Imagick物件上。最後,將影象輸出到瀏覽器。