pencil.js
Version:
Nice modular interactive 2D drawing library.
103 lines (102 loc) • 4.13 kB
TypeScript
/**
* @module Path
*/
/**
* Path class
* <br><img src="./media/examples/path.png" alt="path demo"/>
* @class
* @extends Component
*/
export default class Path extends Component {
/**
* @inheritDoc
* @param {Object} definition - Path definition
* @return {Path}
*/
static from(definition: any): Path;
/**
* Draw a line to a position
* @param {PositionDefinition} position - Any position
* @return {Instruction}
*/
static lineTo(position: any): Instruction;
/**
* Move the pencil without drawing
* @param {PositionDefinition} position - Any position
* @return {Instruction}
*/
static moveTo(position: any): Instruction;
/**
* Draw an quarter circle arc to a position
* @param {PositionDefinition} position - Any position
* @param {Boolean} [clockwise=true] - Should the arc be clockwise or not
* @return {Instruction}
*/
static quarterTo(position: any, clockwise?: boolean): Instruction;
/**
* Draw an quarter circle arc to a position
* @param {PositionDefinition} position - Any position
* @param {Boolean} [clockwise=true] - Should the arc be clockwise or not
* @return {Instruction}
*/
static halfTo(position: any, clockwise?: boolean): Instruction;
/**
* Try to approximate an arc between two points
* @param {PositionDefinition} position - Any position
* @param {Number} angle - Arc angle in ratio of a full circle (should be less than 0.5)
* @param {Number} magicRatio - Control points "openness" ratio
* @param {Boolean} [clockwise=true] - Should the arc be clockwise or not
* @return {Instruction}
*/
static arcTo(position: any, angle: number, magicRatio: number, clockwise?: boolean): Instruction;
/**
* Draw a quadratic curve to a position
* @param {PositionDefinition} position - Any position
* @param {PositionDefinition} controlPoint - Point that control the curve
* @return {Instruction}
*/
static quadTo(position: any, controlPoint: any): Instruction;
/**
* Draw a bezier curve to a position
* @param {PositionDefinition} position - Any position
* @param {PositionDefinition} firstControlPoint - First point to control the curve
* @param {PositionDefinition} secondControlPoint - Second point to control the curve
* @return {Instruction}
*/
static bezierTo(position: any, firstControlPoint: any, secondControlPoint: any): Instruction;
/**
*
* @param {Array<PositionDefinition>} points - Any set of positions
* @param {Number} [tension] - Ratio of tension
* @return {Instruction}
*/
static splineThrough(points: Array<any>, tension?: number): Instruction;
/**
*
* @param {PositionDefinition} position - Any position
* @param {Number} nbWaves - Number of waves to draw
* @return {Instruction}
*/
static waveTo(position: any, nbWaves: number): Instruction;
/**
*
* @param {PositionDefinition} position - Any position
* @param {Number} nbSins - Number of sinusoid to draw
* @param {Number} sinsHeight - Height of the sinusoid
* @return {Instruction}
*/
static sinTo(position: any, nbSins: number, sinsHeight: number): Instruction;
/**
* Path constructor
* @param {PositionDefinition} positionDefinition - Starting position of the Path
* @param {Array<Instruction>|String} instructions - Set of instructions to follow to draw it
* @param {Boolean} [isClosed=true] - Should the path close itself (add a line to the starting position)
* @param {ComponentOptions|LineOptions} [options] - Drawing options
*/
constructor(positionDefinition: any, instructions: Array<Instruction> | string, isClosed?: boolean, options?: any | any);
instructions: string | Instruction[];
isClosed: boolean;
closing: Instruction;
}
import Component from "@pencil.js/component";
import Instruction from "./instruction";