svg-intersections
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/svg-intersections package

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).

/svg-intersections/

    Package Sidebar

    Install

    npm i svg-intersections

    Weekly Downloads

    37,673

    Version

    0.4.0

    License

    BSD

    Unpacked Size

    111 kB

    Total Files

    11

    Last publish

    Collaborators

    • signavio-it
    • thomaszi
    • jfschwarz
    • jbreckel