note 103356 added to function.imagickdraw-pushclippath
| From: | bogdan at moongate dot ro | Date: | Sat, 09 Apr 2011 00:49:49 +0000 |
| Subject: | note 103356 added to function.imagickdraw-pushclippath | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-178652@lists.php.net to get a copy of this message | ||
Here's an interactive example for your enjoyment, featuring two intersecting discs. My version
doesn't antialias the clipping path; I suppose YMMV.
<?php
// Simple clip path example
// Bogdan Stancescu, http://www.moongate.eu/
$showClipping=0; // Try setting this to 0!
$showDrawing=0; // Try setting this to 0!
// Don't edit below this line (at least until you understand the example)
$showBoth=$showClipping && $showDrawing;
$showAny=$showClipping || $showDrawing;
$image=new Imagick(); // Create image
// Image size
$width=151;
$height=101;
$image->newImage($width, $height, new ImagickPixel('lightgray')); // some visible
background
$draw=new ImagickDraw(); // Create draw object
if ($showBoth)
$draw->pushClipPath('circle_left'); // Start clipping path
if ($showClipping) {
$draw->setFillColor('red'); // The color doesn't matter if we clip
$draw->circle(50,50,50,0); // A circle that occupies 100x100px on the left
}
if ($showBoth) {
$draw->popClipPath(); // Finish clipping path
$draw->setClipPath('circle_left'); // Use the clipping path above
}
if ($showDrawing) {
$draw->setFillColor('navy'); // This is the actual drawing color
$draw->circle(100,50,100,0); // A circle that's circumscribed by the right half
}
if ($showAny)
$image->drawImage($draw); // Render $draw unto $image
$image->setImageFormat('png'); // Tell ImageMagick how to render this
header("Content-Type: image/png"); // Tell the browser how to render this
----
Server IP: 69.147.83.197
Probable Submitter: 81.181.249.131
----
Manual Page -- http://www.php.net/manual/en/function.imagickdraw-pushclippath.php
Edit -- https://master.php.net/note/edit/103356
Del: integrated -- https://master.php.net/note/delete/103356/integrated
Del: useless -- https://master.php.net/note/delete/103356/useless
Del: bad code -- https://master.php.net/note/delete/103356/bad+code
Del: spam -- https://master.php.net/note/delete/103356/spam
Del: non-english -- https://master.php.net/note/delete/103356/non-english
Del: in docs -- https://master.php.net/note/delete/103356/in+docs
Del: other reasons-- https://master.php.net/note/delete/103356
Reject -- https://master.php.net/note/reject/103356
Search -- https://master.php.net/manage/user-notes.php