1--TEST-- 2Test ImagickDraw, affine 3--SKIPIF-- 4<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> 5--FILE-- 6<?php 7 8$backgroundColor = 'rgb(225, 225, 225)'; 9$strokeColor = 'rgb(0, 0, 0)'; 10$fillColor = 'DodgerBlue2'; 11 12function affine($strokeColor, $fillColor, $backgroundColor) { 13 14 $draw = new \ImagickDraw(); 15 16 $draw->setStrokeWidth(1); 17 $draw->setStrokeOpacity(1); 18 $draw->setStrokeColor($strokeColor); 19 $draw->setFillColor($fillColor); 20 21 $draw->setStrokeWidth(2); 22 23 $PI = 3.141592653589794; 24 $angle = 60 * $PI / 360; 25 26 //Scale the drawing co-ordinates. 27 $affineScale = array("sx" => 1.75, "sy" => 1.75, "rx" => 0, "ry" => 0, "tx" => 0, "ty" => 0); 28 29 //Shear the drawing co-ordinates. 30 $affineShear = array("sx" => 1, "sy" => 1, "rx" => sin($angle), "ry" => -sin($angle), "tx" => 0, "ty" => 0); 31 32 //Rotate the drawing co-ordinates. The shear affine matrix 33 //produces incorrectly scaled drawings. 34 $affineRotate = array("sx" => cos($angle), "sy" => cos($angle), "rx" => sin($angle), "ry" => -sin($angle), "tx" => 0, "ty" => 0,); 35 36 //Translate (offset) the drawing 37 $affineTranslate = array("sx" => 1, "sy" => 1, "rx" => 0, "ry" => 0, "tx" => 30, "ty" => 30); 38 39 //The identiy affine matrix 40 $affineIdentity = array("sx" => 1, "sy" => 1, "rx" => 0, "ry" => 0, "tx" => 0, "ty" => 0); 41 42 $examples = array($affineScale, $affineShear, $affineRotate, $affineTranslate, $affineIdentity,); 43 44 $count = 0; 45 46 foreach ($examples as $example) { 47 $draw->push(); 48 $draw->translate(($count % 2) * 250, intval($count / 2) * 250); 49 $draw->translate(100, 100); 50 $draw->affine($example); 51 $draw->rectangle(-50, -50, 50, 50); 52 $draw->pop(); 53 $count++; 54 } 55 56 //Create an image object which the draw commands can be rendered into 57 $image = new \Imagick(); 58 $image->newImage(500, 750, $backgroundColor); 59 $image->setImageFormat("png"); 60 61 //Render the draw commands in the ImagickDraw object 62 //into the image. 63 $image->drawImage($draw); 64 65 //Send the image to the browser 66 $bytes = $image->getImageBlob(); 67 if (strlen($bytes) <= 0) { echo "Failed to generate image.";} 68} 69 70affine($strokeColor, $fillColor, $backgroundColor) ; 71echo "Ok"; 72?> 73--EXPECTF-- 74Ok