0.0.2 • Published 2 years ago

bezier-subdivide v0.0.2

Weekly downloads
6
License
MIT
Repository
github
Last release
2 years ago

bezier-subdivide

Build Status

Bezier curve subdivision in JavaScript

Based on Anti-Grain Geometry bezier subdivision

Usage

Points are represented by 2-element arrays.

var subdivide = require("bezier-subdivide");

var curve = [
  [100, 200],
  [200, 50],
  [50, 100],
  [200, 200],
];
var points = subdivide(curve); // subdivided points

https://gyazo.com/f8584661f74872afd5ed33699bca0e5b

subdivide(points[, options])

  • points: Array of points (start, control point 1, control point 2, end)

Types

type Point = [number, number];

interface Options {
  approximationScale?: number;
  angleTolerance?: number;
  cuspLimit?: number;
}

declare function subdivide(
  bezierPoints: [Point, Point, Point, Point],
  options?: Options
): Point[];

export default subdivide;
0.0.2

2 years ago

0.0.1

8 years ago