-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpath.js
More file actions
58 lines (52 loc) · 1.25 KB
/
Copy pathpath.js
File metadata and controls
58 lines (52 loc) · 1.25 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
var handle;
var segment;
project.importSVG("./assets/hashrock-icon.svg");
function onMouseDown(event) {
handle = null;
segment = null;
var hitResult = project.hitTestAll(event.point, {
fill: false,
stroke: false,
segments: true,
handles: true,
tolerance: 8
});
if (hitResult && hitResult[0]) {
handle = null;
segment = null;
project.deselectAll();
hitResult[0].item.fullySelected = true;
if (hitResult[0].type === "handle-in") {
handle = hitResult[0].segment.handleIn;
}
if (hitResult[0].type === "handle-out") {
handle = hitResult[0].segment.handleOut;
}
if (hitResult[0].type === "segment") {
segment = hitResult[0].segment;
}
return;
}
//選択
var ha = project.hitTestAll(event.point, {
fill: true,
stroke: true,
segments: true
});
if (ha && ha[0]) {
project.deselectAll();
ha[0].item.fullySelected = true;
selected = ha[0].item
}
}
function onMouseDrag(event) {
// If we hit a handle before, move it:
if (handle) {
handle.x += event.delta.x;
handle.y += event.delta.y;
}
if (segment) {
segment.point.x += event.delta.x;
segment.point.y += event.delta.y;
}
}