Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bezier-intersect

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bezier-intersect

intersections between bezier curves of order 2, 3 and lines and rectangles

  • 0.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
411
decreased by-15.78%
Maintainers
1
Weekly downloads
 
Created
Source

bezier-intersect npm version build

Set of functions to find intersections between lines and rectangles and Bezier curves of order 2 and 3. Based on thelonious/js-intersections, but with the abstractions removed and some performance tweaking.

Install

npm i -S bezier-intersect
import {
  quadBezierLine,
  cubicBezierLine,
  quadBezierAABB,
  cubicBezierAABB
} from 'bezier-intersect';
<script src="https://unpkg.com/bezier-intersect"></script>
<script>
var res = [];
bezierIntersect.quadBezierLine(..., res);
console.log(res);
</script>

API

quadBezierLine(ax, ay, cx, cy, bx, by, l1x, l1y, l2x, l2y, [result:Array<number>]):number

Calculates the intersection points between the quadratic Bezier curve and line segment. If result is passed, returns the exact number of intersections, and stores them in result as [x, y, x, y]. If not - stops at the first intersection and returns 1 or 0 if there are no intersections.

quadBezierAABB(ax, ay, cx, cy, bx, by, minx, miny, maxx, maxy, [result:Array<number>]):number

Calculates the intersection points between the quadratic Bezier curve and axis-aligned box. If result is passed, returns the exact number of intersections, and stores them in result as [x, y, x, y]. If not - stops at the first intersection and returns 1 or 0 if there are no intersections.

cubicBezierLine(ax, ay, c1x, c1y, c2x, c2y, bx, by, l1x, l1y, l2x, l2y, [result:Array<number>]):number

Calculates the intersection points between the cubic Bezier curve and line segment. If result is passed, returns the exact number of intersections, and stores them in result as [x, y, x, y]. If not - stops at the first intersection and returns 1 or 0 if there are no intersections.

cubicBezierAABB(ax, ay, c1x, c1y, c2x, c2y, bx, by, minx, miny, maxx, maxy, [result:Array<number>]):number

Calculates the intersection points between the cubic Bezier curve and axis-aligned box. If result is passed, returns the exact number of intersections, and stores them in result as [x, y, x, y]. If not - stops at the first intersection and returns 1 or 0 if there are no intersections.

TODO

  • More tests
  • Bezier/Polygon
  • Bezier/Ellipse/Circle

License

MIT

Keywords

FAQs

Package last updated on 18 May 2018

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc