本文整理汇总了PHP中ImagickDraw::push方法的典型用法代码示例。如果您正苦于以下问题:PHP ImagickDraw::push方法的具体用法?PHP ImagickDraw::push怎么用?PHP ImagickDraw::push使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImagickDraw
的用法示例。
在下文中一共展示了ImagickDraw::push方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderKernel
function renderKernel(ImagickKernel $imagickKernel)
{
$matrix = $imagickKernel->getMatrix();
$imageMargin = 20;
$tileSize = 20;
$tileSpace = 4;
$shadowSigma = 4;
$shadowDropX = 20;
$shadowDropY = 0;
$radius = $tileSize / 2 * 0.9;
$rows = count($matrix);
$columns = count($matrix[0]);
$imagickDraw = new \ImagickDraw();
$imagickDraw->setFillColor('#afafaf');
$imagickDraw->setStrokeColor('none');
$imagickDraw->translate($imageMargin, $imageMargin);
$imagickDraw->push();
ksort($matrix);
foreach ($matrix as $row) {
ksort($row);
$imagickDraw->push();
foreach ($row as $cell) {
if ($cell !== false) {
$color = intval(255 * $cell);
$colorString = sprintf("rgb(%f, %f, %f)", $color, $color, $color);
$imagickDraw->setFillColor($colorString);
$imagickDraw->rectangle(0, 0, $tileSize, $tileSize);
}
$imagickDraw->translate($tileSize + $tileSpace, 0);
}
$imagickDraw->pop();
$imagickDraw->translate(0, $tileSize + $tileSpace);
}
$imagickDraw->pop();
$width = $columns * $tileSize + ($columns - 1) * $tileSpace;
$height = $rows * $tileSize + ($rows - 1) * $tileSpace;
$imagickDraw->push();
$imagickDraw->translate($width / 2, $height / 2);
$imagickDraw->setFillColor('rgba(0, 0, 0, 0)');
$imagickDraw->setStrokeColor('white');
$imagickDraw->circle(0, 0, $radius - 1, 0);
$imagickDraw->setStrokeColor('black');
$imagickDraw->circle(0, 0, $radius, 0);
$imagickDraw->pop();
$canvasWidth = $width + 2 * $imageMargin;
$canvasHeight = $height + 2 * $imageMargin;
$kernel = new \Imagick();
$kernel->newPseudoImage($canvasWidth, $canvasHeight, 'canvas:none');
$kernel->setImageFormat('png');
$kernel->drawImage($imagickDraw);
/* create drop shadow on it's own layer */
$canvas = $kernel->clone();
$canvas->setImageBackgroundColor(new \ImagickPixel('rgb(0, 0, 0)'));
$canvas->shadowImage(100, $shadowSigma, $shadowDropX, $shadowDropY);
$canvas->setImagePage($canvasWidth, $canvasHeight, -5, -5);
$canvas->cropImage($canvasWidth, $canvasHeight, 0, 0);
/* composite original text_layer onto shadow_layer */
$canvas->compositeImage($kernel, \Imagick::COMPOSITE_OVER, 0, 0);
$canvas->setImageFormat('png');
return $canvas;
}
示例2: pushPattern
function pushPattern($strokeColor, $fillColor, $backgroundColor)
{
$draw = new \ImagickDraw();
$draw->setStrokeColor($strokeColor);
$draw->setFillColor($fillColor);
$draw->setStrokeWidth(1);
$draw->setStrokeOpacity(1);
$draw->setStrokeColor($strokeColor);
$draw->setFillColor($fillColor);
$draw->setStrokeWidth(1);
$draw->pushPattern("MyFirstPattern", 0, 0, 50, 50);
for ($x = 0; $x < 50; $x += 10) {
for ($y = 0; $y < 50; $y += 5) {
$positionX = $x + $y / 5 % 5;
$draw->rectangle($positionX, $y, $positionX + 5, $y + 5);
}
}
$draw->popPattern();
$draw->setFillOpacity(0);
$draw->rectangle(100, 100, 400, 400);
$draw->setFillOpacity(1);
$draw->setFillOpacity(1);
$draw->push();
$draw->setFillPatternURL('#MyFirstPattern');
$draw->setFillColor('yellow');
$draw->rectangle(100, 100, 400, 400);
$draw->pop();
$imagick = new \Imagick();
$imagick->newImage(500, 500, $backgroundColor);
$imagick->setImageFormat("png");
$imagick->drawImage($draw);
header("Content-Type: image/png");
echo $imagick->getImageBlob();
}