这是一个供您欣赏的交互式示例,它包含两个相交的圆盘。我的版本没有对剪切路径进行抗锯齿化;我想 YMMV。
<?php
$showClipping=1; $showDrawing=1; $showBoth=$showClipping && $showDrawing;
$showAny=$showClipping || $showDrawing;
$image=new Imagick(); $width=151;
$height=101;
$image->newImage($width, $height, new ImagickPixel('lightgray')); $draw=new ImagickDraw(); if ($showBoth)
$draw->pushClipPath('circle_left'); if ($showClipping) {
$draw->setFillColor('red'); $draw->circle(50,50,50,0); }
if ($showBoth) {
$draw->popClipPath(); $draw->setClipPath('circle_left'); }
if ($showDrawing) {
$draw->setFillColor('navy'); $draw->circle(100,50,100,0); }
if ($showAny)
$image->drawImage($draw); $image->setImageFormat('png'); header("Content-Type: image/png"); echo $image; ?>