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
59
60
61
62
63
|
var extend = function (obj1, obj2) {
for (key in obj2) { obj1[key] = obj2[key] }
return obj1
}
var prefs = app.preferences
var startRulerUnits = prefs.rulerUnits
var startTypeUnits = prefs.typeUnits
var startDisplayDialogs = app.displayDialogs
prefs.rulerUnits = Units.PIXELS
prefs.typeUnits = TypeUnits.PIXELS
app.displayDialogs = DialogModes.NO
while (app.documents.length) {
app.activeDocument.close()
}
var docRef = app.documents.add(5000, 7000, 72, "Simple Line")
var subpath = function (vertex_list) {
return extend(new SubPathInfo(), {
operation: ShapeOperation.SHAPEXOR,
closed: false,
entireSubPath: vertex_list
})
}
var vertex = function (anchor, leftDirection, rightDirection) {
return extend(new PathPointInfo(), {
kind: PointKind.CORNERPOINT,
anchor: anchor,
leftDirection: leftDirection,
rightDirection: rightDirection
})
}
var corner_vertex = function (anchor) {
return vertex(anchor, anchor, anchor)
}
var straight_line = function (start_anchor, end_anchor) {
return subpath([corner_vertex(start_anchor), corner_vertex(end_anchor)])
}
var myPathItem = docRef.pathItems.add(
"A Line",
[ straight_line([100, 100], [150, 200]), straight_line([150, 200], [200, 100]), subpath([
corner_vertex([200, 100]), vertex([150, 50], [100, 50], [200, 50]), corner_vertex([100, 100]) ]]))
myPathItem.strokePath(ToolType.BRUSH)
prefs.rulerUnits = startRulerUnits
prefs.typeUnits = startTypeUnits
app.displayDialogs = startDisplayDialogs
|