ImagickDraw, a quick introduction to drawing : Image Create : Graphics Image PHP Source Code


PHP Source Code » Graphics Image » Image Create »

 

ImagickDraw, a quick introduction to drawing


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:

Result

<?php
/* Create an empty canvas with white background */
$im = new Imagick();
$im->newImage400400, 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);
$draw->setFillColor( new ImagickPixel"green" ) );
$draw->ellipse20010050500360 );
/* Render the ellipse on the canvas */
$im->drawImage$draw );
/* Png format */
$im->setImageFormat"png" );
header"Content-Type: image/png" );
echo 
$im;
?>




HTML code for linking to this page:

Follow Navioo On Twitter

PHP Source Code

 Navioo Graphics Image
» Image Create