1--TEST--
2Test Tutorial, psychedelicFontGif
3--SKIPIF--
4<?php
5$imageMagickRequiredVersion=0x675;
6require_once(dirname(__FILE__) . '/skipif.inc');
7?>
8--FILE--
9<?php
10
11require_once(dirname(__FILE__) . '/functions.inc');
12
13function psychedelicFontGif($name = 'Danack') {
14
15    set_time_limit(3000);
16
17    $aniGif = new \Imagick();
18    $aniGif->setFormat("gif");
19
20    $maxFrames = 11;
21    $scale = 0.25;
22
23    for ($frame = 0; $frame < $maxFrames; $frame++) {
24
25        $draw = new \ImagickDraw();
26        setFontForImagickDraw($draw);
27
28        $draw->setStrokeOpacity(1);
29        $draw->setfontsize(150 * $scale);
30
31        for ($strokeWidth = 25; $strokeWidth > 0; $strokeWidth--) {
32            $hue = intval(fmod(($frame * 360 / $maxFrames) + 170 + $strokeWidth * 360 / 25, 360));
33            $color = "hsl($hue, 255, 128)";
34            $draw->setStrokeColor($color);
35            $draw->setFillColor($color);
36            $draw->setStrokeWidth($strokeWidth * 3 * $scale);
37            $draw->annotation((int)(60 * $scale), (int)(165 * $scale), $name);
38        }
39
40        $draw->setStrokeColor('none');
41        $draw->setFillColor('black');
42        $draw->setStrokeWidth(0);
43        $draw->annotation(60 * $scale, 165 * $scale, $name);
44
45        //Create an image object which the draw commands can be rendered into
46        $imagick = new \Imagick();
47        $imagick->newImage((int)(650 * $scale), (int)(230 * $scale), "#eee");
48        $imagick->setImageFormat("png");
49
50        //Render the draw commands in the ImagickDraw object
51        //into the image.
52        $imagick->drawImage($draw);
53
54        $imagick->setImageDelay(5);
55        $aniGif->addImage($imagick);
56
57        $imagick->destroy();
58    }
59
60    $aniGif->setImageIterations(0); //loop forever
61    $aniGif->deconstructImages();
62
63    $bytes = $aniGif->getImagesBlob();
64    if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
65}
66
67psychedelicFontGif($name = 'Danack') ;
68echo "Ok";
69?>
70--EXPECTF--
71Ok