thelonious / kld-intersections

A library of intersection algorithms covering all SVG shape types
BSD 3-Clause "New" or "Revised" License
343 stars 55 forks source link

Automatic creation of shapes from SVG elements #6

Closed tobireif closed 7 years ago

tobireif commented 9 years ago

Hi Kevin :)

Automatic creation of shapes from SVG elements - is that a possibility?

Instead of

Intersection.intersectShapes(  
  IntersectionParams.newCircle(new Point2D(0,0), 50),
  IntersectionParams.newRect(0, 0, 60, 30))
)

we could then write

Intersection.intersectShapes(someSvgCircleElement, someSvgCircleElement)

(That would probably implicitly cause the ~same action as the current version - the lib would create/update its representation of the shape.)

Tobi

thelonious commented 9 years ago

Hey Tobi,

Yes, that should be entirely possible. When I wrote this library, it was my intention to decouple the implementation from SVG, so I purposely didn't implement what you suggest. I never got around to it, but I was thinking another module could be created specifically for SVG. It would use an interface like you're suggesting, but it would ultimately include this module, calling it with this module's primitives.

-Kevin

tobireif commented 9 years ago

Sounds great! I think it would be useful, eg for collision detection of complex SVG shapes.

Feel free to close the ticket for now, or you could leave it open for later - up to you :)

Quazistax commented 9 years ago

You can use this script http://www.quazistax.com/Scripts/SvgDom.intersectShapes.js

SvgDom.intersectShapes(someSvgCircleElement, someSvgCircleElement)
tobireif commented 9 years ago

Awesome!

Perhaps you want to put it on GitHub.com ?