Pandu van Java

Belajar, Berbakti, dan Berjuang

Tutorial Script InDesign CS3

| Comments

Menggambar Poligon Tidak Beraturan

Gambar di atas adalah frame atau border yang terdiri atas dua buah poligon tidak beraturan. Menggambar poligon tidak beraturan memang tidak semudah menggambar segiempat, lingkaran, atau poligon beraturan. Untuk menggambar poligon tidak beraturan kita harus menentukan koordinat tiap-tiap path point, left direction, dan right direction-nya (perhatikan gambar di bawah ini).

Script di bawah ini saya ‘sedekahkan’ untuk anda (hehehe.. mumpung masih bulan Ramadhan mudah2an pahalanya berlipat ganda. Amin..). Silakan diunduh, dipelajari, atau disebarluaskan (jika perlu).

(innovation.jsx) download
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
/*
 *  Script : innovation.jsx
 *  created by : Nurul Huda
 *  Medio:  July 5, 2013
 */

var myDoc = app.activeDocument;

// periksa apakah ada objek yg dipilih
if (myDoc.selection.length != 0){
	var myObj = myDoc.selection[0];
	
	// periksa apakah objek yg dipilih bertipe 'rectangle'
	if (myObj.constructor.name == 'Rectangle'){
		with (myObj){
			var myPage = parent;
			var myVBounds = visibleBounds;
			remove();
		}
	
		var y1 = myVBounds[0];
		var x1 = myVBounds[1];
		var y2 = myVBounds[2];
		var x2 = myVBounds[3];
		
		var pathPoints1 = [[[x1+2.117, y2-10.032], [x1+2.117, y2-9.260], [x1+2.558, y2-9.635]],
		[[x1+3.368, y2-9.890], [x1+4.057, y2-9.878], [x1+5.336, y2-9.856]],
		[[x1+7.078, y2-9.260], [x1+8.290, y2-7.982], [x1+9.503, y2-6.703]],
		[[x1+10.010, y2-4.983], [x1+10.010, y2-3.925], [x1+10.010, y2-2.866]],
		[[x1+9.679, y2-1.940], [x1+9.349, y2-1.367], [x1+9.018, y2-.794]],
		[[x1+8.158, y2-.176], [x1+8.158, y2-.176], [x1+8.158, y2-.176]],
		[[x2-8.158, y2-.176], [x2-8.158, y2-.176], [x2-8.158, y2-.176]],
		[[x2-9.018, y2-.794], [x2-9.349, y2-1.367], [x2-9.679, y2-1.940]],
		[[x2-10.010, y2-2.866], [x2-10.010, y2-3.925], [x2-10.010, y2-4.983]],
		[[x2-9.503, y2-6.703], [x2-8.290, y2-7.982], [x2-7.078, y2-9.260]],
		[[x2-5.336, y2-9.856], [x2-4.057, y2-9.878], [x2-3.368, y2-9.890]],
		[[x2-2.558, y2-9.635], [x2-2.117, y2-9.260], [x2-2.117, y2-10.032]],
		[[x2-2.117, y1+10.032], [x2-2.117, y1+9.260], [x2-2.558, y1+9.635]],
		[[x2-3.368, y1+9.890], [x2-4.057, y1+9.878], [x2-5.336, y1+9.856]],
		[[x2-7.078, y1+9.260], [x2-8.290, y1+7.982], [x2-9.503, y1+6.703]],
		[[x2-10.010, y1+4.983], [x2-10.010, y1+3.925], [x2-10.010, y1+2.866]],
		[[x2-9.679, y1+1.940], [x2-9.349, y1+1.367], [x2-9.018, y1+.794]],
		[[x2-8.158, y1+.176], [x2-8.158, y1+.176], [x2-8.158, y1+.176]],
		[[x1+8.158, y1+.176], [x1+8.158, y1+.176], [x1+8.158, y1+.176]],
		[[x1+9.018, y1+.794], [x1+9.349, y1+1.367], [x1+9.679, y1+1.940]],
		[[x1+10.010, y1+2.866], [x1+10.010, y1+3.925], [x1+10.010, y1+4.983]],
		[[x1+9.503, y1+6.703], [x1+8.290, y1+7.982], [x1+7.078, y1+9.260]],
		[[x1+5.336, y1+9.856], [x1+4.057, y1+9.878], [x1+3.368, y1+9.890]],
		[[x1+2.558, y1+9.635], [x1+2.117, y1+9.260], [x1+2.117, y1+10.032]]];

		var pathPoints2 = [[[x1+.176, y2-6.659], [x1+.176, y2-6.659], [x1+.176, y2-6.659]],
		[[x1+1.446, y2-8.211], [x1+2.999, y2-8.158], [x1+4.005, y2-8.124]],
		[[x1+4.657, y2-7.796], [x1+5.027, y2-7.452], [x1+5.416, y2-7.092]],
		[[x1+5.883, y2-6.429], [x1+5.865, y2-5.821], [x1+5.854, y2-5.458]],
		[[x1+5.786, y2-5.239], [x1+5.468, y2-4.939], [x1+5.653, y2-5.389]],
		[[x1+5.424, y2-5.733], [x1+5.203, y2-5.953], [x1+4.983, y2-6.174]],
		[[x1+4.692, y2-6.315], [x1+4.322, y2-6.262], [x1+3.855, y2-6.195]],
		[[x1+3.625, y2-6.085], [x1+3.404, y2-5.830], [x1+3.188, y2-5.579]],
		[[x1+3.087, y2-5.181], [x1+3.087, y2-4.807], [x1+3.087, y2-4.432]],
		[[x1+3.422, y2-3.889], [x1+3.704, y2-3.660], [x1+4.051, y2-3.379]],
		[[x1+4.392, y2-3.228], [x1+4.895, y2-3.219], [x1+5.336, y2-3.211]],
		[[x1+5.913, y2-3.395], [x1+6.244, y2-3.660], [x1+6.729, y2-4.048]],
		[[x1+7.126, y2-4.595], [x1+7.250, y2-5.001], [x1+7.357, y2-5.354]],
		[[x1+7.379, y2-5.512], [x1+7.364, y2-5.865], [x1+7.338, y2-6.518]],
		[[x1+6.879, y2-7.364], [x1+6.879, y2-7.364], [x1+6.879, y2-7.364]],
		[[x1+7.805, y2-6.262], [x1+7.982, y2-5.733], [x1+8.158, y2-5.203]],
		[[x1+8.176, y2-4.842], [x1+8.158, y2-4.277], [x1+8.141, y2-3.725]],
		[[x1+7.999, y2-3.193], [x1+7.823, y2-2.805], [x1+7.696, y2-2.525]],
		[[x1+7.276, y2-1.764], [x1+7.276, y2-1.764], [x1+7.276, y2-1.764]],
		[[x1+11.443, y2-1.764], [x1+12.215, y2-1.764], [x1+12.987, y2-1.764]],
		[[x1+13.384, y2-2.381], [x1+13.494, y2-2.558], [x1+13.604, y2-2.734]],
		[[x1+13.682, y2-3.003], [x1+13.688, y2-3.157], [x1+13.697, y2-3.378]],
		[[x1+13.653, y2-3.590], [x1+13.538, y2-3.881], [x1+13.406, y2-3.545]],
		[[x1+13.097, y2-3.351], [x1+13.097, y2-3.351], [x1+13.097, y2-3.351]],
		[[x1+12.815, y2-3.184], [x1+12.524, y2-3.175], [x1+12.280, y2-3.168]],
		[[x1+11.977, y2-3.373], [x1+11.845, y2-3.528], [x1+11.712, y2-3.682]],
		[[x1+11.540, y2-4.154], [x1+11.562, y2-4.419], [x1+11.584, y2-4.683]],
		[[x1+11.752, y2-5.115], [x1+12.039, y2-5.336], [x1+12.325, y2-5.556]],
		[[x1+12.634, y2-5.711], [x1+13.141, y2-5.689], [x1+13.648, y2-5.666]],
		[[x1+14.133, y2-5.380], [x1+14.288, y2-5.203], [x1+14.442, y2-5.027]],
		[[x1+14.662, y2-4.696], [x1+14.728, y2-4.410], [x1+14.795, y2-4.123]],
		[[x1+14.764, y2-3.766], [x1+14.728, y2-3.307], [x1+14.949, y2-3.859]],
		[[x1+15.430, y2-3.863], [x1+15.628, y2-3.863], [x1+15.826, y2-3.863]],
		[[x1+16.193, y2-3.642], [x1+16.334, y2-3.404], [x1+16.478, y2-3.161]],
		[[x1+16.550, y2-2.871], [x1+16.484, y2-2.584], [x1+16.417, y2-2.297]],
		[[x1+16.051, y2-1.852], [x1+16.051, y2-1.852], [x1+16.051, y2-1.852]],
		[[x2-16.051, y2-1.852], [x2-16.051, y2-1.852], [x2-16.051, y2-1.852]],
		[[x2-16.417, y2-2.297], [x2-16.484, y2-2.584], [x2-16.550, y2-2.871]],
		[[x2-16.478, y2-3.161], [x2-16.334, y2-3.404], [x2-16.193, y2-3.642]],
		[[x2-15.826, y2-3.863], [x2-15.628, y2-3.863], [x2-15.430, y2-3.863]],
		[[x2-14.949, y2-3.859], [x2-14.728, y2-3.307], [x2-14.764, y2-3.766]],
		[[x2-14.795, y2-4.123], [x2-14.728, y2-4.410], [x2-14.662, y2-4.696]],
		[[x2-14.442, y2-5.027], [x2-14.288, y2-5.203], [x2-14.133, y2-5.380]],
		[[x2-13.648, y2-5.666], [x2-13.141, y2-5.689], [x2-12.634, y2-5.711]],
		[[x2-12.325, y2-5.556], [x2-12.039, y2-5.336], [x2-11.752, y2-5.115]],
		[[x2-11.584, y2-4.683], [x2-11.562, y2-4.419], [x2-11.540, y2-4.154]],
		[[x2-11.712, y2-3.682], [x2-11.845, y2-3.528], [x2-11.977, y2-3.373]],
		[[x2-12.280, y2-3.168], [x2-12.524, y2-3.175], [x2-12.815, y2-3.184]],
		[[x2-13.097, y2-3.351], [x2-13.097, y2-3.351], [x2-13.097, y2-3.351]],
		[[x2-13.406, y2-3.545], [x2-13.538, y2-3.881], [x2-13.653, y2-3.590]],
		[[x2-13.697, y2-3.378], [x2-13.688, y2-3.157], [x2-13.682, y2-3.003]],
		[[x2-13.604, y2-2.734], [x2-13.494, y2-2.558], [x2-13.384, y2-2.381]],
		[[x2-12.987, y2-1.764], [x2-12.215, y2-1.764], [x2-11.443, y2-1.764]],
		[[x2-7.276, y2-1.764], [x2-7.276, y2-1.764], [x2-7.276, y2-1.764]],
		[[x2-7.696, y2-2.525], [x2-7.823, y2-2.805], [x2-7.999, y2-3.193]],
		[[x2-8.141, y2-3.725], [x2-8.158, y2-4.277], [x2-8.176, y2-4.842]],
		[[x2-8.158, y2-5.203], [x2-7.982, y2-5.733], [x2-7.805, y2-6.262]],
		[[x2-6.879, y2-7.364], [x2-6.879, y2-7.364], [x2-6.879, y2-7.364]],
		[[x2-7.338, y2-6.518], [x2-7.364, y2-5.865], [x2-7.379, y2-5.512]],
		[[x2-7.357, y2-5.354], [x2-7.250, y2-5.001], [x2-7.126, y2-4.595]],
		[[x2-6.729, y2-4.048], [x2-6.244, y2-3.660], [x2-5.913, y2-3.395]],
		[[x2-5.336, y2-3.211], [x2-4.895, y2-3.219], [x2-4.392, y2-3.228]],
		[[x2-4.051, y2-3.379], [x2-3.704, y2-3.660], [x2-3.422, y2-3.889]],
		[[x2-3.087, y2-4.432], [x2-3.087, y2-4.807], [x2-3.087, y2-5.181]],
		[[x2-3.188, y2-5.579], [x2-3.404, y2-5.830], [x2-3.625, y2-6.085]],
		[[x2-3.855, y2-6.195], [x2-4.322, y2-6.262], [x2-4.692, y2-6.315]],
		[[x2-4.983, y2-6.174], [x2-5.203, y2-5.953], [x2-5.424, y2-5.733]],
		[[x2-5.653, y2-5.389], [x2-5.468, y2-4.939], [x2-5.786, y2-5.239]],
		[[x2-5.854, y2-5.458], [x2-5.865, y2-5.821], [x2-5.883, y2-6.429]],
		[[x2-5.416, y2-7.092], [x2-5.027, y2-7.452], [x2-4.657, y2-7.796]],
		[[x2-4.005, y2-8.124], [x2-2.999, y2-8.158], [x2-1.446, y2-8.211]],
		[[x2-.176, y2-6.659], [x2-.176, y2-6.659], [x2-.176, y2-6.659]],
		[[x2-.176, y1+6.659], [x2-.176, y1+6.659], [x2-.176, y1+6.659]],
		[[x2-1.446, y1+8.211], [x2-2.999, y1+8.158], [x2-4.005, y1+8.124]],
		[[x2-4.657, y1+7.796], [x2-5.027, y1+7.452], [x2-5.416, y1+7.092]],
		[[x2-5.883, y1+6.429], [x2-5.865, y1+5.821], [x2-5.854, y1+5.458]],
		[[x2-5.786, y1+5.239], [x2-5.468, y1+4.939], [x2-5.653, y1+5.389]],
		[[x2-5.424, y1+5.733], [x2-5.203, y1+5.953], [x2-4.983, y1+6.174]],
		[[x2-4.692, y1+6.315], [x2-4.322, y1+6.262], [x2-3.855, y1+6.195]],
		[[x2-3.625, y1+6.085], [x2-3.404, y1+5.830], [x2-3.188, y1+5.579]],
		[[x2-3.087, y1+5.181], [x2-3.087, y1+4.807], [x2-3.087, y1+4.432]],
		[[x2-3.422, y1+3.889], [x2-3.704, y1+3.660], [x2-4.051, y1+3.379]],
		[[x2-4.392, y1+3.228], [x2-4.895, y1+3.219], [x2-5.336, y1+3.211]],
		[[x2-5.913, y1+3.395], [x2-6.244, y1+3.660], [x2-6.729, y1+4.048]],
		[[x2-7.126, y1+4.595], [x2-7.250, y1+5.001], [x2-7.357, y1+5.354]],
		[[x2-7.379, y1+5.512], [x2-7.364, y1+5.865], [x2-7.338, y1+6.518]],
		[[x2-6.879, y1+7.364], [x2-6.879, y1+7.364], [x2-6.879, y1+7.364]],
		[[x2-7.805, y1+6.262], [x2-7.982, y1+5.733], [x2-8.158, y1+5.203]],
		[[x2-8.176, y1+4.842], [x2-8.158, y1+4.277], [x2-8.141, y1+3.725]],
		[[x2-7.999, y1+3.193], [x2-7.823, y1+2.805], [x2-7.696, y1+2.525]],
		[[x2-7.276, y1+1.764], [x2-7.276, y1+1.764], [x2-7.276, y1+1.764]],
		[[x2-11.443, y1+1.764], [x2-12.215, y1+1.764], [x2-12.987, y1+1.764]],
		[[x2-13.384, y1+2.381], [x2-13.494, y1+2.558], [x2-13.604, y1+2.734]],
		[[x2-13.682, y1+3.003], [x2-13.688, y1+3.157], [x2-13.697, y1+3.378]],
		[[x2-13.653, y1+3.590], [x2-13.538, y1+3.881], [x2-13.406, y1+3.545]],
		[[x2-13.097, y1+3.351], [x2-13.097, y1+3.351], [x2-13.097, y1+3.351]],
		[[x2-12.815, y1+3.184], [x2-12.524, y1+3.175], [x2-12.280, y1+3.168]],
		[[x2-11.977, y1+3.373], [x2-11.845, y1+3.528], [x2-11.712, y1+3.682]],
		[[x2-11.540, y1+4.154], [x2-11.562, y1+4.419], [x2-11.584, y1+4.683]],
		[[x2-11.752, y1+5.115], [x2-12.039, y1+5.336], [x2-12.325, y1+5.556]],
		[[x2-12.634, y1+5.711], [x2-13.141, y1+5.689], [x2-13.648, y1+5.666]],
		[[x2-14.133, y1+5.380], [x2-14.288, y1+5.203], [x2-14.442, y1+5.027]],
		[[x2-14.662, y1+4.696], [x2-14.728, y1+4.410], [x2-14.795, y1+4.123]],
		[[x2-14.764, y1+3.766], [x2-14.728, y1+3.307], [x2-14.949, y1+3.859]],
		[[x2-15.430, y1+3.863], [x2-15.628, y1+3.863], [x2-15.826, y1+3.863]],
		[[x2-16.193, y1+3.642], [x2-16.334, y1+3.404], [x2-16.478, y1+3.161]],
		[[x2-16.550, y1+2.871], [x2-16.484, y1+2.584], [x2-16.417, y1+2.297]],
		[[x2-16.051, y1+1.852], [x2-16.051, y1+1.852], [x2-16.051, y1+1.852]],
		[[x1+16.051, y1+1.852], [x1+16.051, y1+1.852], [x1+16.051, y1+1.852]],
		[[x1+16.417, y1+2.297], [x1+16.484, y1+2.584], [x1+16.550, y1+2.871]],
		[[x1+16.478, y1+3.161], [x1+16.334, y1+3.404], [x1+16.193, y1+3.642]],
		[[x1+15.826, y1+3.863], [x1+15.628, y1+3.863], [x1+15.430, y1+3.863]],
		[[x1+14.949, y1+3.859], [x1+14.728, y1+3.307], [x1+14.764, y1+3.766]],
		[[x1+14.795, y1+4.123], [x1+14.728, y1+4.410], [x1+14.662, y1+4.696]],
		[[x1+14.442, y1+5.027], [x1+14.288, y1+5.203], [x1+14.133, y1+5.380]],
		[[x1+13.648, y1+5.666], [x1+13.141, y1+5.689], [x1+12.634, y1+5.711]],
		[[x1+12.325, y1+5.556], [x1+12.039, y1+5.336], [x1+11.752, y1+5.115]],
		[[x1+11.584, y1+4.683], [x1+11.562, y1+4.419], [x1+11.540, y1+4.154]],
		[[x1+11.712, y1+3.682], [x1+11.845, y1+3.528], [x1+11.977, y1+3.373]],
		[[x1+12.280, y1+3.168], [x1+12.524, y1+3.175], [x1+12.815, y1+3.184]],
		[[x1+13.097, y1+3.351], [x1+13.097, y1+3.351], [x1+13.097, y1+3.351]],
		[[x1+13.406, y1+3.545], [x1+13.538, y1+3.881], [x1+13.653, y1+3.590]],
		[[x1+13.697, y1+3.378], [x1+13.688, y1+3.157], [x1+13.682, y1+3.003]],
		[[x1+13.604, y1+2.734], [x1+13.494, y1+2.558], [x1+13.384, y1+2.381]],
		[[x1+12.987, y1+1.764], [x1+12.215, y1+1.764], [x1+11.443, y1+1.764]],
		[[x1+7.276, y1+1.764], [x1+7.276, y1+1.764], [x1+7.276, y1+1.764]],
		[[x1+7.696, y1+2.525], [x1+7.823, y1+2.805], [x1+7.999, y1+3.193]],
		[[x1+8.141, y1+3.725], [x1+8.158, y1+4.277], [x1+8.176, y1+4.842]],
		[[x1+8.158, y1+5.203], [x1+7.982, y1+5.733], [x1+7.805, y1+6.262]],
		[[x1+6.879, y1+7.364], [x1+6.879, y1+7.364], [x1+6.879, y1+7.364]],
		[[x1+7.338, y1+6.518], [x1+7.364, y1+5.865], [x1+7.379, y1+5.512]],
		[[x1+7.357, y1+5.354], [x1+7.250, y1+5.001], [x1+7.126, y1+4.595]],
		[[x1+6.729, y1+4.048], [x1+6.244, y1+3.660], [x1+5.913, y1+3.395]],
		[[x1+5.336, y1+3.211], [x1+4.895, y1+3.219], [x1+4.392, y1+3.228]],
		[[x1+4.051, y1+3.379], [x1+3.704, y1+3.660], [x1+3.422, y1+3.889]],
		[[x1+3.087, y1+4.432], [x1+3.087, y1+4.807], [x1+3.087, y1+5.181]],
		[[x1+3.188, y1+5.579], [x1+3.404, y1+5.830], [x1+3.625, y1+6.085]],
		[[x1+3.855, y1+6.195], [x1+4.322, y1+6.262], [x1+4.692, y1+6.315]],
		[[x1+4.983, y1+6.174], [x1+5.203, y1+5.953], [x1+5.424, y1+5.733]],
		[[x1+5.653, y1+5.389], [x1+5.468, y1+4.939], [x1+5.786, y1+5.239]],
		[[x1+5.854, y1+5.458], [x1+5.865, y1+5.821], [x1+5.883, y1+6.429]],
		[[x1+5.416, y1+7.092], [x1+5.027, y1+7.452], [x1+4.657, y1+7.796]],
		[[x1+4.005, y1+8.124], [x1+2.999, y1+8.158], [x1+1.446, y1+8.211]],
		[[x1+.176, y1+6.659], [x1+.176, y1+6.659], [x1+.176, y1+6.659]]];
		
		var myPolygon = myPage.polygons.add();
		var myPath = myPolygon.paths[0];
		myPath.entirePath = pathPoints1;
		
		var myObjs = [myPolygon];

		myPolygon = myPage.polygons.add();
		myPath = myPolygon.paths[0];
		myPath.entirePath = pathPoints2;

		myObjs.push(myPolygon);
		
		myGroup = myPage.groups.add( myObjs );
		myGroup.sendToBack();
		
	}
	else alert('Select a rectangle, please!');
	
}
else alert('Nothing is selected. Select a rectangle, please!');

Untuk menjalankan script di atas terlebih dahulu gambarlah sebuah segiempat dengan Rectangle tool. Ukurannya terserah anda. Pastikan mistar atas dan kiri menggunakan satuan milimeter (mm) dan segiempat tersebut harus dalam keadaan terpilih.

Keterangan:
Baris 26-49 adalah koordinat titik-titik pada poligon-1 relatif terhadap posisi segiempat yang anda pilih.
Baris 51-194 adalah koordinat titik-titik pada poligon-2 relatif terhadap posisi segiempat yang anda pilih.

Semoga bermanfaat

Baca juga: Menggambar poligon beraturan

Komentar