W3C home > Mailing lists > Public > www-svg@w3.org > July 2001

Re: Is there away to get a specific x,y coordinate from <path>

From: Robert DiBlasi <r_diblasi@hotmail.com>
Date: Fri, 06 Jul 2001 04:02:39 -0000
To: www-svg@w3.org
Message-ID: <F109ddXAarwgAP93s250000225d@hotmail.com>
SVG community,

[Sorry for cross posting this message]

I have been trying to figure out if it is possible to just change one
coordinate (x,y) or one point in a coordinate (just the x or just the
y)in path data ( or any of the path data commands) in the path
element?

I think Stefan asked a question that was very importaint.....and no
one has been able to answer it..... is his question...(I hope Chris
and Jon are reading today :-)

.. after having written this little piece of code, now it is my turn
to ask questions here.

function ChangePath(e)
{
  if (e.target.nodeType == "path")
  {
     var path = e.target; // SVGPathElement here ..
     var seglist = path.pathSegList; // via SVGAnimatedPathData ifc
     var seg = seglist.getItem(3); // 4th segment (lineToAbs) ..
     seglist.replaceItem(          // replace whole seg.
        path.createSVGPathSegLinetoAbs(  // create new seg.
           seg.x,                        // old x value
           300                           // new y value
        ), 3);                           // 4th seg.
  }
}

1) observing the *readonly* attribute of pathSegList in ..
interface SVGAnimatedPathData {
  readonly attribute SVGPathSegList   pathSegList;
  readonly attribute SVGPathSegList   normalizedPathSegList;
  readonly attribute SVGPathSegList   animatedPathSegList;
  readonly attribute SVGPathSegList   animatedNormalizedPathSegList;
};

.. the above code will not work, since we can use only *readonly*
object properties and methods of 'seglist'. seglist.getItem(..) and
seglist.replaceItem(..) are not *readonly* and will raise an
exception .. at least with my understanding of interface inheritance.
maybe there is still another way to change path data with svg dom.

2) why hasn't 'SVGPathSegList' the same familiar syntax
as 'NodeList'? i find it very confusing with different dom lists
having to use item() the first time and getItem() the next time. this
should really be changed


....oops....he has two questions.....even better ;-)

To follow the complete discussion in yahoo
http://groups.yahoo.com/group/svg-developers

....here are the message numbers in the order that sense:
(just type in the number in the "Msg#" finder form)
4711
4718
4731
4722
4732
4737

I have looked and apparently missed the way to do this.....so did
Stefan ( who know how to code better than me :-) ....

so does any one know the anwser.....is it part of the SVG DOM...IMHO
it should be since it puts so much information in the attribute value
<duck>....sorry had to say it....it is a good solution to keep the
SVG file size down ......but please tell me there is a "SVG" solution
to this problem....not a "hack" that someone has thought of...it
should be in the specification <duck_again>

We all learn by sharing what we know
Robert A. DiBlasi


--- In svg-developers@y..., goessner@m... wrote:
>sorry robert,
>
>.. i should have known, that you are very familiar to the svg
spec ..
>
> > IDL Definition > interface SVGPathSegMovetoAbs : SVGPathSeg { >          
>   attribute float   x;
> >                        // raises DOMException on setting
> >            attribute float   y;
> >                        // raises DOMException on setting
> > };
> > Execption:
> > DOMException   NO_MODIFICATION_ALLOWED_ERR: Raised on an attempt
to
> > change the value of a readonly attribute.  > > > I am I to understand 
>this as: the interface to uses if I want to > access/manipulate the M path 
>command?  The interface states that > it "raises DOMException on setting" 
>....so does this mean I can
not
> > use these interface to change the X of Y end point ?
>
>.. oops, i never looked so close to those interfaces. indeed we are not 
>able to change path segment data with these interfaces. so one possible way 
>might be - at the first look ..
>
>function ChangePath(e)
>{
>   if (e.target.nodeType == "path")
>   {
>      var path = e.target; // SVGPathElement here ..
>      var seglist = path.pathSegList; // via SVGAnimatedPathData ifc
>      var seg = seglist.getItem(3); // 4th segment (lineToAbs) ..
>      seglist.replaceItem(          // replace whole seg.
>         path.createSVGPathSegLinetoAbs(  // create new seg.
>            seg.x,                        // old x value
>            300                           // new y value
>         ), 3);                           // 4th seg.
>   }
>}
>
>.. after having written this little piece of code, now it is my
turn
>to ask questions here.
>
>1) observing the *readonly* attribute of pathSegList in ..
>interface SVGAnimatedPathData {   readonly attribute SVGPathSegList   
>pathSegList;
>   readonly attribute SVGPathSegList   normalizedPathSegList;
>   readonly attribute SVGPathSegList   animatedPathSegList;
>   readonly attribute SVGPathSegList   animatedNormalizedPathSegList;
>};
>
>.. the above code will not work, since we can use only *readonly* object 
>properties and methods of 'seglist'. seglist.getItem(..) and 
>seglist.replaceItem(..) are not *readonly* and will raise an exception .. 
>at least with my understanding of interface
inheritance.
>maybe there is still another way to change path data with svg dom.
>
>2) why hasn't 'SVGPathSegList' the same familiar syntax as 'NodeList'? i 
>find it very confusing with different dom lists having to use item() the 
>first time and getItem() the next time.
this
>should really be changed.
>
>--
>stefan




_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com
Received on Friday, 6 July 2001 00:03:10 GMT

This archive was generated by hypermail 2.3.1 : Friday, 8 March 2013 15:54:20 GMT