Function: use()
ts
function use(plugin, options?): object;Defined in: index.ts:153
Install a plugin in Pencil.js
Parameters
| Parameter | Type | Description |
|---|---|---|
plugin | Plugin | Plugin to install |
options? | any | Option passed down to the plugin |
Returns
The Pencil.js package
Arc
ts
Arc: typeof Arc;author
ts
author: string;Author of the library
BaseEvent
ts
BaseEvent: typeof BaseEvent;Button
ts
Button: typeof Button;Checkbox
ts
Checkbox: typeof Checkbox;Circle
ts
Circle: typeof Circle;Color
ts
Color: typeof Color;Component
ts
Component: typeof Component;ConicGradient
ts
ConicGradient: typeof ConicGradient;Container
ts
Container: typeof Container;Ellipse
ts
Ellipse: typeof Ellipse;EventEmitter
ts
EventEmitter: typeof EventEmitter;from
ts
from: <T>(json) => T;Construct Pencil.js objects (and their children) from a JSON definition
Type Parameters
| Type Parameter | Default type |
|---|---|
T | any |
Parameters
| Parameter | Type | Description |
|---|---|---|
json | Definition | Valid JSON definition (from any toJSON call) |
Returns
T
Example
ts
const copy = from(JSON.parse(JSON.stringify(scene)));Heart
ts
Heart: typeof Heart;homepage
ts
homepage: string;Homepage of the library
Image
ts
Image: typeof Image;Input
ts
Input: typeof Input;Instruction
ts
Instruction: typeof Instruction;KeyboardEvent
ts
KeyboardEvent: typeof KeyboardEvent;Knob
ts
Knob: typeof Knob;Line
ts
Line: typeof Line;LinearGradient
ts
LinearGradient: typeof LinearGradient;Math
ts
Math: math;Constrain a number between two limits.
Param
value
Any number
Param
min
Minimal limit for the value
Param
max
Maximal limit for the value
Example
ts
constrain(999, 0, 50); // => 50
constrain(-999, 0, 50); // => 0MouseEvent
ts
MouseEvent: typeof MouseEvent;Navigation
ts
Navigation: navigation;NetworkEvent
ts
NetworkEvent: typeof NetworkEvent;OffScreenCanvas
ts
OffScreenCanvas: typeof OffScreenCanvas;Particles
ts
Particles: typeof Particles;Path
ts
Path: typeof Path;Pattern
ts
Pattern: typeof Pattern;Pie
ts
Pie: typeof Pie;Polygon
ts
Polygon: typeof Polygon;Position
ts
Position: typeof Position;ProgressBar
ts
ProgressBar: typeof ProgressBar;ProgressPie
ts
ProgressPie: typeof ProgressPie;RadialGradient
ts
RadialGradient: typeof RadialGradient;Rectangle
ts
Rectangle: typeof Rectangle;register
ts
register: (...classes) => void;Make classes available to the from function (every built-in class is registered when importing the main "pencil.js" entry)
Parameters
| Parameter | Type | Description |
|---|---|---|
...classes | Revivable[] | Any set of classes |
Returns
void
Example
ts
class MyShape extends Component { … }
register(MyShape);RegularPolygon
ts
RegularPolygon: typeof RegularPolygon;Scene
ts
Scene: typeof Scene;Select
ts
Select: typeof Select;Slider
ts
Slider: typeof Slider;Spline
ts
Spline: typeof Spline;Sprite
ts
Sprite: typeof Sprite;Spritesheet
ts
Spritesheet: typeof Spritesheet;Square
ts
Square: typeof Square;Star
ts
Star: typeof Star;Text
ts
Text: typeof Text;Triangle
ts
Triangle: typeof Triangle;use
ts
use: (plugin, options?) => { EventEmitter: typeof EventEmitter; Container: typeof Container; Scene: typeof Scene; Component: typeof Component; Particles: typeof Particles; Arc: typeof Arc; Pie: typeof Pie; ... 45 more ...; homepage: string; };Install a plugin in Pencil.js
Parameters
| Parameter | Type | Description |
|---|---|---|
plugin | Plugin | Plugin to install |
options? | any | Option passed down to the plugin |
Returns
{ EventEmitter: typeof EventEmitter; Container: typeof Container; Scene: typeof Scene; Component: typeof Component; Particles: typeof Particles; Arc: typeof Arc; Pie: typeof Pie; ... 45 more ...; homepage: string; }
The Pencil.js package
Vector
ts
Vector: typeof Vector;version
ts
version: string;Version of the library
Widget
ts
Widget: typeof Widget;