pencil.js
Version:
Nice modular interactive 2D drawing library.
51 lines (50 loc) • 2 kB
TypeScript
/**
* @module Spline
*/
/**
* Spline class
* <br><img src="./media/examples/spline.png" alt="spline demo"/>
* @class
* @extends Line
*/
export default class Spline extends Line {
/**
* @inheritDoc
* @param {Object} definition - Spline definition
* @return {Spline}
*/
static from(definition: any): Spline;
/**
* Default ratio of tension
* @type {Number}
*/
static get defaultTension(): number;
/**
* Draw a spline through points using a tension (first point should be current position)
* @param {Path2D} path - Current drawing path
* @param {Array<PositionDefinition>} points - Points to use (need at least 2 points)
* @param {Number} [tension=Spline.defaultTension] - Ratio of tension
*/
static splineThrough(path: Path2D, points: Array<any>, tension?: number): void;
/**
* Returns control points for a point in a spline (needs before and after, 3 points in total)
* @param {Array<PositionDefinition>} points - 3 points to use (before, target, after)
* @param {Number} [tension=Spline.defaultTension] - Ratio of tension
* @return {Array<Position>}
*/
static getControlPoint(points: Array<any>, tension?: number): Array<Position>;
/**
* Spline constructor
* @param {PositionDefinition} positionDefinition - First point
* @param {Array<PositionDefinition>|PositionDefinition} points - Set of points to go through or a single target point
* @param {Number} [tension=Spline.defaultTension] - Ratio of tension between points (0 means straight line, can take any value, but with weird results above 1)
* @param {LineOptions} [options] - Drawing options
*/
constructor(positionDefinition: any, points: Array<any> | any, tension?: number, options?: any);
/**
* @type {Number}
*/
tension: number;
}
import Line from "@pencil.js/line";
import Position from "@pencil.js/position";