Loading ...
Sorry, an error occurred while loading the content.

Re: [svg-developers] Drag group of elements and line end

Expand Messages
  • David Leunen
    Hey, The only solution I can think ... Yes there is. Are you aware of the SVGPathElement? http://www.w3.org/TR/SVG/paths.html#InterfaceSVGPathElement
    Message 1 of 5 , Mar 8, 2009
    • 0 Attachment
      Hey,


      The only solution I can think
      > of when using a path is to perform some string replacements on the 'd'
      > attribute (locate the 'M' command, change the points). Something which
      > isn't very clean. Is there any other way to just replace the 'M' command?


      Yes there is. Are you aware of the SVGPathElement?
      http://www.w3.org/TR/SVG/paths.html#InterfaceSVGPathElement
      http://xmlgraphics.apache.org/batik/javadoc/org/apache/batik/dom/svg/SVGOMPathElement.html
      You can get its pathSegList and modify it without having to parse the 'd'
      attribute yourself.




      > The second issue is getting the path element in the first place. I take
      > it there's no easier way then to a) give each line a special 'id', one
      > which can be determined by the 'id' of the car group or b) add both the
      > car group and the path to a second group and walk the DOM until it finds
      > a path in the same group as the car group. Too bad SVG doesn't support
      > some kind of snapping behaviour ;-)


      What do you mean exactly ?
      By using SMIL (batik does support it pretty well) you can use an
      <animationMotion> and a <mpath> linked to your dynamic path.
      See this example in Batik or Opera :
      http://www.w3.org/TR/SVG/images/animate/animMotion01.svg
      It's from here : http://www.w3.org/TR/SVG/animate.html#AnimateMotionElement
      But yes, in order to link your car to the animation path, you have to give
      the path an id.


      cheers.

      David


      [Non-text portions of this message have been removed]
    • Age Bosma
      ... No, I did not know about the SVGPathElement. There are just too many options :-S Many thanks, that was what I was looking for. ... What I meant was having
      Message 2 of 5 , Mar 10, 2009
      • 0 Attachment
        2009/3/8 David Leunen <leunen.d@...>:
        > Hey,
        >
        >
        > The only solution I can think
        >> of when using a path is to perform some string replacements on the 'd'
        >> attribute (locate the 'M' command, change the points). Something which
        >> isn't very clean. Is there any other way to just replace the 'M' command?
        >
        >
        > Yes there is. Are you aware of the SVGPathElement?
        > http://www.w3.org/TR/SVG/paths.html#InterfaceSVGPathElement
        > http://xmlgraphics.apache.org/batik/javadoc/org/apache/batik/dom/svg/SVGOMPathElement.html
        > You can get its pathSegList and modify it without having to parse the 'd'
        > attribute yourself.
        >

        No, I did not know about the SVGPathElement. There are just too many
        options :-S Many thanks, that was what I was looking for.

        >
        >
        >
        >> The second issue is getting the path element in the first place. I take
        >> it there's no easier way then to a) give each line a special 'id', one
        >> which can be determined by the 'id' of the car group or b) add both the
        >> car group and the path to a second group and walk the DOM until it finds
        >> a path in the same group as the car group. Too bad SVG doesn't support
        >> some kind of snapping behaviour ;-)
        >
        >
        > What do you mean exactly ?

        What I meant was having the option in SVG to say: This path point
        should always be attached to this path/location of this element. This
        way, not matter what happens to the element the path point is attached
        to, the point will always move along with the element. You wouldn't
        have to do it manually any more.

        Age
      Your message has been successfully submitted and would be delivered to recipients shortly.