pencil.js
Version:
Nice modular interactive 2D drawing library.
76 lines (75 loc) • 2.36 kB
TypeScript
/**
* @module Line
*/
/**
* Line class
* <br><img src="./media/examples/line.png" alt="line demo"/>
* @class
* @extends {module:Component}
*/
export default class Line {
/**
* @inheritDoc
* @param {Object} definition -Line definition
* @return {Line}
*/
static from(definition: any): Line;
/**
* @typedef {Object} LineOptions
* @extends ComponentOptions
* @prop {String} [cap=Line.caps.round] - How the line end points looks
* @prop {String} [join=Line.joins.round] - How the line segment are join
* @prop {String|ColorDefinition} [fill=null] - Color used to fill, set to null for transparent
* @prop {String|ColorDefinition} [stroke=Component.defaultOptions.fill] - Color used to stroke, set to null for transparent
* @prop {Boolean} [absolute=false] - Should points be treated as absolute coordinates
*/
/**
* @type {LineOptions}
*/
static get defaultOptions(): any;
/**
* @typedef {Object} LineCaps
* @prop {String} butt - Caps cut straight at end points
* @prop {String} round - Round caps by adding a circle at end points, with a radius of lineWidth
* @prop {String} square - Square caps by adding a square at end points, with a size of lineWidth
*/
/**
* @type {LineCaps}
*/
static get caps(): {
/**
* - Caps cut straight at end points
*/
butt: string;
/**
* - Round caps by adding a circle at end points, with a radius of lineWidth
*/
round: string;
/**
* - Square caps by adding a square at end points, with a size of lineWidth
*/
square: string;
};
/**
* Line constructor
* @param {PositionDefinition} positionDefinition - First point
* @param {Array<PositionDefinition>} points - List of points
* @param {LineOptions} [options] - Drawing options
*/
constructor(positionDefinition: PositionDefinition, points: Array<PositionDefinition>, options?: any);
/**
* @type {Array<Position>}
*/
points: Array<Position>;
/**
* Draw the line
* @param {Path2D} path - Drawing context
* @return {Line} Itself
*/
trace(path: Path2D): Line;
/**
* @inheritDoc
*/
toJSON(): any;
}
import Position from "@pencil.js/position";