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

points-on-curve

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

points-on-curve - npm Package Compare versions

Comparing version 0.2.0 to 1.0.0

2

lib/curve-to-bezier.d.ts
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;

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