-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathSplitter Raster Color.js
More file actions
44 lines (35 loc) · 1.02 KB
/
Copy pathSplitter Raster Color.js
File metadata and controls
44 lines (35 loc) · 1.02 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
// Script author peko [peko@gasubasu.com]
// http://gasubasu.com
// TOOL SPLITING PATH AND COLOR IT WITH IMAGE BEHIND
var raster;
function segment(item, position) {
i = item.clone();
i.scale(0.5, position);
c = raster.getAverageColor(i);
i.fillColor = c;
print(c);
}
function onMouseDown(event) {
if (raster == null) {
var rasters = document.getItems({
type: Raster,
selected: true
});
if(rasters.length > 0) {
raster = rasters[0];
} else {
raster = null;
Dialog.alert('Please select an image first!')
return;
}
}
if(event.item) {
if (event.item instanceof Path) {
segment(event.item, event.item.bounds.topLeft);
segment(event.item, event.item.bounds.topRight);
segment(event.item, event.item.bounds.bottomLeft);
segment(event.item, event.item.bounds.bottomRight);
event.item.remove();
}
}
}