Thanks philippe!
It does work great in extracting the points from the path as I wanted.one thing i would like to know however, will it only abstract the M points and not the rest? since most path drawn by maps would have multiple joints of path in a single drawn path. thanks again! i'm trying it as i type =) --- In svg-developers@yahoogroups.com, Philippe Lhoste <[EMAIL PROTECTED]> wrote: > e2mieluv wrote: > > i do hope you guys could help me with this. Kevin's path parser is > > really useful in extracting multiple path.however,i'm finding > > difficulty to extract the path that has been retrieve by the path > > parser into 1 points. > > > > in the example it uses tspan which to manipulate text and 1 more thing > > i forgot. but how to extract the path? > > > > ex. path extracted M a,b L c,d > > would like to extract it as point a,b to be save in an array. > > anyone knows how the path parser could work that way? please help me, > > thanks! > > > > > > the example prog. > > > > <?xml version="1.0" encoding="utf-8" standalone="no"?> > > <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" > > "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> > > <svg onload="init(evt)" > > xmlns="http://www.w3.org/2000/svg" > > xmlns:xlink="http://www.w3.org/1999/xlink"> > > <script type="text/ecmascript" xlink:href="path_parser.js.gz"/> > > <script type="text/ecmascript" xlink:href="SampleHandler.js"/> > > <script type="text/ecmascript"><![CDATA[ > > var stdout; > > var parser = new PathParser(); > > > > function init(e) { > > if ( window.svgDocument == null ) > > svgDocument = e.target.ownerDocument; > > > > stdout = svgDocument.getElementById("stdout"); > > > > parser.setHandler(new SampleHandler()); > > parse("path1"); > > parse("path2"); > > parse("path3"); > var r = ''; > for (var i = 0; i < mNb; i++) { r += mArray[i] + ','; } > alert(r); > > } > > > > function parse(id) { > > var source = svgDocument.getElementById(id); > > var pathData = source.getAttributeNS(null, "d"); > > > > println("Parsing: " + pathData); > > parser.parseData(pathData); > > } > > > > function println(msg) { > > > > /*var tspan = svgDocument.createElementNS (Svg.NAMESPACE, "tspan"); > > tspan.setAttributeNS(null, "x", "3"); > > tspan.setAttributeNS(null, "dy", "1em"); > > tspan.appendChild( svgDocument.createTextNode(msg) ); > > stdout.appendChild(tspan);*/ > > } > var mArray = {}; > var mNb = 0; > SampleHandler.prototype.movetoAbs = function(x, y) { > mArray[mNb++] = x; > mArray[mNb++] = y; > }; > > ]]></script> > > <g> > > <path id="path1" > > d="M300,25 L450,100" > > stroke="gold" stroke-width="5" > > fill="none"/> > > <path id="path2" > > d="M450,100 L250,150" > > stroke="blue" stroke-width="5" fill="none"/> > > <path id="path3" > > d="M250,150 L300,25" > > stroke="blue" stroke-width="5" fill="none"/> > > </g> > > <text id="stdout"> </text> > > </svg> > > OK, I am not sure of what you can do. > Perhaps it would be easier to use Kevin's PathData object than PathParser. > > But if you want to stick to it for any reason, either you drop the > SampleHandler to replace it with your own code, similar but more on the > aim, or you do as I did above: override the > SampleHandler.prototype.movetoAbs function to write your own. > > This function is called each time a M command is found, and there I > store the corresponding two coordinates in an array. > At the end, I just display the content of the array. > > HTH. > > -- > Philippe Lhoste > -- (near) Paris -- France > -- http://Phi.Lho.free.fr > -- For servers mangling my From and Reply-To fields, > -- please send private answers to PhiLho(a)GMX.net > -- -- -- -- -- -- -- -- -- -- -- -- -- -- ----- To unsubscribe send a message to: [EMAIL PROTECTED] -or- visit http://groups.yahoo.com/group/svg-developers and click "edit my membership" ---- Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/svg-developers/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/