From c3966e5501b24fbf75a3b7cfe331bf68262771c5 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 11 Feb 2006 21:15:59 +0000 Subject: [PATCH] Use scaling factors instead of explicit height and widths --- graph_pie.php | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/graph_pie.php b/graph_pie.php index d92338f..db1e13f 100644 --- a/graph_pie.php +++ b/graph_pie.php @@ -91,7 +91,7 @@ class Graph_Pie { $this->registry =& $registry; - $this->image = imagecreate($this->dimensions['width'], $this->dimensions['height']); + $this->set_scale(0); } // ################################################################### @@ -187,18 +187,31 @@ class Graph_Pie // ################################################################### /** - * Sets the width and height of an image + * Sets the width and height by using scale factors of 550x350; you + * can specify a positive value to multiply by that many times or a + * negative one to divide * * @access public * - * @param integer Width (pixels) - * @param integer Height (pixels) + * @param float Scale factor */ - function set_dimensions($width, $height) + function set_scale($scale) { - $this->dimensions['width'] = intval($width); - $this->dimensions['height'] = intval($height); + $this->dimensions['width'] = 550; + $this->dimensions['height'] = 350; + if ($scale > 0) + { + $this->dimensions['width'] *= $scale; + $this->dimensions['height'] *= $scale; + } + else if ($scale < 0) + { + $scale = abs($scale); + $this->dimensions['width'] /= $scale; + $this->dimensions['height'] /= $scale; + } + $this->image = imagecreate($this->dimensions['width'], $this->dimensions['height']); } -- 2.22.5