mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-22 20:39:17 +08:00
37 lines
863 B
TypeScript
37 lines
863 B
TypeScript
import paper = require('paper');
|
|
|
|
var canvas = document.createElement('canvas')
|
|
|
|
paper.setup(canvas);
|
|
|
|
// Circle
|
|
var path = new paper.Path.Circle({
|
|
center: [80, 50],
|
|
radius: 35,
|
|
fillColor: 'red'
|
|
});
|
|
|
|
// Dotted Line Tool
|
|
var dottedLinePath: paper.Path;
|
|
var dottedLineTool = new paper.Tool();
|
|
|
|
dottedLineTool.onMouseDown = function(event: any) {
|
|
new paper.Layer().activate();
|
|
dottedLinePath = new paper.Path();
|
|
dottedLinePath.strokeColor = '#00';
|
|
dottedLinePath.strokeWidth = 2;
|
|
dottedLinePath.dashArray = [5, 8];
|
|
dottedLinePath.strokeCap = 'round';
|
|
dottedLinePath.strokeJoin = 'round';
|
|
dottedLinePath.add(event.point);
|
|
};
|
|
|
|
dottedLineTool.onMouseDrag = function(event: any) {
|
|
dottedLinePath.add(event.point);
|
|
};
|
|
|
|
dottedLineTool.onMouseUp = function(event: any) {
|
|
dottedLinePath.smooth();
|
|
dottedLinePath.simplify();
|
|
};
|