包详细信息

path-intersection

bpmn-io374kMIT3.1.0

Computes the intersection between two SVG paths

svg, path, path intersection

自述文件

path-intersection

CI

Computes the intersection between two SVG paths.

Examples

Intersection examples

Execute npm run dev and navigate to http://localhost:9876/debug.html to see more examples.

Usage

import intersect from 'path-intersection';

const path0 = 'M30,100L270,20';
const path1 = 'M150,150m0,-18a18,18,0,1,1,0,36a18,18,0,1,1,0,-36z';

const intersection = intersect(path0, path1);
// [ { x: ..., y: ..., segment1: ..., segment2: ... }, ... ]

Results are approximate, as we use bezier clipping to find intersections.

Building the Project

# install dependencies
npm install

# build and test the library
npm run all

Credits

The intersection logic provided by this library is derived from path.js, a part of Snap.svg.

License

Use under the terms of the MIT license.

更新日志

Changelog

All notable changes to path-intersection are documented here. We use semantic versioning for releases.

Unreleased

_Note: Yet to be released changes appear here._

3.1.0

  • FIX: correct type declaration (#23)
  • CHORE: add exports field

3.0.0

  • FEAT: turn into module

Breaking Changes

  • You must now configure a module transpiler such as Babel or Webpack in order to import from non-ES modules code.

2.2.1

  • FIX: correct parsing of paths with scientific notation (#17, #18, #19)

2.2.0

  • FEAT: optimize intersection finding for vertical or horizontal lines (#9)

2.1.0

  • CHORE: various code cleanups

2.0.2

  • FIX: safely clone things

2.0.1

  • FIX: handle path segments with length smaller than five pixel (f733e90f)
  • FIX: compensate rounding error (6433915d)
  • CHORE: slightly increase duplicate filtering accuracy (f37c0567)
  • CHORE: various code cleanups

2.0.0

  • CHORE: remove intersection logic for non-standardized path descriptors (d6f07947)

1.1.1

  • FIX: correct TypeScript definitions to match export

1.1.0

  • FEAT: add TypeScript definitions

...

Check git log for earlier history.