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

Accessing Paths based on bounds.

Expand Messages
  • wrinkledcheese
    Hello all, I m having some difficulty thinking of a way to do this without a lot of programming, and I figured a group dedicated to SVG development might be
    Message 1 of 3 , Mar 28, 2013
    • 0 Attachment
      Hello all,

      I'm having some difficulty thinking of a way to do this without a lot of programming, and I figured a group dedicated to SVG development might be some assistance.

      I want to access all paths that fall within a certain bounds.

      Let's say I have an SVG that is 20,000 x 20,000 pixels and I have a 'view bounds' of 2800,2400 - 3600,2800(x0,y0 - x1,y1 opposing corners. Either top,left bottom,right or bottom,right - top,left, doesn't matter because I can get either)

      What I want to be able to do is something along the lines of this pseudo code:

      for the given svg g element
      return all path elements for which the d(path data) falls within the bounds of topLeft(2800,2400) bottomRight(3600,2800)

      Another way to think of it would be:

      for a given svg g element
      return all path elements for which the d(path data) contains a secment that is contained within the bounds of topLeft(2800,2400) bottomRight(3600,2800)

      It would be optimal if I could get paths that have only one segment that falls within the given bounds.

      I'm hoping there is something in jQuery or D3 that can help me, but anything at all that will point me in the right direction will be awesome.
    • HelderMagalhaes
      ... Hi wrinkledcheese, ... Checkout methods such as getIntersectionList and getEnclosureList (and/or their boolean counterparts, checkIntersection and
      Message 2 of 3 , Mar 31, 2013
      • 0 Attachment
        > Hello all,

        Hi wrinkledcheese,


        > I want to access all paths that fall within a certain bounds.

        Checkout methods such as "getIntersectionList" and "getEnclosureList" (and/or their boolean counterparts, checkIntersection and checkEnclosure) [1]. I believe they offer exactly what you're looking for... ;-)


        > I'm hoping there is something in jQuery or D3 that can help me [...]

        These are native methods which should already be in most SVG implementations, so no need for add-ons. Note that, nevertheless, you should test them in your target environments, as implementations such as WebKit (Safari/Chrome/etc.) and Gecko (Firefox) have "only" added support for this about 1-2 years ago (so very outdated versions don't have these methods available).


        Hope this helps,
        Helder


        [1] http://www.w3.org/TR/SVG/struct.html#__svg__SVGSVGElement__getIntersectionList
      • HelderMagalhaes
        Follow-up on my previous post... ... Unfortunately, I thought this had landed already but it s not the case, so it s still not available in Firefox. :-( You
        Message 3 of 3 , Mar 31, 2013
        • 0 Attachment
          Follow-up on my previous post...

          > These are native methods which should already be in most SVG implementations [...] and Gecko (Firefox) have "only" added support for this about 1-2 years ago [...]

          Unfortunately, I thought this had landed already but it's not the case, so it's still not available in Firefox. :-(

          You can follow progress and/or vote on bug 501421 [1].

          [1] https://bugzilla.mozilla.org/show_bug.cgi?id=501421
        Your message has been successfully submitted and would be delivered to recipients shortly.