You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by David Gellman <ga...@hotmail.com> on 2004/02/12 23:06:01 UTC

rasterizing files with scripted elements

I'm just getting started with scripting in SVG. My files render perfectly in 
squiggle, but the batik-rasterizer ignores the scripted elements and renders 
just the blank canvas. When I rasterize files without scripting, everything 
works fine.

I'm sure I must just be missing something basic.

Here is an example of how I'm scripting elements. Thanks for any advice you 
can give.

--David

<?xml version="1.0"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
              "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100px" height="100px"
     xmlns="http://www.w3.org/2000/svg" version="1.1"
onload="makeBallSimple(evt)">
  <title>Example scripted element</title>
  <desc>An example of scripting an element with ecmascript in SVG.</desc>

    <script type="text/ecmascript"> <![CDATA[
	var svgns = "http://www.w3.org/2000/svg";

	var ballRad = 20;
	var ballFill = "#999999";
	var ballOutline = "#333333";

	function makeBallSimple(evt) {
	if ( window.svgDocument == null )
	        svgDocument = evt.target.ownerDocument;

                        var shape = svgDocument.createElementNS(svgns, 
"circle");
                        shape.setAttributeNS(null, "cx", 2*ballRad + 4);
                        shape.setAttributeNS(null, "cy", 2*ballRad + 4);
                        shape.setAttributeNS(null, "r",  ballRad);
                        shape.setAttributeNS(null, "fill", ballFill);
                        shape.setAttributeNS(null, "stroke", ballOutline);
                        shape.setAttributeNS(null, "stroke-width", 2);

    svgDocument.documentElement.appendChild(shape);
    }
   ]]> </script>
</svg>

_________________________________________________________________
Keep up with high-tech trends here at "Hook'd on Technology." 
http://special.msn.com/msnbc/hookedontech.armx


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: rasterizing files with scripted elements

Posted by Cameron McCormack <ca...@aka.mcc.id.au>.
Hi David.

David Gellman:
> I'm just getting started with scripting in SVG. My files render perfectly 
> in squiggle, but the batik-rasterizer ignores the scripted elements and 
> renders just the blank canvas. When I rasterize files without scripting, 
> everything works fine.
> 
> I'm sure I must just be missing something basic.
> 
> Here is an example of how I'm scripting elements. Thanks for any advice you 
> can give.

Are you running the Batik rasterizer with the -onload option?  This will
cause the rasterizer to run the document's onload script before
rasterizing.  Normally, no scripts are run.

Cameron

-- 
Cameron McCormack
|  Web: http://mcc.id.au/
|  ICQ: 26955922

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org