Socket
Socket
Sign inDemoInstall

svg-intersections

Package Overview
Dependencies
2
Maintainers
3
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    svg-intersections

A library of intersection algorithms covering all SVG shape types


Version published
Maintainers
3
Install size
175 kB
Created

Readme

Source

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

Keywords

FAQs

Last updated on 12 Feb 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc