points-on-curve
Advanced tools
Comparing version 0.2.0 to 1.0.0
import { Point } from './index.js'; | ||
export declare function curveToBezier(pointsIn: Point[], curveTightness?: number): Point[]; | ||
export declare function curveToBezier(pointsIn: readonly Point[], curveTightness?: number): Point[]; |
@@ -1,3 +0,3 @@ | ||
export declare type Point = [number, number]; | ||
export declare function simplify(points: Point[], distance: number): Point[]; | ||
export declare function pointsOnBezierCurves(points: Point[], tolerance?: number, distance?: number): Point[]; | ||
export declare type Point = readonly [number, number]; | ||
export declare function simplify(points: readonly Point[], distance: number): Point[]; | ||
export declare function pointsOnBezierCurves(points: readonly Point[], tolerance?: number, distance?: number): Point[]; |
{ | ||
"name": "points-on-curve", | ||
"version": "0.2.0", | ||
"version": "1.0.0", | ||
"description": "Estimate points on a bezier curve or a set of connexted bezier curves", | ||
@@ -10,3 +10,2 @@ "main": "lib/index.js", | ||
"build": "rm -rf lib && tsc", | ||
"lint": "tslint -p tsconfig.json", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
@@ -29,5 +28,4 @@ }, | ||
"devDependencies": { | ||
"tslint": "^6.1.1", | ||
"typescript": "^3.8.3" | ||
"typescript": "^4.5.5" | ||
} | ||
} | ||
} |
@@ -7,3 +7,3 @@ import { Point } from './index.js'; | ||
export function curveToBezier(pointsIn: Point[], curveTightness = 0): Point[] { | ||
export function curveToBezier(pointsIn: readonly Point[], curveTightness = 0): Point[] { | ||
const len = pointsIn.length; | ||
@@ -10,0 +10,0 @@ if (len < 3) { |
@@ -1,2 +0,2 @@ | ||
export type Point = [number, number]; | ||
export type Point = readonly [number, number]; | ||
@@ -32,3 +32,3 @@ // distance between 2 points | ||
// Adapted from https://seant23.wordpress.com/2010/11/12/offset-bezier-curves/ | ||
function flatness(points: Point[], offset: number): number { | ||
function flatness(points: readonly Point[], offset: number): number { | ||
const p1 = points[offset + 0]; | ||
@@ -55,3 +55,3 @@ const p2 = points[offset + 1]; | ||
function getPointsOnBezierCurveWithSplitting(points: Point[], offset: number, tolerance: number, newPoints?: Point[]): Point[] { | ||
function getPointsOnBezierCurveWithSplitting(points: readonly Point[], offset: number, tolerance: number, newPoints?: Point[]): Point[] { | ||
const outPoints = newPoints || []; | ||
@@ -92,3 +92,3 @@ if (flatness(points, offset) < tolerance) { | ||
export function simplify(points: Point[], distance: number): Point[] { | ||
export function simplify(points: readonly Point[], distance: number): Point[] { | ||
return simplifyPoints(points, 0, points.length, distance); | ||
@@ -99,3 +99,3 @@ } | ||
// https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm | ||
function simplifyPoints(points: Point[], start: number, end: number, epsilon: number, newPoints?: Point[]): Point[] { | ||
function simplifyPoints(points: readonly Point[], start: number, end: number, epsilon: number, newPoints?: Point[]): Point[] { | ||
const outPoints = newPoints || []; | ||
@@ -130,3 +130,3 @@ | ||
export function pointsOnBezierCurves(points: Point[], tolerance: number = 0.15, distance?: number): Point[] { | ||
export function pointsOnBezierCurves(points: readonly Point[], tolerance: number = 0.15, distance?: number): Point[] { | ||
const newPoints: Point[] = []; | ||
@@ -133,0 +133,0 @@ const numSegments = (points.length - 1) / 3; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
1
17319
10
340