Home » XML » XML_SVG » Bug #7959
RadialGradient support
Details
| Request #7959 | RadialGradient support |
|---|---|
| Submitted | 2006-06-21 22:02 UTC |
| From | frederic dot jacquot at insa-lyon dot fr |
| Assigned | chagenbu |
| Status | Closed |
| Package | XML_SVG |
| PHP Version | 5.1.2 |
| OS | Linux |
| Roadmaps | (Not assigned) |
Comments
[2006-06-21 22:02 UTC] frederic dot jacquot at insa-lyon dot fr
Description:
------------
I added two classes to implement radial gradient. Nothing very difficult, but it might help those who, like me, wanted to use them.
/**
* XML_SVG_RadialGradient
*
* @package XML_SVG
*/
class XML_SVG_RadialGradient extends XML_SVG_Element {
var $_desc;
function printElement()
{
echo '<radialGradient';
$this->printParams('id', 'cx', 'cy', 'r', 'fx', 'fy');
echo '>' . $this->_desc;
parent::printElement();
echo "</radialGradient>\n";
}
}
/**
* XML_SVG_Stop
*
* @package XML_SVG
*/
class XML_SVG_Stop extends XML_SVG_Element {
var $_desc;
function printElement()
{
echo '<stop';
$this->printParams('offset', 'style');
echo '>' . $this->_desc;
parent::printElement();
echo "</stop>\n";
}
}
Test script:
---------------
$defs = &new XML_SVG_Defs();
$gradient = &new XML_SVG_RadialGradient(array('id' => 'grey_none', 'cx' => '50%', 'cy' => '50%', 'r' => '50%', 'fx' => '50%', 'fy' => '50%'));
$stop = &new XML_SVG_Stop(array('offset' => '90%', 'style' => 'stop-color:rgb(0,0,0);stop-opacity:0.5'));
$gradient->addChild($stop);
$stop = &new XML_SVG_Stop(array('offset' => '100%', 'style' => 'stop-color:rgb(0,0,0);stop-opacity:0'));
$gradient->addChild($stop);
$defs->addChild($gradient);
$this->svg->addChild($defs);
$shadow = &new XML_SVG_CIRCLE(array('cx' => 170, 'cy' => 170, 'r' => 150, 'style' => 'fill:url(#grey_none)'));
$this->svg->addChild($shadow);
[2006-06-22 04:31 UTC] chagenbu at php dot net
Tweaked a bit and committed - thanks!
[2006-06-22 13:41 UTC] frederic dot jacquot at insa-lyon dot fr
Great! Thanks.