1<?php 2 3/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ 4 5/** 6 * This is a visual test case, testing canvas support for text output. 7 * 8 * PHP versions 4 and 5 9 * 10 * LICENSE: This library is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU Lesser General Public License as published by 12 * the Free Software Foundation; either version 2.1 of the License, or (at your 13 * option) any later version. This library is distributed in the hope that it 14 * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 16 * General Public License for more details. You should have received a copy of 17 * the GNU Lesser General Public License along with this library; if not, write 18 * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 19 * 02111-1307 USA 20 * 21 * @category Images 22 * @package Image_Canvas 23 * @author Jesper Veggerby <pear.nosey@veggerby.dk> 24 * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen 25 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 26 * @version CVS: $Id: lineends.php 262259 2008-07-08 11:45:42Z steinm $ 27 * @link http://pear.php.net/package/Image_Canvas 28 */ 29 30require_once 'Image/Canvas.php'; 31 32$font = array('name' => 'Verdana', 'size' => 10); 33 34$canvas =& Image_Canvas::factory( 35 'png', 36 array('width' => 300, 'height' => 300) 37); 38 39$shapes = array('arrow', 'box', 'diamond', 'arrow2', 'lollipop', 'line'); 40 41$j = 0; 42for ($i = 0; $i < 360; $i += 30) { 43 $x0 = 150; 44 $y0 = 150; 45 if ($j >= count($shapes)) { 46 $j = 0; 47 } 48 $shape1 = $shapes[$j]; $j++; 49 50 if ($j >= count($shapes)) { 51 $j = 0; 52 } 53 $shape2 = $shapes[$j]; $j++; 54 55 $canvas->setLineColor('black'); 56 $canvas->line( 57 array( 58 'x0' => $x0 + cos(deg2rad($i)) * 50, 59 'y0' => $y0 - sin(deg2rad($i)) * 50, 60 'x1' => $x0 + cos(deg2rad($i)) * 100, 61 'y1' => $y0 - sin(deg2rad($i)) * 100, 62 'end0' => $shape1, 63 'size0' => 8, 64 'color0' => 'red', 65 'end1' => $shape2, 66 'color1' => 'green', 67 'size1' => 8 68 ) 69 ); 70 $canvas->setFont($font); 71 $canvas->addText( 72 array( 73 'x' => $x0 + cos(deg2rad($i)) * 125, 74 'y' => $y0 - sin(deg2rad($i)) * 125, 75 'text' => $i, 76 'alignment' => array( 77 'horizontal' => ((($i > 90) && ($i < 270)) ? 'right' : ((($i == 90) || ($i == 270)) ? 'center' : 'left')), 78 'vertical' => (($i < 180) ? 'bottom' : ((($i == 0) || ($i == 180)) ? 'center' : 'top')), 79 ) 80 ) 81 ); 82} 83$canvas->show(); 84 85?> 86