Select SVG elements by making a free drawing for them

I am working on a project in which I want to draw a line around some SVG elements to make a selection of objects within an area.

Here is a screenshot of what I have now. I used Paint to add a line so that it is completely clear what I am trying to achieve. I want to select two rectinside the drawn circle.

Screen shot

I see a series of steps that need to be addressed:

  1. Create an item pathin mousedownand record the mouse movements untilmouseup
  2. Close pathif user didn’t draw a circle
  3. Find SVG elements that are fully or partially inside the circle

What approaches do you see and do you have any recommendations on how to do this?

D3.js. ( , D3) .

+6
1

:

  • aabb ( min/max box) ,
  • , ,
  • ,
  • ,

, , , .

, d3.js, , , . , -, 2.

...

+3

All Articles