Initial Commit of AgileBill Open Source
This commit is contained in:
12
includes/pear/Image/tests/README
Normal file
12
includes/pear/Image/tests/README
Normal file
@@ -0,0 +1,12 @@
|
||||
-------------------------------------------------------------------------------
|
||||
These tests are not unit or regression tests.
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
This is because it is not possible to compare output from Image_Driver with an
|
||||
expected "value" (i.e. is this graph equal to this graph). The problem is similar
|
||||
to testing user interfaces.
|
||||
|
||||
The provided test "cases" are visual test suites that renders Image_Driver output,
|
||||
the output should then be viewed and checked for inconsistencies on a visual base,
|
||||
fx. this line chart does not show as _expected_, this gradient fill does not fill
|
||||
to the edges of the area, the text does not align properly, etc.
|
87
includes/pear/Image/tests/axis/category.php
Normal file
87
includes/pear/Image/tests/axis/category.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This is a visual test case, testing the category axis.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
* option) any later version. This library is distributed in the hope that it
|
||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||
* General Public License for more details. You should have received a copy of
|
||||
* the GNU Lesser General Public License along with this library; if not, write
|
||||
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307 USA
|
||||
*
|
||||
* @category Images
|
||||
* @package Image_Graph
|
||||
* @subpackage Tests
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version CVS: $Id: category.php,v 1.4 2005/08/03 21:21:58 nosey Exp $
|
||||
* @link http://pear.php.net/package/Image_Graph
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(400, 300));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('ttf_font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(7);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
// create the plotarea
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Testing Category Axis', 10)),
|
||||
$Plotarea = Image_Graph::factory('plotarea', array('Image_Graph_Axis_Category', 'Image_Graph_Axis_Category')),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
$DS =& Image_Graph::factory('dataset');
|
||||
$DS->addPoint('Germany', 'England');
|
||||
$DS->addPoint('Denmark', 'France');
|
||||
$DS->addPoint('Sweden', 'Denmark');
|
||||
$DS->addPoint('England', 'France');
|
||||
$DS->addPoint('Norway', 'Finland');
|
||||
$DS->addPoint('Denmark', 'Finland');
|
||||
$DS->addPoint('Iceland', 'Germany');
|
||||
$DS->addPoint('Norway', 'France');
|
||||
|
||||
$DS2 =& Image_Graph::factory('dataset');
|
||||
$DS2->addPoint('Sweden', 'France');
|
||||
$DS2->addPoint('Austria', 'Germany');
|
||||
$DS2->addPoint('Norway', 'Holland');
|
||||
$DS2->addPoint('Denmark', 'Germany');
|
||||
$DS2->addPoint('Sweden', 'Holland');
|
||||
$DS2->addPoint('Iceland', 'Denmark');
|
||||
|
||||
/* Expect x-axis to be ordered:
|
||||
* Germany, Denmark, Sweden, England, Austria, Norway, Iceland
|
||||
*
|
||||
* Expect y-axis to be ordered:
|
||||
* England, France, Denmark, Finland, Holland, Germany
|
||||
*
|
||||
* Special points are X = Austria and Y = Holland, which are expected to be
|
||||
* "placed" before Norway and Germany respective (since that is the point at
|
||||
* which they exist "before" in the dataset on their first occurence)
|
||||
*/
|
||||
|
||||
$Plot =& $Plotarea->addNew('line', $DS);
|
||||
$Plot->setLineColor('red');
|
||||
|
||||
$Plot2 =& $Plotarea->addNew('line', $DS2);
|
||||
$Plot2->setLineColor('blue');
|
||||
|
||||
$Graph->done();
|
||||
?>
|
82
includes/pear/Image/tests/axis/intersection.php
Normal file
82
includes/pear/Image/tests/axis/intersection.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This is a visual test case, testing the setting of the intersection of
|
||||
* a x-axis on a y-axis, and the intersection of a y-axis on the x- axis.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
* option) any later version. This library is distributed in the hope that it
|
||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||
* General Public License for more details. You should have received a copy of
|
||||
* the GNU Lesser General Public License along with this library; if not, write
|
||||
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307 USA
|
||||
*
|
||||
* @category Images
|
||||
* @package Image_Graph
|
||||
* @subpackage Tests
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version CVS: $Id: intersection.php,v 1.5 2005/08/03 21:21:58 nosey Exp $
|
||||
* @link http://pear.php.net/package/Image_Graph
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(600, 400));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('ttf_font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(7);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
// create the plotarea
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Testing Axis Intersection', 10)),
|
||||
$Matrix = Image_Graph::factory('Image_Graph_Layout_Matrix', array(3, 3)),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
$DS[0] =& Image_Graph::factory('dataset', array(array('0' => 1, '1' => 2, '2' => 0)));
|
||||
$DS[1] =& Image_Graph::factory('dataset', array(array('0' => -1, '1' => 2, '2' => 2)));
|
||||
$DS[2] =& Image_Graph::factory('dataset', array(array('0' => 1, '1' => 3, '2' => 2)));
|
||||
|
||||
for ($row = 0; $row < 3; $row++) {
|
||||
for ($col = 0; $col < 3; $col++) {
|
||||
if (isset($DS[$col])) {
|
||||
$Plotarea =& $Matrix->getEntry($row, $col);
|
||||
$AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
|
||||
$AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
|
||||
if ($row >= 1) {
|
||||
$AxisY->setAxisIntersection(1);
|
||||
$AxisY->setTitle("Intersect\n at x = 1");
|
||||
} else {
|
||||
$AxisY->setTitle("Intersect\nat x = min");
|
||||
}
|
||||
if ($row >= 2) {
|
||||
$AxisX->setAxisIntersection(1);
|
||||
$AxisX->setTitle('Intersect at y = 1');
|
||||
} else {
|
||||
$AxisX->setTitle('Intersect at y = 0');
|
||||
}
|
||||
$Plot =& $Plotarea->addNew('line', $DS[$col]);
|
||||
$Plot->setLineColor('red');
|
||||
$Plotarea->setBackgroundColor('blue@0.2');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$Graph->done();
|
||||
?>
|
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This is a visual test case, testing the setting of the intersection of
|
||||
* a x-axis on a secondary y-axis, and the intersection of a secondary-y-
|
||||
* axis on the x-axis.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
* option) any later version. This library is distributed in the hope that it
|
||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||
* General Public License for more details. You should have received a copy of
|
||||
* the GNU Lesser General Public License along with this library; if not, write
|
||||
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307 USA
|
||||
*
|
||||
* @category Images
|
||||
* @package Image_Graph
|
||||
* @subpackage Tests
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version CVS: $Id: intersection_secondary_axis.php,v 1.5 2005/08/03 21:21:58 nosey Exp $
|
||||
* @link http://pear.php.net/package/Image_Graph
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(800, 600));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('ttf_font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(7);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
// create the plotarea
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Testing Secondary Axis Intersection', 10)),
|
||||
$Matrix = Image_Graph::factory('Image_Graph_Layout_Matrix', array(3, 3)),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
$DS[0] =& Image_Graph::factory('dataset', array(array('0' => 1, '1' => 2, '2' => 0)));
|
||||
$DS[1] =& Image_Graph::factory('dataset', array(array('0' => -1, '1' => 2, '2' => 1)));
|
||||
$DS[2] =& Image_Graph::factory('dataset', array(array('0' => 1, '1' => 3, '2' => 2)));
|
||||
$DS2[0] =& Image_Graph::factory('dataset', array(array('0' => -1, '1' => 2, '2' => 1)));
|
||||
$DS2[1] =& Image_Graph::factory('dataset', array(array('0' => 1, '1' => 3, '2' => 2)));
|
||||
$DS2[2] =& Image_Graph::factory('dataset', array(array('0' => 1, '1' => 2, '2' => 1)));
|
||||
|
||||
for ($row = 0; $row < 3; $row++) {
|
||||
for ($col = 0; $col < 3; $col++) {
|
||||
if (isset($DS[$col])) {
|
||||
$Plotarea =& $Matrix->getEntry($row, $col);
|
||||
$AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
|
||||
$AxisY->setLineColor('silver');
|
||||
|
||||
$AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
|
||||
$AxisX->setAxisIntersection(($row < 1 ? 0 : 1), IMAGE_GRAPH_AXIS_Y_SECONDARY);
|
||||
$AxisX->setTitle("Intersect at\ny2=" . ($row < 1 ? '0' : '1'));
|
||||
|
||||
$Plot =& $Plotarea->addNew('line', $DS2[$col]);
|
||||
$Plot->setLineColor('red@0.1');
|
||||
$Plot2 =& $Plotarea->addNew('line', $DS[$col], IMAGE_GRAPH_AXIS_Y_SECONDARY);
|
||||
$Plot2->setLineColor('green');
|
||||
$Plotarea->setBackgroundColor('blue@0.2');
|
||||
|
||||
$AxisYsec =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y_SECONDARY);
|
||||
if ($row > 1) {
|
||||
$AxisYsec->setAxisIntersection(1);
|
||||
$AxisYsec->setTitle("Intersect\nat x=1");
|
||||
} else {
|
||||
$AxisYsec->setTitle("Intersect\nat x=max");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$Graph->done();
|
||||
?>
|
89
includes/pear/Image/tests/axis/inversion.php
Normal file
89
includes/pear/Image/tests/axis/inversion.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This is a visual test case, testing axis inversion.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
* option) any later version. This library is distributed in the hope that it
|
||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||
* General Public License for more details. You should have received a copy of
|
||||
* the GNU Lesser General Public License along with this library; if not, write
|
||||
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307 USA
|
||||
*
|
||||
* @category Images
|
||||
* @package Image_Graph
|
||||
* @subpackage Tests
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version CVS: $Id: inversion.php,v 1.4 2005/08/03 21:21:58 nosey Exp $
|
||||
* @link http://pear.php.net/package/Image_Graph
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(600, 600));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('ttf_font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(7);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
// create the plotarea
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Testing Axis Inversion', 10)),
|
||||
$Matrix = Image_Graph::factory('Image_Graph_Layout_Matrix', array(4, 3)),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
$DS[0] =& Image_Graph::factory('dataset', array(array('0' => 1, '1' => 2, '2' => 0)));
|
||||
$DS[1] =& Image_Graph::factory('dataset', array(array('0' => -1, '1' => 2, '2' => 2)));
|
||||
$DS[2] =& Image_Graph::factory('dataset', array(array('0' => 1, '1' => 3, '2' => 2)));
|
||||
|
||||
for ($row = 0; $row < 4; $row++) {
|
||||
for ($col = 0; $col < 3; $col++) {
|
||||
if (isset($DS[$col])) {
|
||||
$Plotarea =& $Matrix->getEntry($row, $col);
|
||||
$AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
|
||||
$AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
|
||||
|
||||
if ($row >= 1) {
|
||||
$AxisY->setInverted(true);
|
||||
$AxisY->setTitle('Inverted Y', 'vertical');
|
||||
} else {
|
||||
$AxisY->setTitle('Normal Y', 'vertical');
|
||||
}
|
||||
|
||||
if ($row >= 2) {
|
||||
$AxisX->setInverted(true);
|
||||
$AxisX->setTitle('Inverted X');
|
||||
} else {
|
||||
$AxisX->setTitle('Normal X');
|
||||
}
|
||||
|
||||
if ($row >= 3) {
|
||||
$AxisX->setAxisIntersection('max');
|
||||
$AxisX->setTitle('Inverted X at Bottom (set X intersection)');
|
||||
}
|
||||
|
||||
$Plot =& $Plotarea->addNew('line', $DS[$col]);
|
||||
$Plot->setLineColor('red');
|
||||
$Plotarea->setBackgroundColor('blue@0.2');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$Graph->done();
|
||||
?>
|
99
includes/pear/Image/tests/axis/labelinterval.php
Normal file
99
includes/pear/Image/tests/axis/labelinterval.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This is a visual test case, testing setting of label interval's.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
* option) any later version. This library is distributed in the hope that it
|
||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||
* General Public License for more details. You should have received a copy of
|
||||
* the GNU Lesser General Public License along with this library; if not, write
|
||||
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307 USA
|
||||
*
|
||||
* @category Images
|
||||
* @package Image_Graph
|
||||
* @subpackage Tests
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version CVS: $Id: labelinterval.php,v 1.4 2005/08/03 21:21:58 nosey Exp $
|
||||
* @link http://pear.php.net/package/Image_Graph
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(800, 600));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('ttf_font', 'Verdana');
|
||||
// set the font size to 7 pixels
|
||||
$Font->setSize(7);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
// create the plotarea
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Testing Changing Axis Label Intervals (Bar Charts also test label distance)', 10)),
|
||||
$Matrix = Image_Graph::factory('Image_Graph_Layout_Matrix', array(4, 4)),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
$DS[0] =& Image_Graph::factory('dataset', array(array(0 => 1, 1 => 2, 2 => 0, 3 => 1, 4 => 4)));
|
||||
$DS[1] =& Image_Graph::factory('dataset', array(array('A' => 1, 'B' => 2, 'C' => 0, 'D' => 1, 'E' => 4)));
|
||||
|
||||
$DS[2] =& Image_Graph::factory('dataset', array(array(0 => 1, 1 => 2, 2 => -2, 3 => 1, 4 => 4)));
|
||||
$DS[3] =& Image_Graph::factory('dataset', array(array('A' => 1, 'B' => 2, 'C' => -2, 'D' => 1, 'E' => 4)));
|
||||
|
||||
for ($row = 0; $row < 4; $row++) {
|
||||
for ($col = 0; $col < 4; $col++) {
|
||||
if (isset($DS[$col])) {
|
||||
$Plotarea =& $Matrix->getEntry($row, $col);
|
||||
$AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
|
||||
$AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
|
||||
|
||||
if ($row > 2) {
|
||||
$AxisX->setLabelInterval(3);
|
||||
$AxisX->setTitle('"Odd" interval');
|
||||
} elseif ($row > 0) {
|
||||
$AxisX->setLabelInterval(2);
|
||||
$AxisX->setTitle('Changed interval');
|
||||
} else {
|
||||
$AxisX->setTitle('Default interval');
|
||||
}
|
||||
|
||||
if ($row > 2) {
|
||||
$AxisY->setLabelInterval(0.25);
|
||||
$AxisY->setTitle('Small interval', 'vertical');
|
||||
} elseif ($row > 1) {
|
||||
$AxisY->setLabelInterval(2);
|
||||
$AxisY->setTitle('Changed interval', 'vertical');
|
||||
} else {
|
||||
$AxisY->setTitle('Default interval', 'vertical');
|
||||
}
|
||||
|
||||
if ($col > 1) {
|
||||
$Plot =& $Plotarea->addNew('bar', $DS[$col]);
|
||||
$Plot->setLineColor('gray');
|
||||
$Plot->setFillColor('blue@0.2');
|
||||
} else {
|
||||
$Plot =& $Plotarea->addNew('line', $DS[$col]);
|
||||
$Plot->setLineColor('red');
|
||||
}
|
||||
|
||||
$Plotarea->setBackgroundColor('blue@0.2');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$Graph->done();
|
||||
?>
|
84
includes/pear/Image/tests/axis/logarithmic.php
Normal file
84
includes/pear/Image/tests/axis/logarithmic.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This is a visual test case, testing the logarithmic axis.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
* option) any later version. This library is distributed in the hope that it
|
||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||
* General Public License for more details. You should have received a copy of
|
||||
* the GNU Lesser General Public License along with this library; if not, write
|
||||
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307 USA
|
||||
*
|
||||
* @category Images
|
||||
* @package Image_Graph
|
||||
* @subpackage Tests
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version CVS: $Id: logarithmic.php,v 1.4 2005/08/03 21:21:58 nosey Exp $
|
||||
* @link http://pear.php.net/package/Image_Graph
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(600, 400));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('ttf_font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(7);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
// create the plotarea
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Testing Logarihtmic Axis', 10)),
|
||||
$Matrix = Image_Graph::factory('Image_Graph_Layout_Matrix', array(2, 2, false)),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
$Matrix->setEntry(0, 0, Image_Graph::factory('plotarea', array('axis', 'axis')));
|
||||
$Matrix->setEntry(0, 1, Image_Graph::factory('plotarea', array('axis', 'axis_log')));
|
||||
$Matrix->setEntry(1, 0, Image_Graph::factory('plotarea', array('axis_log', 'axis')));
|
||||
$Matrix->setEntry(1, 1, Image_Graph::factory('plotarea', array('axis_log', 'axis_log')));
|
||||
|
||||
function sqr($x) { return $x * $x; }
|
||||
|
||||
$DS =& Image_Graph::factory('function', array(1, 10, 'sqr', 9));
|
||||
|
||||
for ($row = 0; $row < 2; $row++) {
|
||||
for ($col = 0; $col < 2; $col++) {
|
||||
$Plotarea =& $Matrix->getEntry($row, $col);
|
||||
|
||||
$AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
|
||||
if (is_a($AxisX, 'Image_Graph_Axis_Logarithmic')) {
|
||||
$AxisX->setTitle('Logarithmic');
|
||||
} else {
|
||||
$AxisX->setTitle('Normal');
|
||||
}
|
||||
|
||||
$AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
|
||||
if (is_a($AxisY, 'Image_Graph_Axis_Logarithmic')) {
|
||||
$AxisY->setTitle('Logarithmic', 'vertical');
|
||||
} else {
|
||||
$AxisY->setTitle('Normal', 'vertical');
|
||||
}
|
||||
|
||||
$Plot =& $Plotarea->addNew('line', $DS);
|
||||
$Plot->setLineColor('red');
|
||||
}
|
||||
}
|
||||
|
||||
$Graph->done();
|
||||
?>
|
326
includes/pear/Image/tests/canvas_body.php
Normal file
326
includes/pear/Image/tests/canvas_body.php
Normal file
@@ -0,0 +1,326 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This is not a test in itself, since it depends on another source part to
|
||||
* create the canvas. It is merely a common canvas test include, to avoid
|
||||
* redundant code in every canvas test.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
* option) any later version. This library is distributed in the hope that it
|
||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||
* General Public License for more details. You should have received a copy of
|
||||
* the GNU Lesser General Public License along with this library; if not, write
|
||||
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307 USA
|
||||
*
|
||||
* @category Images
|
||||
* @package Image_Canvas
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version CVS: $Id: canvas_body.php,v 1.4 2005/08/16 21:27:58 nosey Exp $
|
||||
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
|
||||
*/
|
||||
|
||||
$canvas->addText(array('x' => 5, 'y' => 5, 'text' => 'Line'));
|
||||
|
||||
$canvas->setLineColor('black');
|
||||
$canvas->line(array('x0' => 100, 'x1' => 195, 'y0' => 5, 'y1' => 5));
|
||||
$canvas->setLineColor('red');
|
||||
$canvas->line(array('x0' => 200, 'x1' => 295, 'y0' => 5, 'y1' => 5));
|
||||
$canvas->setLineColor('green');
|
||||
$canvas->line(array('x0' => 300, 'x1' => 395, 'y0' => 5, 'y1' => 5));
|
||||
$canvas->setLineColor('blue');
|
||||
$canvas->line(array('x0' => 400, 'x1' => 495, 'y0' => 5, 'y1' => 5));
|
||||
|
||||
$canvas->setLineColor(array('blue', 'red'));
|
||||
$canvas->line(array('x0' => 100, 'x1' => 195, 'y0' => 10, 'y1' => 10));
|
||||
|
||||
$canvas->setLineColor(array('blue', 'blue', 'transparent'));
|
||||
$canvas->line(array('x0' => 200, 'x1' => 295, 'y0' => 10, 'y1' => 10));
|
||||
|
||||
$canvas->setLineColor('yellow');
|
||||
$canvas->setLineThickness(2);
|
||||
$canvas->line(array('x0' => 300, 'x1' => 395, 'y0' => 10, 'y1' => 10));
|
||||
|
||||
$canvas->setLineColor('red');
|
||||
$canvas->setLineThickness(4);
|
||||
$canvas->line(array('x0' => 400, 'x1' => 495, 'y0' => 10, 'y1' => 10));
|
||||
|
||||
$canvas->setLineColor('black@0.4');
|
||||
$canvas->setLineThickness(4);
|
||||
$canvas->line(array('x0' => 100, 'x1' => 220, 'y0' => 15, 'y1' => 15));
|
||||
$canvas->setLineColor('red@0.4');
|
||||
$canvas->setLineThickness(4);
|
||||
$canvas->line(array('x0' => 200, 'x1' => 320, 'y0' => 15, 'y1' => 15));
|
||||
$canvas->setLineColor('green@0.4');
|
||||
$canvas->setLineThickness(4);
|
||||
$canvas->line(array('x0' => 300, 'x1' => 420, 'y0' => 15, 'y1' => 15));
|
||||
$canvas->setLineColor('blue@0.4');
|
||||
$canvas->setLineThickness(4);
|
||||
$canvas->line(array('x0' => 400, 'x1' => 495, 'y0' => 15, 'y1' => 15));
|
||||
|
||||
$canvas->addText(array('x' => 5, 'y' => 30, 'text' => 'Rectangle'));
|
||||
|
||||
$canvas->setLineColor('black');
|
||||
$canvas->rectangle(array('x0' => 100, 'x1' => 150, 'y0' => 30, 'y1' => 80));
|
||||
$canvas->setLineColor('red');
|
||||
$canvas->rectangle(array('x0' => 155, 'x1' => 205, 'y0' => 30, 'y1' => 80));
|
||||
$canvas->setLineColor('green');
|
||||
$canvas->rectangle(array('x0' => 210, 'x1' => 260, 'y0' => 30, 'y1' => 80));
|
||||
$canvas->setLineColor('blue');
|
||||
$canvas->rectangle(array('x0' => 265, 'x1' => 315, 'y0' => 30, 'y1' => 80));
|
||||
|
||||
$canvas->setFillColor('black');
|
||||
$canvas->rectangle(array('x0' => 100, 'x1' => 150, 'y0' => 85, 'y1' => 135));
|
||||
$canvas->setLineColor('black');
|
||||
$canvas->setFillColor('red');
|
||||
$canvas->rectangle(array('x0' => 155, 'x1' => 205, 'y0' => 85, 'y1' => 135));
|
||||
$canvas->setLineColor('black');
|
||||
$canvas->setFillColor('green');
|
||||
$canvas->rectangle(array('x0' => 210, 'x1' => 260, 'y0' => 85, 'y1' => 135));
|
||||
$canvas->setLineColor('black');
|
||||
$canvas->setFillColor('blue');
|
||||
$canvas->rectangle(array('x0' => 265, 'x1' => 315, 'y0' => 85, 'y1' => 135));
|
||||
|
||||
$canvas->setLineColor('red');
|
||||
$canvas->setFillColor('red@0.3');
|
||||
$canvas->rectangle(array('x0' => 340, 'x1' => 400, 'y0' => 30, 'y1' => 90));
|
||||
$canvas->setLineColor('green');
|
||||
$canvas->setFillColor('green@0.3');
|
||||
$canvas->rectangle(array('x0' => 380, 'x1' => 440, 'y0' => 50, 'y1' => 110));
|
||||
$canvas->setLineColor('blue');
|
||||
$canvas->setFillColor('blue@0.3');
|
||||
$canvas->rectangle(array('x0' => 360, 'x1' => 420, 'y0' => 70, 'y1' => 130));
|
||||
|
||||
$canvas->addText(array('x' => 90, 'y' => 140, 'text' => "Circle / Ellipse", 'alignment' => array('horizontal' => 'right')));
|
||||
|
||||
$canvas->setLineColor('black');
|
||||
$canvas->ellipse(array('x' => 130, 'y' => 170, 'rx' => 30, 'ry' => 30));
|
||||
$canvas->setLineColor('red');
|
||||
$canvas->ellipse(array('x' => 195, 'y' => 170, 'rx' => 30, 'ry' => 30));
|
||||
$canvas->setLineColor('blue');
|
||||
$canvas->ellipse(array('x' => 250, 'y' => 170, 'rx' => 30, 'ry' => 30));
|
||||
$canvas->setLineColor('green');
|
||||
$canvas->ellipse(array('x' => 305, 'y' => 170, 'rx' => 30, 'ry' => 30));
|
||||
|
||||
$canvas->setFillColor('black');
|
||||
$canvas->ellipse(array('x' => 130, 'y' => 235, 'rx' => 30, 'ry' => 30));
|
||||
$canvas->setLineColor('black');
|
||||
$canvas->setFillColor('red');
|
||||
$canvas->ellipse(array('x' => 195, 'y' => 235, 'rx' => 30, 'ry' => 30));
|
||||
$canvas->setLineColor('black');
|
||||
$canvas->setFillColor('blue');
|
||||
$canvas->ellipse(array('x' => 250, 'y' => 235, 'rx' => 30, 'ry' => 30));
|
||||
$canvas->setLineColor('black');
|
||||
$canvas->setFillColor('green');
|
||||
$canvas->ellipse(array('x' => 305, 'y' => 235, 'rx' => 30, 'ry' => 30));
|
||||
|
||||
$canvas->setLineColor('brown');
|
||||
$canvas->setFillColor('brown@0.3');
|
||||
$canvas->ellipse(array('x' => 400, 'y' => 200, 'rx' => 40, 'ry' => 40));
|
||||
$canvas->setLineColor('orange');
|
||||
$canvas->setFillColor('orange@0.3');
|
||||
$canvas->ellipse(array('x' => 430, 'y' => 220, 'rx' => 30, 'ry' => 40));
|
||||
$canvas->setLineColor('purple');
|
||||
$canvas->setFillColor('purple@0.3');
|
||||
$canvas->ellipse(array('x' => 390, 'y' => 230, 'rx' => 40, 'ry' => 20));
|
||||
|
||||
$canvas->addText(array('x' => 5, 'y' => 270, 'text' => 'Pie slices'));
|
||||
|
||||
$c = 0;
|
||||
for ($i = 360; $i >= 45; $i -= 30) {
|
||||
$canvas->setLineColor('black');
|
||||
$canvas->setFillColor('blue@' . sprintf('%0.1f', ((360 - $i) / 360)));
|
||||
$canvas->pieslice(
|
||||
array(
|
||||
'x' => 130 + $c * 55,
|
||||
'y' => 295,
|
||||
'rx' => 25,
|
||||
'ry' => 25,
|
||||
'v1' => 0,
|
||||
'v2' => $i
|
||||
)
|
||||
);
|
||||
$c++;
|
||||
}
|
||||
|
||||
$canvas->addText(array('x' => 5, 'y' => 325, 'text' => 'Polygon'));
|
||||
|
||||
$canvas->setLineColor('green');
|
||||
for ($i = 0; $i < 8; $i++) {
|
||||
$canvas->addVertex(array('x' => 115 + $i * 50, 'y' => 330));
|
||||
$canvas->addVertex(array('x' => 100 + $i * 50, 'y' => 325));
|
||||
$canvas->addVertex(array('x' => 125 + $i * 50, 'y' => 350));
|
||||
}
|
||||
$canvas->polygon(array('connect' => false));
|
||||
|
||||
$canvas->setLineColor('purple');
|
||||
$canvas->setFillColor('purple@0.3');
|
||||
for ($i = 0; $i < 8; $i++) {
|
||||
$canvas->addVertex(array('x' => 100 + $i * 50, 'y' => 355));
|
||||
$canvas->addVertex(array('x' => 125 + $i * 50, 'y' => 380 + 2 * $i));
|
||||
}
|
||||
$canvas->addVertex(array('x' => 550, 'y' => 355));
|
||||
for ($i = 4; $i >= 0; $i--) {
|
||||
$canvas->addVertex(array('x' => 120 + $i * 100, 'y' => 430 + $i * 5));
|
||||
$canvas->addVertex(array('x' => 110 + $i * 100, 'y' => 405 - $i * 5));
|
||||
}
|
||||
$canvas->polygon(array('connect' => true));
|
||||
|
||||
$canvas->addText(array('x' => 5, 'y' => 455, 'text' => 'Splines'));
|
||||
|
||||
$points = array();
|
||||
$points[] = array(
|
||||
'x' => 100, 'y' => 470,
|
||||
'p1x' => 120, 'p1y' => 455,
|
||||
'p2x' => 150, 'p2y' => 460
|
||||
);
|
||||
|
||||
$points[] = array(
|
||||
'x' => 170, 'y' => 490,
|
||||
'p1x' => 190, 'p1y' => 500,
|
||||
'p2x' => 200, 'p2y' => 510
|
||||
);
|
||||
|
||||
$points[] = array(
|
||||
'x' => 210, 'y' => 540,
|
||||
'p1x' => 200, 'p1y' => 550,
|
||||
'p2x' => 160, 'p2y' => 560
|
||||
);
|
||||
|
||||
$points[] = array(
|
||||
'x' => 120, 'y' => 480
|
||||
);
|
||||
|
||||
// draw control points! not directly a canvas test!
|
||||
foreach ($points as $point) {
|
||||
if (isset($last)) {
|
||||
$canvas->setLineColor('gray@0.2');
|
||||
$canvas->line(array('x0' => $last['p2x'], 'y0' => $last['p2y'], 'x1' => $point['x'], 'y1' => $point['y']));
|
||||
}
|
||||
|
||||
$canvas->setLineColor('red');
|
||||
$canvas->ellipse(array('x' => $point['x'], 'y' => $point['y'], 'rx' => 3, 'ry' => 3));
|
||||
|
||||
if (isset($point['p1x'])) {
|
||||
$canvas->setLineColor('green');
|
||||
$canvas->ellipse(array('x' => $point['p1x'], 'y' => $point['p1y'], 'rx' => 2, 'ry' => 2));
|
||||
$canvas->setLineColor('green');
|
||||
$canvas->ellipse(array('x' => $point['p2x'], 'y' => $point['p2y'], 'rx' => 2, 'ry' => 2));
|
||||
|
||||
$canvas->setLineColor('gray@0.2');
|
||||
$canvas->line(array('x0' => $point['x'], 'y0' => $point['y'], 'x1' => $point['p1x'], 'y1' => $point['p1y']));
|
||||
$canvas->setLineColor('gray@0.2');
|
||||
$canvas->line(array('x0' => $point['p1x'], 'y0' => $point['p1y'], 'x1' => $point['p2x'], 'y1' => $point['p2y']));
|
||||
|
||||
$last = $point;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($points as $point) {
|
||||
if (isset($point['p1x'])) {
|
||||
$canvas->addSpline($point);
|
||||
} else {
|
||||
$canvas->addVertex($point);
|
||||
}
|
||||
}
|
||||
|
||||
$canvas->setLineColor('black');
|
||||
$canvas->polygon(array('connect' => false));
|
||||
|
||||
$points = array();
|
||||
$points[] = array(
|
||||
'x' => 220, 'y' => 470,
|
||||
'p1x' => 240, 'p1y' => 455,
|
||||
'p2x' => 270, 'p2y' => 460
|
||||
);
|
||||
|
||||
$points[] = array(
|
||||
'x' => 240, 'y' => 490,
|
||||
'p1x' => 310, 'p1y' => 460,
|
||||
'p2x' => 320, 'p2y' => 470
|
||||
);
|
||||
|
||||
$points[] = array(
|
||||
'x' => 330, 'y' => 500,
|
||||
'p1x' => 320, 'p1y' => 550,
|
||||
'p2x' => 280, 'p2y' => 560
|
||||
);
|
||||
|
||||
$points[] = array(
|
||||
'x' => 240, 'y' => 520,
|
||||
'p1x' => 230, 'p1y' => 490,
|
||||
'p2x' => 225, 'p2y' => 490
|
||||
);
|
||||
|
||||
$points[] = array(
|
||||
'x' => 220, 'y' => 470
|
||||
);
|
||||
|
||||
unset($last);
|
||||
// draw control points! not directly a canvas test!
|
||||
foreach ($points as $point) {
|
||||
if (isset($last)) {
|
||||
$canvas->setLineColor('gray@0.2');
|
||||
$canvas->line(array('x0' => $last['p2x'], 'y0' => $last['p2y'], 'x1' => $point['x'], 'y1' => $point['y']));
|
||||
}
|
||||
|
||||
$canvas->setLineColor('red');
|
||||
$canvas->ellipse(array('x' => $point['x'], 'y' => $point['y'], 'rx' => 3, 'ry' => 3));
|
||||
|
||||
if (isset($point['p1x'])) {
|
||||
$canvas->setLineColor('green');
|
||||
$canvas->ellipse(array('x' => $point['p1x'], 'y' => $point['p1y'], 'rx' => 2, 'ry' => 2));
|
||||
$canvas->setLineColor('green');
|
||||
$canvas->ellipse(array('x' => $point['p2x'], 'y' => $point['p2y'], 'rx' => 2, 'ry' => 2));
|
||||
|
||||
$canvas->setLineColor('gray@0.2');
|
||||
$canvas->line(array('x0' => $point['x'], 'y0' => $point['y'], 'x1' => $point['p1x'], 'y1' => $point['p1y']));
|
||||
$canvas->setLineColor('gray@0.2');
|
||||
$canvas->line(array('x0' => $point['p1x'], 'y0' => $point['p1y'], 'x1' => $point['p2x'], 'y1' => $point['p2y']));
|
||||
|
||||
$last = $point;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($points as $point) {
|
||||
if (isset($point['p1x'])) {
|
||||
$canvas->addSpline($point);
|
||||
} else {
|
||||
$canvas->addVertex($point);
|
||||
}
|
||||
}
|
||||
|
||||
$canvas->setLineColor('black');
|
||||
$canvas->setFillColor('red@0.2');
|
||||
$canvas->polygon(array('connect' => true));
|
||||
|
||||
$canvas->addText(array('x' => 375, 'y' => 455, 'text' => 'Image'));
|
||||
|
||||
$canvas->image(array('x' => 445, 'y' => 455, 'filename' => './pear-icon.png', 'url' => 'http://pear.veggerby.dk/', 'target' => '_blank'));
|
||||
|
||||
$canvas->image(array('x' => 445, 'y' => 495, 'filename' => './pear-icon.png', 'width' => 20, 'height' => 20));
|
||||
|
||||
$canvas->image(array('x' => 445, 'y' => 523, 'filename' => './pear-icon.png', 'width' => 40, 'height' => 40));
|
||||
|
||||
//$canvas->show();
|
||||
$type = basename($_SERVER['SCRIPT_NAME'], '.php');
|
||||
$canvas->toHtml(
|
||||
array(
|
||||
'filename' => 'test' . $type . '.' . $type,
|
||||
'urlpath' => '',
|
||||
'filepath' => './',
|
||||
'width' => '100%',
|
||||
'height' => '100%'
|
||||
)
|
||||
);
|
||||
|
||||
?>
|
70
includes/pear/Image/tests/freetype.php
Normal file
70
includes/pear/Image/tests/freetype.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This is a visual test case, testing basic Freetype support within GD
|
||||
*
|
||||
* If this fails, a basic requirement of Image_Graph is not met, and it is as
|
||||
* such not a Image_Graph failure but a (missing) component of PHP all together.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
* option) any later version. This library is distributed in the hope that it
|
||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||
* General Public License for more details. You should have received a copy of
|
||||
* the GNU Lesser General Public License along with this library; if not, write
|
||||
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307 USA
|
||||
*
|
||||
* @category Images
|
||||
* @package Image_Graph
|
||||
* @subpackage Tests
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version CVS: $Id: freetype.php,v 1.2 2005/02/21 20:49:58 nosey Exp $
|
||||
* @link http://pear.php.net/package/Image_Graph
|
||||
*/
|
||||
|
||||
// SPECIFY HERE WHERE A TRUETYPE FONT CAN BE FOUND
|
||||
$testFont = 'c:/windows/fonts/Arial.ttf';
|
||||
|
||||
if (!file_exists($testFont)) {
|
||||
die('The font specified cannot be found (' . $testFont .')! Please specify an existing font');
|
||||
}
|
||||
|
||||
// create a true color image (requires GD2)
|
||||
$image = ImageCreateTrueColor(600, 200);
|
||||
ImageAlphaBlending($image, true);
|
||||
|
||||
// allocate some colors
|
||||
$black = ImageColorAllocate($image, 0, 0, 0);
|
||||
$red = ImageColorAllocate($image, 0xff, 0, 0);
|
||||
$green = ImageColorAllocate($image, 0, 0xff, 0);
|
||||
$blue = ImageColorAllocate($image, 0, 0, 0xff);
|
||||
$white = ImageColorAllocate($image, 0xff, 0xff, 0xff);
|
||||
|
||||
// create a frame
|
||||
ImageFilledRectangle($image, 0, 0, 599, 199, $white);
|
||||
ImageRectangle($image, 0, 0, 599, 199, $black);
|
||||
|
||||
// output some text using the specified font
|
||||
$y = 20;
|
||||
$text = 'Your Freetype installation with GD works';
|
||||
for ($i = 12; $i <= 20; $i++) {
|
||||
$box = ImageTTFBbox($i, 0, $testFont, $text);
|
||||
$x = 300 - (max($box[0], $box[2], $box[4], $box[6]) - min($box[0], $box[2], $box[4], $box[6])) / 2;
|
||||
ImageTTFText($image, $i, 0, $x, $y, $black, $testFont, $text);
|
||||
$y += max($box[1], $box[3], $box[5], $box[7]) - min($box[1], $box[3], $box[5], $box[7]);
|
||||
}
|
||||
|
||||
// output the test image
|
||||
header('Content-Type: image/png');
|
||||
ImagePNG($image);
|
||||
|
||||
?>
|
75
includes/pear/Image/tests/gd.php
Normal file
75
includes/pear/Image/tests/gd.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This is a visual test case, testing basic GD2 support
|
||||
*
|
||||
* If this fails, a basic requirement of Image_Graph is not met, and it is as
|
||||
* such not a Image_Graph failure but a (missing) component of PHP all together.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
* option) any later version. This library is distributed in the hope that it
|
||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||
* General Public License for more details. You should have received a copy of
|
||||
* the GNU Lesser General Public License along with this library; if not, write
|
||||
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307 USA
|
||||
*
|
||||
* @category Images
|
||||
* @package Image_Graph
|
||||
* @subpackage Tests
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version CVS: $Id: gd.php,v 1.2 2005/02/21 20:49:58 nosey Exp $
|
||||
* @link http://pear.php.net/package/Image_Graph
|
||||
*/
|
||||
|
||||
// create a true color image (requires GD2)
|
||||
$image = ImageCreateTrueColor(400, 300);
|
||||
ImageAlphaBlending($image, true);
|
||||
|
||||
// allocate some colors
|
||||
$black = ImageColorAllocate($image, 0, 0, 0);
|
||||
$red = ImageColorAllocate($image, 0xff, 0, 0);
|
||||
$green = ImageColorAllocate($image, 0, 0xff, 0);
|
||||
$blue = ImageColorAllocate($image, 0, 0, 0xff);
|
||||
$white = ImageColorAllocate($image, 0xff, 0xff, 0xff);
|
||||
|
||||
// create a frame
|
||||
ImageFilledRectangle($image, 0, 0, 399, 299, $white);
|
||||
ImageRectangle($image, 0, 0, 399, 299, $black);
|
||||
|
||||
// draw some lines
|
||||
ImageLine($image, 200, 50, 350, 150, $red);
|
||||
ImageLine($image, 200, 60, 350, 160, $green);
|
||||
ImageLine($image, 200, 70, 350, 170, $blue);
|
||||
|
||||
// draw some overlapping alpha blended boxes
|
||||
$redAlpha = ImageColorAllocateAlpha($image, 0xff, 0, 0, 75);
|
||||
$blueAlpha = ImageColorAllocateAlpha($image, 0, 0xff, 0, 75);
|
||||
$greenAlpha = ImageColorAllocateAlpha($image, 0, 0, 0xff, 75);
|
||||
|
||||
ImageFilledRectangle($image, 50, 50, 90, 90, $redAlpha);
|
||||
ImageFilledRectangle($image, 60, 80, 100, 120, $greenAlpha);
|
||||
ImageFilledRectangle($image, 80, 60, 120, 100, $blueAlpha);
|
||||
|
||||
// write some _default_ text
|
||||
for ($font = 1; $font <= 5; $font++) {
|
||||
ImageString($image, $font, 50, 150 + $font * 20, 'Testing GD output', $black);
|
||||
}
|
||||
|
||||
ImageString($image, 3, 51, 21, 'Congratulations! The GD2 installation works', $black);
|
||||
ImageString($image, 3, 50, 20, 'Congratulations! The GD2 installation works', $red);
|
||||
|
||||
// output the test image
|
||||
header('Content-Type: image/png');
|
||||
ImagePNG($image);
|
||||
|
||||
?>
|
87
includes/pear/Image/tests/gradients.php
Normal file
87
includes/pear/Image/tests/gradients.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This is a visual test case, testing canvas support for gradient fillings.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
* option) any later version. This library is distributed in the hope that it
|
||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||
* General Public License for more details. You should have received a copy of
|
||||
* the GNU Lesser General Public License along with this library; if not, write
|
||||
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307 USA
|
||||
*
|
||||
* @category Images
|
||||
* @package Image_Canvas
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version CVS: $Id: gradients.php,v 1.2 2005/08/03 21:17:48 nosey Exp $
|
||||
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
|
||||
*/
|
||||
|
||||
require_once 'Image/Canvas.php';
|
||||
|
||||
$canvas =& Image_Canvas::factory(
|
||||
'png',
|
||||
array('width' => 605, 'height' => 350)
|
||||
);
|
||||
|
||||
$gradient = array(
|
||||
'type' => 'gradient',
|
||||
'start' => 'yellow',
|
||||
'end' => 'maroon'
|
||||
);
|
||||
|
||||
$directions = array('horizontal', 'vertical', 'horizontal_mirror', 'vertical_mirror', 'diagonal_tl_br', 'diagonal_bl_tr', 'radial');
|
||||
|
||||
$space = 10;
|
||||
$size = 75;
|
||||
|
||||
$canvas->setLineColor('black');
|
||||
$canvas->rectangle(array('x0' => 0, 'y0' => 0, 'x1' => $canvas->getWidth() - 1, 'y1' => $canvas->getHeight() - 1));
|
||||
|
||||
$i = 0;
|
||||
foreach ($directions as $direction) {
|
||||
$gradient['direction'] = $direction;
|
||||
|
||||
$x = $space + ($i * ($size + $space));
|
||||
|
||||
$y = $space;
|
||||
$canvas->setGradientFill($gradient);
|
||||
$canvas->rectangle(array('x0' => $x, 'y0' => $y, 'x1' => $x + $size, 'y1' => $y + $size));
|
||||
|
||||
$y += $size + $space;
|
||||
$canvas->setGradientFill($gradient);
|
||||
$canvas->ellipse(array('x' => $x + $size / 2, 'y' => $y + $size / 2, 'rx' => $size / 2, 'ry' => $size / 2));
|
||||
|
||||
$y += $size + $space;
|
||||
$canvas->setGradientFill($gradient);
|
||||
$canvas->pieslice(array('x' => $x + $size / 2, 'y' => $y + $size / 2, 'rx' => $size / 2, 'ry' => $size / 2, 'v1' => 45, 'v2' => 270));
|
||||
|
||||
$y += $size + $space;
|
||||
$points = array();
|
||||
$points[] = array('x' => $x + $size / 3, 'y' => $y);
|
||||
$points[] = array('x' => $x + $size, 'y' => $y + $size / 2);
|
||||
$points[] = array('x' => $x + $size / 3, 'y' => $y + 3 * $size / 4);
|
||||
$points[] = array('x' => $x + $size / 5, 'y' => $y + $size);
|
||||
$points[] = array('x' => $x, 'y' => $y + $size / 3);
|
||||
$y += $size + $space;
|
||||
$canvas->setGradientFill($gradient);
|
||||
foreach ($points as $point) {
|
||||
$canvas->addVertex($point);
|
||||
}
|
||||
$canvas->polygon(array('connect' => true));
|
||||
$i++;
|
||||
}
|
||||
|
||||
$canvas->show();
|
||||
|
||||
?>
|
180
includes/pear/Image/tests/imagemap.php
Normal file
180
includes/pear/Image/tests/imagemap.php
Normal file
@@ -0,0 +1,180 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This is a visual test case, testing image map support
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
* option) any later version. This library is distributed in the hope that it
|
||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||
* General Public License for more details. You should have received a copy of
|
||||
* the GNU Lesser General Public License along with this library; if not, write
|
||||
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307 USA
|
||||
*
|
||||
* @category Images
|
||||
* @package Image_Canvas
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version CVS: $Id: imagemap.php,v 1.4 2005/08/10 20:01:05 nosey Exp $
|
||||
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
|
||||
*/
|
||||
|
||||
require_once 'Image/Canvas.php';
|
||||
|
||||
$canvas =& Image_Canvas::factory(
|
||||
'png',
|
||||
array('width' => 800, 'height' => 500, 'usemap' => true, 'antialias' => 'native')
|
||||
);
|
||||
|
||||
$canvas->setLineColor('black');
|
||||
$canvas->rectangle(array('x0' => 0, 'y0' => 0, 'x1' => $canvas->getWidth() - 1, 'y1' => $canvas->getHeight() - 1));
|
||||
|
||||
|
||||
$canvas->setLineColor('gray');
|
||||
$canvas->line(
|
||||
array(
|
||||
'x0' => 450,
|
||||
'y0' => 50,
|
||||
'x1' => 550,
|
||||
'y1' => 100,
|
||||
'url' => 'http://pear.veggerby.dk/',
|
||||
'target' => '_blank',
|
||||
'alt' => 'Line',
|
||||
'mapsize' => 5
|
||||
)
|
||||
);
|
||||
|
||||
$canvas->setLineColor('gray');
|
||||
$canvas->line(
|
||||
array(
|
||||
'x0' => 600,
|
||||
'y0' => 125,
|
||||
'x1' => 700,
|
||||
'y1' => 50,
|
||||
'url' => 'http://pear.veggerby.dk/',
|
||||
'target' => '_blank',
|
||||
'alt' => 'Line',
|
||||
'mapsize' => 5
|
||||
)
|
||||
);
|
||||
|
||||
$canvas->setLineColor('blue');
|
||||
$canvas->rectangle(
|
||||
array(
|
||||
'x0' => 50,
|
||||
'y0' => 50,
|
||||
'x1' => 350,
|
||||
'y1' => 100,
|
||||
'url' => 'http://pear.veggerby.dk/',
|
||||
'target' => '_blank',
|
||||
'alt' => 'Rectangle'
|
||||
)
|
||||
);
|
||||
|
||||
$canvas->setLineColor('red');
|
||||
$canvas->ellipse(
|
||||
array(
|
||||
'x' => 200,
|
||||
'y' => 200,
|
||||
'rx' => 75,
|
||||
'ry' => 75,
|
||||
'url' => 'http://pear.php.net/Image_Graph/',
|
||||
'alt' => 'Circle'
|
||||
)
|
||||
);
|
||||
|
||||
$canvas->setLineColor('brown');
|
||||
$canvas->ellipse(
|
||||
array(
|
||||
'x' => 500,
|
||||
'y' => 200,
|
||||
'rx' => 100,
|
||||
'ry' => 75,
|
||||
'url' => 'http://pear.php.net/Image_Graph/',
|
||||
'alt' => 'Ellipse'
|
||||
)
|
||||
);
|
||||
|
||||
$canvas->setLineColor('green');
|
||||
for ($i = 0; $i < 8; $i++) {
|
||||
$canvas->addVertex(array('x' => 115 + $i * 50, 'y' => 330, 'alt' => 'Vertex #' . $i * 3, 'url' => 'test?id=' . $i * 3));
|
||||
$canvas->addVertex(array('x' => 100 + $i * 50, 'y' => 325, 'alt' => 'Vertex #' . ($i * 3 + 1), 'url' => 'test?id=' . ($i * 3 + 1)));
|
||||
$canvas->addVertex(array('x' => 125 + $i * 50, 'y' => 350, 'alt' => 'Vertex #' . ($i * 3 + 2), 'url' => 'test?id=' . ($i * 3 + 2)));
|
||||
}
|
||||
$canvas->polygon(
|
||||
array(
|
||||
'connect' => false,
|
||||
'url' => 'http://php.net/',
|
||||
'alt' => 'Open polygon',
|
||||
'map_vertices' => true
|
||||
)
|
||||
);
|
||||
|
||||
$canvas->setLineColor('purple');
|
||||
for ($i = 0; $i < 8; $i++) {
|
||||
$canvas->addVertex(array('x' => 100 + $i * 50, 'y' => 355));
|
||||
$canvas->addVertex(array('x' => 125 + $i * 50, 'y' => 380 + 2 * $i));
|
||||
}
|
||||
$canvas->addVertex(array('x' => 550, 'y' => 355));
|
||||
for ($i = 4; $i >= 0; $i--) {
|
||||
$canvas->addVertex(array('x' => 120 + $i * 100, 'y' => 430 + $i * 5));
|
||||
$canvas->addVertex(array('x' => 110 + $i * 100, 'y' => 405 - $i * 5));
|
||||
}
|
||||
$canvas->polygon(
|
||||
array(
|
||||
'connect' => true,
|
||||
'url' => 'http://pear.php.net/',
|
||||
'alt' => 'Closed polygon'
|
||||
)
|
||||
);
|
||||
|
||||
$canvas->setLineColor('orange');
|
||||
$canvas->pieslice(
|
||||
array(
|
||||
'x' => 600,
|
||||
'y' => 400,
|
||||
'rx' => 50,
|
||||
'ry' => 50,
|
||||
'v1' => 10,
|
||||
'v2' => 350,
|
||||
'url' => 'http://www.dr.dk/',
|
||||
'alt' => 'Pieslice'
|
||||
)
|
||||
);
|
||||
|
||||
$canvas->setLineColor('silver');
|
||||
$canvas->pieslice(
|
||||
array(
|
||||
'x' => 700,
|
||||
'y' => 300,
|
||||
'rx' => 100,
|
||||
'ry' => 50,
|
||||
'v1' => 45,
|
||||
'v2' => 275,
|
||||
'srx' => 25,
|
||||
'sry' => 10,
|
||||
'url' => 'http://www.dr.dk/',
|
||||
'alt' => 'Donut slice',
|
||||
'htmltags' => array(
|
||||
'onMouseOver' => 'alert("Hello, World!");'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
print $canvas->toHtml(
|
||||
array(
|
||||
'filename' => 'imagemap.png',
|
||||
'filepath' => './',
|
||||
'urlpath' => ''
|
||||
)
|
||||
);
|
||||
|
||||
?>
|
39
includes/pear/Image/tests/jpg.php
Normal file
39
includes/pear/Image/tests/jpg.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This is a visual test case, testing canvas fundamental canvas functionality.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
* option) any later version. This library is distributed in the hope that it
|
||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||
* General Public License for more details. You should have received a copy of
|
||||
* the GNU Lesser General Public License along with this library; if not, write
|
||||
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307 USA
|
||||
*
|
||||
* @category Images
|
||||
* @package Image_Canvas
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version CVS: $Id: jpg.php,v 1.2 2005/08/03 21:17:48 nosey Exp $
|
||||
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
|
||||
*/
|
||||
|
||||
// SPECIFY HERE WHERE A TRUETYPE FONT CAN BE FOUND
|
||||
$testFont = 'c:/windows/fonts/Arial.ttf';
|
||||
|
||||
require_once 'Image/Canvas.php';
|
||||
|
||||
$canvas =& Image_Canvas::factory('jpg', array('width' => 600, 'height' => 600, 'quality' => 90));
|
||||
|
||||
require_once './canvas_body.php';
|
||||
|
||||
?>
|
85
includes/pear/Image/tests/lineends.php
Normal file
85
includes/pear/Image/tests/lineends.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This is a visual test case, testing canvas support for text output.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
* option) any later version. This library is distributed in the hope that it
|
||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||
* General Public License for more details. You should have received a copy of
|
||||
* the GNU Lesser General Public License along with this library; if not, write
|
||||
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307 USA
|
||||
*
|
||||
* @category Images
|
||||
* @package Image_Canvas
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version CVS: $Id: lineends.php,v 1.3 2005/08/04 19:24:39 nosey Exp $
|
||||
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
|
||||
*/
|
||||
|
||||
require_once 'Image/Canvas.php';
|
||||
|
||||
$font = array('name' => 'Verdana', 'size' => 10);
|
||||
|
||||
$canvas =& Image_Canvas::factory(
|
||||
'png',
|
||||
array('width' => 300, 'height' => 300)
|
||||
);
|
||||
|
||||
$shapes = array('arrow', 'box', 'diamond', 'arrow2', 'lollipop', 'line');
|
||||
|
||||
$j = 0;
|
||||
for ($i = 0; $i < 360; $i += 30) {
|
||||
$x0 = 150;
|
||||
$y0 = 150;
|
||||
if ($j >= count($shapes)) {
|
||||
$j = 0;
|
||||
}
|
||||
$shape1 = $shapes[$j]; $j++;
|
||||
|
||||
if ($j >= count($shapes)) {
|
||||
$j = 0;
|
||||
}
|
||||
$shape2 = $shapes[$j]; $j++;
|
||||
|
||||
$canvas->setLineColor('black');
|
||||
$canvas->line(
|
||||
array(
|
||||
'x0' => $x0 + cos(deg2rad($i)) * 50,
|
||||
'y0' => $y0 - sin(deg2rad($i)) * 50,
|
||||
'x1' => $x0 + cos(deg2rad($i)) * 100,
|
||||
'y1' => $y0 - sin(deg2rad($i)) * 100,
|
||||
'end0' => $shape1,
|
||||
'size0' => 8,
|
||||
'color0' => 'red',
|
||||
'end1' => $shape2,
|
||||
'color1' => 'green',
|
||||
'size1' => 8
|
||||
)
|
||||
);
|
||||
$canvas->setFont($font);
|
||||
$canvas->addText(
|
||||
array(
|
||||
'x' => $x0 + cos(deg2rad($i)) * 125,
|
||||
'y' => $y0 - sin(deg2rad($i)) * 125,
|
||||
'text' => $i,
|
||||
'alignment' => array(
|
||||
'horizontal' => ((($i > 90) && ($i < 270)) ? 'right' : ((($i == 90) || ($i == 270)) ? 'center' : 'left')),
|
||||
'vertical' => (($i < 180) ? 'bottom' : ((($i == 0) || ($i == 180)) ? 'center' : 'top')),
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
$canvas->show();
|
||||
|
||||
?>
|
39
includes/pear/Image/tests/pdf.php
Normal file
39
includes/pear/Image/tests/pdf.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This is a visual test case, testing canvas fundamental canvas functionality.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
* option) any later version. This library is distributed in the hope that it
|
||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||
* General Public License for more details. You should have received a copy of
|
||||
* the GNU Lesser General Public License along with this library; if not, write
|
||||
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307 USA
|
||||
*
|
||||
* @category Images
|
||||
* @package Image_Canvas
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version CVS: $Id: pdf.php,v 1.2 2005/08/03 21:17:48 nosey Exp $
|
||||
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
|
||||
*/
|
||||
|
||||
// SPECIFY HERE WHERE A TRUETYPE FONT CAN BE FOUND
|
||||
$testFont = 'c:/windows/fonts/Arial.ttf';
|
||||
|
||||
require_once 'Image/Canvas.php';
|
||||
|
||||
$canvas =& Image_Canvas::factory('pdf', array('page' => 'A4', 'align' => 'center', 'width' => 600, 'height' => 600));
|
||||
|
||||
require_once './canvas_body.php';
|
||||
|
||||
?>
|
BIN
includes/pear/Image/tests/pear-icon.png
Normal file
BIN
includes/pear/Image/tests/pear-icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 927 B |
79
includes/pear/Image/tests/plot/area.php
Normal file
79
includes/pear/Image/tests/plot/area.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This is a visual test case, testing the a set of area plots.
|
||||
*
|
||||
* Test cases:
|
||||
*
|
||||
* 1,1: A "normal" simple plot test
|
||||
*
|
||||
* 1,2: A plot crossing the x-axis (both positive and negative y-values)
|
||||
*
|
||||
* 2,1: A plot with all positive non-zero values
|
||||
*
|
||||
* 2,2: A plot with all negative non-zero values
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
* option) any later version. This library is distributed in the hope that it
|
||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||
* General Public License for more details. You should have received a copy of
|
||||
* the GNU Lesser General Public License along with this library; if not, write
|
||||
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307 USA
|
||||
*
|
||||
* @category Images
|
||||
* @package Image_Graph
|
||||
* @subpackage Tests
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version CVS: $Id: area.php,v 1.5 2005/08/03 21:21:58 nosey Exp $
|
||||
* @link http://pear.php.net/package/Image_Graph
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(600, 400));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('ttf_font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(7);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
// create the plotarea
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Testing Area Plots', 10)),
|
||||
$Matrix = Image_Graph::factory('Image_Graph_Layout_Matrix', array(2, 2)),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
$DS[0][0] =& Image_Graph::factory('dataset', array(array('A' => 1, 'B' => 2, 'C' => 0, 'D' => 4, 'E' => 3)));
|
||||
$DS[0][1] =& Image_Graph::factory('dataset', array(array('A' => 1, 'B' => -2, 'C' => 1, 'D' => 3, 'E' => -1)));
|
||||
$DS[1][0] =& Image_Graph::factory('dataset', array(array('A' => 2, 'B' => 3, 'C' => 1, 'D' => 4, 'E' => 2)));
|
||||
$DS[1][1] =& Image_Graph::factory('dataset', array(array('A' => -1, 'B' => -3, 'C' => -2, 'D' => -4, 'E' => -1)));
|
||||
|
||||
for ($row = 0; $row < 2; $row++) {
|
||||
for ($col = 0; $col < 2; $col++) {
|
||||
if (isset($DS[$row][$col])) {
|
||||
$Plotarea =& $Matrix->getEntry($row, $col);
|
||||
|
||||
$Plot =& $Plotarea->addNew('area', $DS[$row][$col]);
|
||||
$Plot->setLineColor('gray');
|
||||
$Plot->setFillColor('blue@0.2');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$Graph->done();
|
||||
?>
|
79
includes/pear/Image/tests/plot/bar.php
Normal file
79
includes/pear/Image/tests/plot/bar.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This is a visual test case, testing the a set of bar plots.
|
||||
*
|
||||
* Test cases:
|
||||
*
|
||||
* 1,1: A "normal" simple plot test
|
||||
*
|
||||
* 1,2: A plot crossing the x-axis (both positive and negative y-values)
|
||||
*
|
||||
* 2,1: A plot with all positive non-zero values
|
||||
*
|
||||
* 2,2: A plot with all negative non-zero values
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
* option) any later version. This library is distributed in the hope that it
|
||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||
* General Public License for more details. You should have received a copy of
|
||||
* the GNU Lesser General Public License along with this library; if not, write
|
||||
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307 USA
|
||||
*
|
||||
* @category Images
|
||||
* @package Image_Graph
|
||||
* @subpackage Tests
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version CVS: $Id: bar.php,v 1.5 2005/08/03 21:21:58 nosey Exp $
|
||||
* @link http://pear.php.net/package/Image_Graph
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(600, 400));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('ttf_font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(7);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
// create the plotarea
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Testing Area Plots', 10)),
|
||||
$Matrix = Image_Graph::factory('Image_Graph_Layout_Matrix', array(2, 2)),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
$DS[0][0] =& Image_Graph::factory('dataset', array(array('A' => 1, 'B' => 2, 'C' => 0, 'D' => 4, 'E' => 3)));
|
||||
$DS[0][1] =& Image_Graph::factory('dataset', array(array('A' => 1, 'B' => -2, 'C' => 1, 'D' => 3, 'E' => -1)));
|
||||
$DS[1][0] =& Image_Graph::factory('dataset', array(array('A' => 2, 'B' => 3, 'C' => 1, 'D' => 4, 'E' => 2)));
|
||||
$DS[1][1] =& Image_Graph::factory('dataset', array(array('A' => -1, 'B' => -3, 'C' => -2, 'D' => -4, 'E' => -1)));
|
||||
|
||||
for ($row = 0; $row < 2; $row++) {
|
||||
for ($col = 0; $col < 2; $col++) {
|
||||
if (isset($DS[$row][$col])) {
|
||||
$Plotarea =& $Matrix->getEntry($row, $col);
|
||||
|
||||
$Plot =& $Plotarea->addNew('bar', $DS[$row][$col]);
|
||||
$Plot->setLineColor('gray');
|
||||
$Plot->setFillColor('blue@0.2');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$Graph->done();
|
||||
?>
|
92
includes/pear/Image/tests/plot/horizontal/area.php
Normal file
92
includes/pear/Image/tests/plot/horizontal/area.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This is a visual test case, testing the a set of horizontal area plots.
|
||||
*
|
||||
* Test cases:
|
||||
*
|
||||
* 1,1: A "normal" simple plot test
|
||||
*
|
||||
* 1,2: A plot crossing the x-axis (both positive and negative y-values)
|
||||
*
|
||||
* 2,1: A plot with all positive non-zero values
|
||||
*
|
||||
* 2,2: A plot with all negative non-zero values
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
* option) any later version. This library is distributed in the hope that it
|
||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||
* General Public License for more details. You should have received a copy of
|
||||
* the GNU Lesser General Public License along with this library; if not, write
|
||||
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307 USA
|
||||
*
|
||||
* @category Images
|
||||
* @package Image_Graph
|
||||
* @subpackage Tests
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version CVS: $Id: area.php,v 1.1 2005/08/27 17:27:32 nosey Exp $
|
||||
* @link http://pear.php.net/package/Image_Graph
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(600, 400));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('ttf_font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(7);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
// create the plotarea
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Testing Area Plots', 10)),
|
||||
$Matrix = Image_Graph::factory('Image_Graph_Layout_Matrix', array(2, 2, false)),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
for ($i = 0; $i < 2; $i++) {
|
||||
for ($j = 0; $j < 2; $j++) {
|
||||
$Matrix->setEntry(
|
||||
$i,
|
||||
$j,
|
||||
Image_Graph::factory(
|
||||
'plotarea',
|
||||
array('Image_Graph_Axis_Category', 'axis', 'horizontal')
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$DS[0][0] =& Image_Graph::factory('dataset', array(array('A' => 1, 'B' => 2, 'C' => 0, 'D' => 4, 'E' => 3)));
|
||||
$DS[0][1] =& Image_Graph::factory('dataset', array(array('A' => 1, 'B' => -2, 'C' => 1, 'D' => 3, 'E' => -1)));
|
||||
$DS[1][0] =& Image_Graph::factory('dataset', array(array('A' => 2, 'B' => 3, 'C' => 1, 'D' => 4, 'E' => 2)));
|
||||
$DS[1][1] =& Image_Graph::factory('dataset', array(array('A' => -1, 'B' => -3, 'C' => -2, 'D' => -4, 'E' => -1)));
|
||||
|
||||
for ($row = 0; $row < 2; $row++) {
|
||||
for ($col = 0; $col < 2; $col++) {
|
||||
if (isset($DS[$row][$col])) {
|
||||
$Plotarea =& $Matrix->getEntry($row, $col);
|
||||
|
||||
$Plot =& $Plotarea->addNew('area', $DS[$row][$col]);
|
||||
$Plot->setLineColor('gray');
|
||||
$Plot->setFillColor('blue@0.2');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$Graph->done();
|
||||
?>
|
92
includes/pear/Image/tests/plot/horizontal/bar.php
Normal file
92
includes/pear/Image/tests/plot/horizontal/bar.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This is a visual test case, testing the a set of horizontal bar plots.
|
||||
*
|
||||
* Test cases:
|
||||
*
|
||||
* 1,1: A "normal" simple plot test
|
||||
*
|
||||
* 1,2: A plot crossing the x-axis (both positive and negative y-values)
|
||||
*
|
||||
* 2,1: A plot with all positive non-zero values
|
||||
*
|
||||
* 2,2: A plot with all negative non-zero values
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
* option) any later version. This library is distributed in the hope that it
|
||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||
* General Public License for more details. You should have received a copy of
|
||||
* the GNU Lesser General Public License along with this library; if not, write
|
||||
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307 USA
|
||||
*
|
||||
* @category Images
|
||||
* @package Image_Graph
|
||||
* @subpackage Tests
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version CVS: $Id: bar.php,v 1.1 2005/08/27 17:27:32 nosey Exp $
|
||||
* @link http://pear.php.net/package/Image_Graph
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(600, 400));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('ttf_font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(7);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
// create the plotarea
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Testing Area Plots', 10)),
|
||||
$Matrix = Image_Graph::factory('Image_Graph_Layout_Matrix', array(2, 2, false)),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
for ($i = 0; $i < 2; $i++) {
|
||||
for ($j = 0; $j < 2; $j++) {
|
||||
$Matrix->setEntry(
|
||||
$i,
|
||||
$j,
|
||||
Image_Graph::factory(
|
||||
'plotarea',
|
||||
array('Image_Graph_Axis_Category', 'axis', 'horizontal')
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$DS[0][0] =& Image_Graph::factory('dataset', array(array('A' => 1, 'B' => 2, 'C' => 0, 'D' => 4, 'E' => 3)));
|
||||
$DS[0][1] =& Image_Graph::factory('dataset', array(array('A' => 1, 'B' => -2, 'C' => 1, 'D' => 3, 'E' => -1)));
|
||||
$DS[1][0] =& Image_Graph::factory('dataset', array(array('A' => 2, 'B' => 3, 'C' => 1, 'D' => 4, 'E' => 2)));
|
||||
$DS[1][1] =& Image_Graph::factory('dataset', array(array('A' => -1, 'B' => -3, 'C' => -2, 'D' => -4, 'E' => -1)));
|
||||
|
||||
for ($row = 0; $row < 2; $row++) {
|
||||
for ($col = 0; $col < 2; $col++) {
|
||||
if (isset($DS[$row][$col])) {
|
||||
$Plotarea =& $Matrix->getEntry($row, $col);
|
||||
|
||||
$Plot =& $Plotarea->addNew('bar', $DS[$row][$col]);
|
||||
$Plot->setLineColor('gray');
|
||||
$Plot->setFillColor('blue@0.2');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$Graph->done();
|
||||
?>
|
91
includes/pear/Image/tests/plot/horizontal/impulse.php
Normal file
91
includes/pear/Image/tests/plot/horizontal/impulse.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This is a visual test case, testing the a set of horizontal impulse plots.
|
||||
*
|
||||
* Test cases:
|
||||
*
|
||||
* 1,1: A "normal" simple plot test
|
||||
*
|
||||
* 1,2: A plot crossing the x-axis (both positive and negative y-values)
|
||||
*
|
||||
* 2,1: A plot with all positive non-zero values
|
||||
*
|
||||
* 2,2: A plot with all negative non-zero values
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
* option) any later version. This library is distributed in the hope that it
|
||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||
* General Public License for more details. You should have received a copy of
|
||||
* the GNU Lesser General Public License along with this library; if not, write
|
||||
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307 USA
|
||||
*
|
||||
* @category Images
|
||||
* @package Image_Graph
|
||||
* @subpackage Tests
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version CVS: $Id: impulse.php,v 1.1 2005/08/27 17:27:32 nosey Exp $
|
||||
* @link http://pear.php.net/package/Image_Graph
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(600, 400));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('ttf_font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(7);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
// create the plotarea
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Testing Area Plots', 10)),
|
||||
$Matrix = Image_Graph::factory('Image_Graph_Layout_Matrix', array(2, 2, false)),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
for ($i = 0; $i < 2; $i++) {
|
||||
for ($j = 0; $j < 2; $j++) {
|
||||
$Matrix->setEntry(
|
||||
$i,
|
||||
$j,
|
||||
Image_Graph::factory(
|
||||
'plotarea',
|
||||
array('Image_Graph_Axis_Category', 'axis', 'horizontal')
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$DS[0][0] =& Image_Graph::factory('dataset', array(array('A' => 1, 'B' => 2, 'C' => 0, 'D' => 4, 'E' => 3)));
|
||||
$DS[0][1] =& Image_Graph::factory('dataset', array(array('A' => 1, 'B' => -2, 'C' => 1, 'D' => 3, 'E' => -1)));
|
||||
$DS[1][0] =& Image_Graph::factory('dataset', array(array('A' => 2, 'B' => 3, 'C' => 1, 'D' => 4, 'E' => 2)));
|
||||
$DS[1][1] =& Image_Graph::factory('dataset', array(array('A' => -1, 'B' => -3, 'C' => -2, 'D' => -4, 'E' => -1)));
|
||||
|
||||
for ($row = 0; $row < 2; $row++) {
|
||||
for ($col = 0; $col < 2; $col++) {
|
||||
if (isset($DS[$row][$col])) {
|
||||
$Plotarea =& $Matrix->getEntry($row, $col);
|
||||
|
||||
$Plot =& $Plotarea->addNew('impulse', $DS[$row][$col]);
|
||||
$Plot->setLineColor('red');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$Graph->done();
|
||||
?>
|
91
includes/pear/Image/tests/plot/horizontal/line.php
Normal file
91
includes/pear/Image/tests/plot/horizontal/line.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This is a visual test case, testing the a set of horizontal line plots.
|
||||
*
|
||||
* Test cases:
|
||||
*
|
||||
* 1,1: A "normal" simple plot test
|
||||
*
|
||||
* 1,2: A plot crossing the x-axis (both positive and negative y-values)
|
||||
*
|
||||
* 2,1: A plot with all positive non-zero values
|
||||
*
|
||||
* 2,2: A plot with all negative non-zero values
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
* option) any later version. This library is distributed in the hope that it
|
||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||
* General Public License for more details. You should have received a copy of
|
||||
* the GNU Lesser General Public License along with this library; if not, write
|
||||
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307 USA
|
||||
*
|
||||
* @category Images
|
||||
* @package Image_Graph
|
||||
* @subpackage Tests
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version CVS: $Id: line.php,v 1.1 2005/08/27 17:27:32 nosey Exp $
|
||||
* @link http://pear.php.net/package/Image_Graph
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(600, 400));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('ttf_font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(7);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
// create the plotarea
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Testing Line Plots', 10)),
|
||||
$Matrix = Image_Graph::factory('Image_Graph_Layout_Matrix', array(2, 2, false)),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
for ($i = 0; $i < 2; $i++) {
|
||||
for ($j = 0; $j < 2; $j++) {
|
||||
$Matrix->setEntry(
|
||||
$i,
|
||||
$j,
|
||||
Image_Graph::factory(
|
||||
'plotarea',
|
||||
array('Image_Graph_Axis_Category', 'axis', 'horizontal')
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$DS[0][0] =& Image_Graph::factory('dataset', array(array('A' => 1, 'B' => 2, 'C' => 0, 'D' => 4, 'E' => 3)));
|
||||
$DS[0][1] =& Image_Graph::factory('dataset', array(array('A' => 1, 'B' => -2, 'C' => 1, 'D' => 3, 'E' => -1)));
|
||||
$DS[1][0] =& Image_Graph::factory('dataset', array(array('A' => 2, 'B' => 3, 'C' => 1, 'D' => 4, 'E' => 2)));
|
||||
$DS[1][1] =& Image_Graph::factory('dataset', array(array('A' => -1, 'B' => -3, 'C' => -2, 'D' => -4, 'E' => -1)));
|
||||
|
||||
for ($row = 0; $row < 2; $row++) {
|
||||
for ($col = 0; $col < 2; $col++) {
|
||||
if (isset($DS[$row][$col])) {
|
||||
$Plotarea =& $Matrix->getEntry($row, $col);
|
||||
|
||||
$Plot =& $Plotarea->addNew('line', $DS[$row][$col]);
|
||||
$Plot->setLineColor('red');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$Graph->done();
|
||||
?>
|
92
includes/pear/Image/tests/plot/horizontal/step.php
Normal file
92
includes/pear/Image/tests/plot/horizontal/step.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This is a visual test case, testing the a set of horizontal step plots.
|
||||
*
|
||||
* Test cases:
|
||||
*
|
||||
* 1,1: A "normal" simple plot test
|
||||
*
|
||||
* 1,2: A plot crossing the x-axis (both positive and negative y-values)
|
||||
*
|
||||
* 2,1: A plot with all positive non-zero values
|
||||
*
|
||||
* 2,2: A plot with all negative non-zero values
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
* option) any later version. This library is distributed in the hope that it
|
||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||
* General Public License for more details. You should have received a copy of
|
||||
* the GNU Lesser General Public License along with this library; if not, write
|
||||
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307 USA
|
||||
*
|
||||
* @category Images
|
||||
* @package Image_Graph
|
||||
* @subpackage Tests
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version CVS: $Id: step.php,v 1.1 2005/08/27 17:27:32 nosey Exp $
|
||||
* @link http://pear.php.net/package/Image_Graph
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(600, 400));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('ttf_font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(7);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
// create the plotarea
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Testing Area Plots', 10)),
|
||||
$Matrix = Image_Graph::factory('Image_Graph_Layout_Matrix', array(2, 2, false)),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
for ($i = 0; $i < 2; $i++) {
|
||||
for ($j = 0; $j < 2; $j++) {
|
||||
$Matrix->setEntry(
|
||||
$i,
|
||||
$j,
|
||||
Image_Graph::factory(
|
||||
'plotarea',
|
||||
array('Image_Graph_Axis_Category', 'axis', 'horizontal')
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$DS[0][0] =& Image_Graph::factory('dataset', array(array('A' => 1, 'B' => 2, 'C' => 0, 'D' => 4, 'E' => 3)));
|
||||
$DS[0][1] =& Image_Graph::factory('dataset', array(array('A' => 1, 'B' => -2, 'C' => 1, 'D' => 3, 'E' => -1)));
|
||||
$DS[1][0] =& Image_Graph::factory('dataset', array(array('A' => 2, 'B' => 3, 'C' => 1, 'D' => 4, 'E' => 2)));
|
||||
$DS[1][1] =& Image_Graph::factory('dataset', array(array('A' => -1, 'B' => -3, 'C' => -2, 'D' => -4, 'E' => -1)));
|
||||
|
||||
for ($row = 0; $row < 2; $row++) {
|
||||
for ($col = 0; $col < 2; $col++) {
|
||||
if (isset($DS[$row][$col])) {
|
||||
$Plotarea =& $Matrix->getEntry($row, $col);
|
||||
|
||||
$Plot =& $Plotarea->addNew('step', $DS[$row][$col]);
|
||||
$Plot->setLineColor('gray');
|
||||
$Plot->setFillColor('blue@0.2');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$Graph->done();
|
||||
?>
|
78
includes/pear/Image/tests/plot/impulse.php
Normal file
78
includes/pear/Image/tests/plot/impulse.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This is a visual test case, testing the a set of impulse plots.
|
||||
*
|
||||
* Test cases:
|
||||
*
|
||||
* 1,1: A "normal" simple plot test
|
||||
*
|
||||
* 1,2: A plot crossing the x-axis (both positive and negative y-values)
|
||||
*
|
||||
* 2,1: A plot with all positive non-zero values
|
||||
*
|
||||
* 2,2: A plot with all negative non-zero values
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
* option) any later version. This library is distributed in the hope that it
|
||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||
* General Public License for more details. You should have received a copy of
|
||||
* the GNU Lesser General Public License along with this library; if not, write
|
||||
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307 USA
|
||||
*
|
||||
* @category Images
|
||||
* @package Image_Graph
|
||||
* @subpackage Tests
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version CVS: $Id: impulse.php,v 1.5 2005/08/03 21:21:58 nosey Exp $
|
||||
* @link http://pear.php.net/package/Image_Graph
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(600, 400));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('ttf_font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(7);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
// create the plotarea
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Testing Area Plots', 10)),
|
||||
$Matrix = Image_Graph::factory('Image_Graph_Layout_Matrix', array(2, 2)),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
$DS[0][0] =& Image_Graph::factory('dataset', array(array('A' => 1, 'B' => 2, 'C' => 0, 'D' => 4, 'E' => 3)));
|
||||
$DS[0][1] =& Image_Graph::factory('dataset', array(array('A' => 1, 'B' => -2, 'C' => 1, 'D' => 3, 'E' => -1)));
|
||||
$DS[1][0] =& Image_Graph::factory('dataset', array(array('A' => 2, 'B' => 3, 'C' => 1, 'D' => 4, 'E' => 2)));
|
||||
$DS[1][1] =& Image_Graph::factory('dataset', array(array('A' => -1, 'B' => -3, 'C' => -2, 'D' => -4, 'E' => -1)));
|
||||
|
||||
for ($row = 0; $row < 2; $row++) {
|
||||
for ($col = 0; $col < 2; $col++) {
|
||||
if (isset($DS[$row][$col])) {
|
||||
$Plotarea =& $Matrix->getEntry($row, $col);
|
||||
|
||||
$Plot =& $Plotarea->addNew('impulse', $DS[$row][$col]);
|
||||
$Plot->setLineColor('red');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$Graph->done();
|
||||
?>
|
78
includes/pear/Image/tests/plot/line.php
Normal file
78
includes/pear/Image/tests/plot/line.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This is a visual test case, testing the a set of line plots.
|
||||
*
|
||||
* Test cases:
|
||||
*
|
||||
* 1,1: A "normal" simple plot test
|
||||
*
|
||||
* 1,2: A plot crossing the x-axis (both positive and negative y-values)
|
||||
*
|
||||
* 2,1: A plot with all positive non-zero values
|
||||
*
|
||||
* 2,2: A plot with all negative non-zero values
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
* option) any later version. This library is distributed in the hope that it
|
||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||
* General Public License for more details. You should have received a copy of
|
||||
* the GNU Lesser General Public License along with this library; if not, write
|
||||
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307 USA
|
||||
*
|
||||
* @category Images
|
||||
* @package Image_Graph
|
||||
* @subpackage Tests
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version CVS: $Id: line.php,v 1.5 2005/08/03 21:21:58 nosey Exp $
|
||||
* @link http://pear.php.net/package/Image_Graph
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(600, 400));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('ttf_font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(7);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
// create the plotarea
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Testing Line Plots', 10)),
|
||||
$Matrix = Image_Graph::factory('Image_Graph_Layout_Matrix', array(2, 2)),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
$DS[0][0] =& Image_Graph::factory('dataset', array(array('A' => 1, 'B' => 2, 'C' => 0, 'D' => 4, 'E' => 3)));
|
||||
$DS[0][1] =& Image_Graph::factory('dataset', array(array('A' => 1, 'B' => -2, 'C' => 1, 'D' => 3, 'E' => -1)));
|
||||
$DS[1][0] =& Image_Graph::factory('dataset', array(array('A' => 2, 'B' => 3, 'C' => 1, 'D' => 4, 'E' => 2)));
|
||||
$DS[1][1] =& Image_Graph::factory('dataset', array(array('A' => -1, 'B' => -3, 'C' => -2, 'D' => -4, 'E' => -1)));
|
||||
|
||||
for ($row = 0; $row < 2; $row++) {
|
||||
for ($col = 0; $col < 2; $col++) {
|
||||
if (isset($DS[$row][$col])) {
|
||||
$Plotarea =& $Matrix->getEntry($row, $col);
|
||||
|
||||
$Plot =& $Plotarea->addNew('line', $DS[$row][$col]);
|
||||
$Plot->setLineColor('red');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$Graph->done();
|
||||
?>
|
79
includes/pear/Image/tests/plot/step.php
Normal file
79
includes/pear/Image/tests/plot/step.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This is a visual test case, testing the a set of step plots.
|
||||
*
|
||||
* Test cases:
|
||||
*
|
||||
* 1,1: A "normal" simple plot test
|
||||
*
|
||||
* 1,2: A plot crossing the x-axis (both positive and negative y-values)
|
||||
*
|
||||
* 2,1: A plot with all positive non-zero values
|
||||
*
|
||||
* 2,2: A plot with all negative non-zero values
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
* option) any later version. This library is distributed in the hope that it
|
||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||
* General Public License for more details. You should have received a copy of
|
||||
* the GNU Lesser General Public License along with this library; if not, write
|
||||
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307 USA
|
||||
*
|
||||
* @category Images
|
||||
* @package Image_Graph
|
||||
* @subpackage Tests
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version CVS: $Id: step.php,v 1.5 2005/08/03 21:21:58 nosey Exp $
|
||||
* @link http://pear.php.net/package/Image_Graph
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(600, 400));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('ttf_font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(7);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
// create the plotarea
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Testing Area Plots', 10)),
|
||||
$Matrix = Image_Graph::factory('Image_Graph_Layout_Matrix', array(2, 2)),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
$DS[0][0] =& Image_Graph::factory('dataset', array(array('A' => 1, 'B' => 2, 'C' => 0, 'D' => 4, 'E' => 3)));
|
||||
$DS[0][1] =& Image_Graph::factory('dataset', array(array('A' => 1, 'B' => -2, 'C' => 1, 'D' => 3, 'E' => -1)));
|
||||
$DS[1][0] =& Image_Graph::factory('dataset', array(array('A' => 2, 'B' => 3, 'C' => 1, 'D' => 4, 'E' => 2)));
|
||||
$DS[1][1] =& Image_Graph::factory('dataset', array(array('A' => -1, 'B' => -3, 'C' => -2, 'D' => -4, 'E' => -1)));
|
||||
|
||||
for ($row = 0; $row < 2; $row++) {
|
||||
for ($col = 0; $col < 2; $col++) {
|
||||
if (isset($DS[$row][$col])) {
|
||||
$Plotarea =& $Matrix->getEntry($row, $col);
|
||||
|
||||
$Plot =& $Plotarea->addNew('step', $DS[$row][$col]);
|
||||
$Plot->setLineColor('gray');
|
||||
$Plot->setFillColor('blue@0.2');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$Graph->done();
|
||||
?>
|
39
includes/pear/Image/tests/png.php
Normal file
39
includes/pear/Image/tests/png.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This is a visual test case, testing canvas fundamental canvas functionality.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
* option) any later version. This library is distributed in the hope that it
|
||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||
* General Public License for more details. You should have received a copy of
|
||||
* the GNU Lesser General Public License along with this library; if not, write
|
||||
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307 USA
|
||||
*
|
||||
* @category Images
|
||||
* @package Image_Canvas
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version CVS: $Id: png.php,v 1.2 2005/08/03 21:17:48 nosey Exp $
|
||||
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
|
||||
*/
|
||||
|
||||
// SPECIFY HERE WHERE A TRUETYPE FONT CAN BE FOUND
|
||||
$testFont = 'c:/windows/fonts/Arial.ttf';
|
||||
|
||||
require_once 'Image/Canvas.php';
|
||||
|
||||
$canvas =& Image_Canvas::factory('png', array('width' => 600, 'height' => 600));
|
||||
|
||||
require_once './canvas_body.php';
|
||||
|
||||
?>
|
39
includes/pear/Image/tests/svg.php
Normal file
39
includes/pear/Image/tests/svg.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This is a visual test case, testing canvas fundamental canvas functionality.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
* option) any later version. This library is distributed in the hope that it
|
||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||
* General Public License for more details. You should have received a copy of
|
||||
* the GNU Lesser General Public License along with this library; if not, write
|
||||
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307 USA
|
||||
*
|
||||
* @category Images
|
||||
* @package Image_Canvas
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version CVS: $Id: svg.php,v 1.2 2005/08/03 21:17:48 nosey Exp $
|
||||
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
|
||||
*/
|
||||
|
||||
// SPECIFY HERE WHERE A TRUETYPE FONT CAN BE FOUND
|
||||
$testFont = 'c:/windows/fonts/Arial.ttf';
|
||||
|
||||
require_once 'Image/Canvas.php';
|
||||
|
||||
$canvas =& Image_Canvas::factory('svg', array('width' => 600, 'height' => 600));
|
||||
|
||||
require_once './canvas_body.php';
|
||||
|
||||
?>
|
109
includes/pear/Image/tests/text.php
Normal file
109
includes/pear/Image/tests/text.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This is a visual test case, testing canvas support for text output.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
* option) any later version. This library is distributed in the hope that it
|
||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||
* General Public License for more details. You should have received a copy of
|
||||
* the GNU Lesser General Public License along with this library; if not, write
|
||||
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307 USA
|
||||
*
|
||||
* @category Images
|
||||
* @package Image_Canvas
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version CVS: $Id: text.php,v 1.2 2005/08/03 21:17:48 nosey Exp $
|
||||
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
|
||||
*/
|
||||
|
||||
require_once 'Image/Canvas.php';
|
||||
|
||||
$canvas =& Image_Canvas::factory(
|
||||
'png',
|
||||
array('width' => 300, 'height' => 200)
|
||||
);
|
||||
|
||||
$canvas->setLineColor('black');
|
||||
$canvas->rectangle(array('x0' => 0, 'y0' => 0, 'x1' => $canvas->getWidth() - 1, 'y1' => $canvas->getHeight() - 1));
|
||||
|
||||
$canvas->setLineColor('lightgrey@0.3');
|
||||
$canvas->rectangle(array('x0' => 10, 'y0' => 10, 'x1' => 290, 'y1' => 190));
|
||||
$canvas->setLineColor('lightgrey@0.3');
|
||||
$canvas->line(array('x0' => 10, 'y0' => 100, 'x1' => 290, 'y1' => 100));
|
||||
$canvas->setLineColor('lightgrey@0.3');
|
||||
$canvas->rectangle(array('x0' => 150, 'y0' => 10, 'x1' => 150, 'y1' => 190));
|
||||
|
||||
$font = array('name' => 'Verdana', 'size' => 10);
|
||||
|
||||
$align = array(
|
||||
array(
|
||||
array('horizontal' => 'left', 'vertical' => 'top'),
|
||||
array('horizontal' => 'center', 'vertical' => 'top'),
|
||||
array('horizontal' => 'right', 'vertical' => 'top')
|
||||
),
|
||||
array(
|
||||
array('horizontal' => 'left', 'vertical' => 'center'),
|
||||
array('horizontal' => 'center', 'vertical' => 'center'),
|
||||
array('horizontal' => 'right', 'vertical' => 'center')
|
||||
),
|
||||
array(
|
||||
array('horizontal' => 'left', 'vertical' => 'bottom'),
|
||||
array('horizontal' => 'center', 'vertical' => 'bottom'),
|
||||
array('horizontal' => 'right', 'vertical' => 'bottom')
|
||||
)
|
||||
);
|
||||
|
||||
for ($row = 0; $row < 3; $row++) {
|
||||
for ($col = 0; $col < 3; $col++) {
|
||||
$x = 10 + $col * 140;
|
||||
$y = 10 + $row * 90;
|
||||
|
||||
switch ($row) {
|
||||
case 0:
|
||||
$text = 'Top';
|
||||
break;
|
||||
case 1:
|
||||
$text = 'Center';
|
||||
break;
|
||||
case 2:
|
||||
$text = 'Bottom';
|
||||
break;
|
||||
}
|
||||
switch ($col) {
|
||||
case 0:
|
||||
$text .= "\n" . 'Left';
|
||||
break;
|
||||
case 1:
|
||||
if ($row !== 1) {
|
||||
$text .= "\n" . 'Center';
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
$text .= "\n" . 'Right';
|
||||
break;
|
||||
}
|
||||
|
||||
$canvas->setLineColor('red');
|
||||
$canvas->line(array('x0' => $x - 5, 'y0' => $y, 'x1' => $x + 5, 'y1' => $y));
|
||||
$canvas->setLineColor('red');
|
||||
$canvas->line(array('x0' => $x, 'y0' => $y - 5, 'x1' => $x, 'y1' => $y + 5));
|
||||
|
||||
$canvas->setFont($font);
|
||||
$canvas->addText(array('x' => $x, 'y' => $y, 'text' => $text, 'alignment' => $align[$row][$col]));
|
||||
}
|
||||
}
|
||||
|
||||
$canvas->show();
|
||||
|
||||
?>
|
Reference in New Issue
Block a user