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

Re: [svg-developers] Create new svg from a portion of an existing svg

Expand Messages
  • ddailey
    ... Let s call your bounding rectangle the Big Box. I m assuming that you don t just want to rely on using the Big Box as a clipPath for the other content,
    Message 1 of 3 , Aug 31, 2006
      Tim Hesse wrote:

      > I need to "extract" the elements within a bounding rectangle which
      > would entail slicing lines and polys that are in the rectangle but
      > run over the edges of the bounding rectangle.
      >
      > Any help for things to look at would be greatly appreciated, tia

      Let's call your "bounding rectangle" the Big Box.

      I'm assuming that you don't just want to rely on using the Big Box as a
      clipPath for the other content, since that would solve the problem (in terms
      of drawing their intersection) but without having those things available for
      subsequent data analysis.

      I've never really worked on this problem but I think I'd proceed as follows:

      1. Find all the drawn objects in the SVGDocument. I'd probably loop through
      the W3C list of nodetypes of drawn objects :
      'path', 'text', 'rect', 'circle', 'ellipse', 'line', 'polyline', 'polygon',
      'image' and 'use'. I'd add <g> to that list and then do a
      getElementsByTagName on each type of rendered object until I have a big list
      of just the objects that are drawn on the canvas, hence avoiding <filter>
      and <def> and the like.

      2. Find the bounding box of each drawn object using getBBox()

      2a. If the drawn object is entirely inside the BigBox then it's easy
      2b If it's entirely outside the BigBox, then its easy
      2c. If its partly inside, then calculate the intersection of the box with
      the object using the advice of Kevin Lindsey at
      http://www.kevlindev.com/gui/math/intersection/index.htm
      2d. If the object we're looking at is a text object, then ick -- give it to
      a student and let them work on it.

      I'll be interested to see if others suggest something more straightforward,
      since this is just what came to mind.

      David
    • Tim Hesse
      thanks for the response! i am sending the svg to adobe document server for output as PDF. What i was trying to accomplish was a print window type
      Message 2 of 3 , Sep 1, 2006
        thanks for the response!

        i am sending the svg to adobe document server for output as PDF.
        What i was trying to accomplish was a "print window" type
        functionality.

        After testing some other stuff, I realized all I need to do is set
        the viewbox of the source svg for pdf output to be the area that is
        visible onscreen ... very simple and a huge DOH! on my part.

        Thanks again for you time
        tim

        --- In svg-developers@yahoogroups.com, "ddailey" <ddailey@...> wrote:
        >
        >
        > Tim Hesse wrote:
        >
        > > I need to "extract" the elements within a bounding rectangle which
        > > would entail slicing lines and polys that are in the rectangle but
        > > run over the edges of the bounding rectangle.
        > >
        > > Any help for things to look at would be greatly appreciated, tia
        >
        > Let's call your "bounding rectangle" the Big Box.
        >
        > I'm assuming that you don't just want to rely on using the Big Box
        as a
        > clipPath for the other content, since that would solve the problem
        (in terms
        > of drawing their intersection) but without having those things
        available for
        > subsequent data analysis.
        >
        > I've never really worked on this problem but I think I'd proceed as
        follows:
        >
        > 1. Find all the drawn objects in the SVGDocument. I'd probably loop
        through
        > the W3C list of nodetypes of drawn objects :
        > 'path', 'text', 'rect', 'circle', 'ellipse', 'line', 'polyline', 'po
        lygon',
        > 'image' and 'use'. I'd add <g> to that list and then do a
        > getElementsByTagName on each type of rendered object until I have a
        big list
        > of just the objects that are drawn on the canvas, hence avoiding
        <filter>
        > and <def> and the like.
        >
        > 2. Find the bounding box of each drawn object using getBBox()
        >
        > 2a. If the drawn object is entirely inside the BigBox then it's easy
        > 2b If it's entirely outside the BigBox, then its easy
        > 2c. If its partly inside, then calculate the intersection of the
        box with
        > the object using the advice of Kevin Lindsey at
        > http://www.kevlindev.com/gui/math/intersection/index.htm
        > 2d. If the object we're looking at is a text object, then ick --
        give it to
        > a student and let them work on it.
        >
        > I'll be interested to see if others suggest something more
        straightforward,
        > since this is just what came to mind.
        >
        > David
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.