forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample6-tests.ts
26 lines (20 loc) · 876 Bytes
/
sample6-tests.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
///<reference path="fabricjs.d.ts" />
var canvas = new fabric.Canvas('c');
fabric.loadSVGFromURL('../assets/135.svg', function (objects) {
var obj = objects[0].scale(0.25);
canvas.centerObject(obj);
canvas.add(obj);
canvas.add(obj.clone().set({ left: 100, top: 100, angle: -15 }));
canvas.add(obj.clone().set({ left: 480, top: 100, angle: 15 }));
canvas.add(obj.clone().set({ left: 100, top: 400, angle: -15 }));
canvas.add(obj.clone().set({ left: 480, top: 400, angle: 15 }));
canvas.on('mouse:move', function (options) {
var p = canvas.getPointer(options.e);
canvas.forEachObject(function (obj) {
var distX = Math.abs(p.x - obj.left),
distY = Math.abs(p.y - obj.top),
dist = Math.round(Math.sqrt(Math.pow(distX, 2) + Math.pow(distY, 2)));
obj.setOpacity(1 / (dist / 20));
});
});
});