@xwiillz/svg-intersections
TypeScript icon, indicating that this package has built-in type declarations

0.4.0 • Public • Published

svg-intersections

A library of intersection algorithms covering all SVG shape types.
Possible to intersect rotated/scaled/skewed shapes.

Installation

npm install svg-intersections

API

This module exports two functions:

The intersect function takes two shapes as an input an returns an result object providing a result status, and all intersection points of the two shapes.

intersect (shape1, shape2)

The shape function wraps the necessary input parameters for each of the two shapes. It requires the SVG element name of the shape as a string and an object of the SVG element's attributes.

shape (svgElementName, svgAttributes)

Usage example

Example 1:

Example image

    
    var svgIntersections = require('svg-intersections');
    var intersect = svgIntersections.intersect;
    var shape = svgIntersections.shape;

    var intersections = intersect(  
        shape("circle", { cx: 0, cy: 0, r: 50 }),
        shape("rect", { x: 0, y: 0, width: 60, height: 30 })  
    );

Credits

The implementation is based on the intersection procedures by Kevin Lindsey (http://www.kevlindev.com) with contributions by Robert Benko (http://www.quazistax.com).

Package Sidebar

Install

npm i @xwiillz/svg-intersections

Weekly Downloads

1

Version

0.4.0

License

BSD-3-Clause

Unpacked Size

203 kB

Total Files

16

Last publish

Collaborators

  • xwiillz