One could consider ImagickDraw object as an "operation fifo". All operations are executed in order when drawImage method is called. You could for example call rotate and it would affect all drawing operations executed after it on the specific object.
Here's a primitive example to get you started with drawing:
Resulting image:
<?php
/* Create an empty canvas with white background */
$im = new Imagick();
$im->newImage( 400, 400, new ImagickPixel( "white" ) );
/* Now lets draw some stuff */
$draw = new ImagickDraw();
/* Draw a green ellipse with red border */
$draw->setStrokeColor( new ImagickPixel( "red" ) );
$draw->setStrokeWidth( 2 );
$draw->setFillColor( new ImagickPixel( "green" ) );
$draw->ellipse( 200, 100, 50, 50, 0, 360 );
/* Render the ellipse on the canvas */
$im->drawImage( $draw );
/* Png format */
$im->setImageFormat( "png" );
header( "Content-Type: image/png" );
echo $im;
?>
|