pencil.js
Version:
Nice modular interactive 2D drawing library.
53 lines (52 loc) • 1.95 kB
TypeScript
/**
* @module Spline
*/
/**
* Spline class
* <br><img src="./media/examples/spline.png" alt="spline demo"/>
* @class
* @extends {module:Line}
*/
export default class Spline {
/**
* @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|CanvasRenderingContext2D} path - Current drawing path
* @param {Array<PositionDefinition>} points - Points to use (need at least 2 points)
* @param {Number} [tension=Spline.defaultTension] - Ratio of tension
* @param {PositionDefinition} [_correction] - Apply position correction to all points (used by the library)
*/
static splineThrough(path: Path2D | CanvasRenderingContext2D, points: Array<PositionDefinition>, tension?: number, _correction?: PositionDefinition): void;
/**
* 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: PositionDefinition, points: Array<PositionDefinition> | PositionDefinition, tension?: number, options?: LineOptions);
/**
* @type {Number}
*/
tension: number;
/**
* Draw the spline
* @param {Path2D} path - Current drawing path
* @return {Spline} Itself
*/
trace(path: Path2D): Spline;
/**
* @inheritDoc
*/
toJSON(): any;
}