1 function cdDrawBezier(kage, polygons, x1, y1, x2, y2, x3, y3, x4, y4, a1, a2){
\r
4 var ix, iy, ia, ib, ir;
\r
11 if(kage.kShotai == kage.kMincho){ // mincho
\r
15 delta = -1 * kage.kMinWidthY * 0.5;
\r
25 delta = kage.kMinWidthY;
\r
32 if(y1 < y2){ y1 = y1 - delta; }
\r
33 else{ y1 = y1 + delta; }
\r
36 if(x1 < x2){ x1 = x1 - delta; }
\r
37 else{ x1 = x1 + delta; }
\r
40 rad = Math.atan((y2 - y1) / (x2 - x1));
\r
41 if(x1 < x2){ v = 1; } else{ v = -1; }
\r
42 x1 = x1 - delta * Math.cos(rad) * v;
\r
43 y1 = y1 - delta * Math.sin(rad) * v;
\r
63 if(y3 < y4){ y4 = y4 + delta; }
\r
64 else{ y4 = y4 - delta; }
\r
67 if(x3 < x4){ x4 = x4 + delta; }
\r
68 else{ x4 = x4 - delta; }
\r
71 rad = Math.atan((y4 - y3) / (x4 - x3));
\r
72 if(x3 < x4){ v = 1; } else{ v = -1; }
\r
73 x4 = x4 + delta * Math.cos(rad) * v;
\r
74 y4 = y4 + delta * Math.sin(rad) * v;
\r
77 poly = new Polygon();
\r
78 poly2 = new Polygon();
\r
79 for(tt = 0; tt <= 1000; tt = tt + kage.kRate){
\r
83 x = (1.0 - t) * (1.0 - t) * (1.0 - t) * x1 + 3.0 * t * (1.0 - t) * (1.0 - t) * x2 + 3 * t * t * (1.0 - t) * x3 + t * t * t * x4;
\r
84 y = (1.0 - t) * (1.0 - t) * (1.0 - t) * y1 + 3.0 * t * (1.0 - t) * (1.0 - t) * y2 + 3 * t * t * (1.0 - t) * y3 + t * t * t * y4;
\r
85 //KATAMUKI of vector by BIBUN
\r
86 ix = t * t * (-3 * x1 + 9 * x2 + -9 * x3 + 3 * x4) + t * (6 * x1 + -12 * x2 + 6 * x3) + -3 * x1 + 3 * x2;
\r
87 iy = t * t * (-3 * y1 + 9 * y2 + -9 * y3 + 3 * y4) + t * (6 * y1 + -12 * y2 + 6 * y3) + -3 * y1 + 3 * y2;
\r
89 //line SUICHOKU by vector
\r
90 if(ix != 0 && iy != 0){
\r
91 ir = Math.atan(iy / ix * -1);
\r
92 ia = Math.sin(ir) * (kage.kMinWidthT);
\r
93 ib = Math.cos(ir) * (kage.kMinWidthT);
\r
96 ia = kage.kMinWidthT;
\r
101 ib = kage.kMinWidthT;
\r
104 if(a1 == 7){ deltad = Math.sqrt(t); }
\r
105 else if(a2 == 7){ deltad = Math.sqrt(1.0 - t); }
\r
106 else{ deltad = 1; }
\r
110 //reverse if vector is going 2nd/3rd quadrants
\r
116 //copy to polygon structuer
\r
117 poly.push(x - ia, y - ib);
\r
118 poly2.push(x + ia, y + ib);
\r
121 poly.concat(poly2);
\r
122 polygons.push(poly);
\r
124 //process for head of stroke
\r
125 rad = Math.atan((y2 - y1) / (x2 - x1));
\r
126 if(x1 < x2){ v = 1; } else{ v = -1; }
\r
127 XX = Math.sin(rad) * v;
\r
128 XY = Math.cos(rad) * v * -1;
\r
129 YX = Math.cos(rad) * v;
\r
130 YY = Math.sin(rad) * v;
\r
134 poly = new Polygon();
\r
135 poly.push(x1 - kage.kMinWidthT, y1);
\r
136 poly.push(x1 + kage.kMinWidthT, y1);
\r
137 poly.push(x1 - kage.kMinWidthT, y1 - kage.kMinWidthT);
\r
138 polygons.push(poly);
\r
141 poly = new Polygon();
\r
142 poly.push(x1 - kage.kMinWidthT * XX, y1 - kage.kMinWidthT * XY);
\r
143 poly.push(x1 + kage.kMinWidthT * XX, y1 + kage.kMinWidthT * XY);
\r
144 poly.push(x1 - kage.kMinWidthT * XX - kage.kMinWidthT * YX, y1 - kage.kMinWidthT * XY - kage.kMinWidthT * YY);
\r
145 polygons.push(poly);
\r
150 if(y1 <= y4){ //from up to bottom
\r
152 poly = new Polygon();
\r
153 poly.push(x1 - kage.kMinWidthT, y1);
\r
154 poly.push(x1 + kage.kMinWidthT, y1);
\r
155 poly.push(x1 - kage.kMinWidthT, y1 - kage.kMinWidthY);
\r
156 polygons.push(poly);
\r
159 poly = new Polygon();
\r
160 poly.push(x1 - kage.kMinWidthT * XX, y1 - kage.kMinWidthT * XY);
\r
161 poly.push(x1 + kage.kMinWidthT * XX, y1 + kage.kMinWidthT * XY);
\r
162 poly.push(x1 - kage.kMinWidthT * XX - kage.kMinWidthY * YX, y1 - kage.kMinWidthT * XY - kage.kMinWidthY * YY);
\r
163 polygons.push(poly);
\r
166 else{ //bottom to up
\r
167 if(x1 == x2){ //is it right?
\r
168 poly = new Polygon();
\r
169 poly.push(x1 - kage.kMinWidthT, y1);
\r
170 poly.push(x1 + kage.kMinWidthT, y1);
\r
171 poly.push(x1 - kage.kMinWidthT, y1 + kage.kMinWidthY);
\r
172 polygons.push(poly);
\r
175 poly = new Polygon();
\r
176 poly.push(x1 - kage.kMinWidthT * XX, y1 - kage.kMinWidthT * XY);
\r
177 poly.push(x1 + kage.kMinWidthT * XX, y1 + kage.kMinWidthT * XY);
\r
178 poly.push(x1 + kage.kMinWidthT * XX - kage.kMinWidthY * YX, y1 + kage.kMinWidthT * XY - kage.kMinWidthY * YY);
\r
179 polygons.push(poly);
\r
184 if(a1 == 22){ //box's up-right corner, any time same degree
\r
185 poly = new Polygon();
\r
186 poly.push(x1 - kage.kMinWidthT, y1 - kage.kMinWidthY);
\r
187 poly.push(x1, y1 - kage.kMinWidthY - kage.kWidth);
\r
188 poly.push(x1 + kage.kMinWidthT + kage.kWidth, y1 + kage.kMinWidthY);
\r
189 poly.push(x1 + kage.kMinWidthT, y1 + kage.kMinWidthT);
\r
190 poly.push(x1 - kage.kMinWidthT, y1);
\r
191 polygons.push(poly);
\r
194 if(a1 == 0){ //beginning of the stroke
\r
195 if(y1 <= y4){ //from up to bottom
\r
197 poly = new Polygon();
\r
198 poly.push(x1 + kage.kMinWidthT, y1 + kage.kMinWidthY * 0.5);
\r
199 poly.push(x1 + kage.kMinWidthT + kage.kMinWidthT * 0.5, y1 + kage.kMinWidthY * 0.5 + kage.kMinWidthY);
\r
200 poly.push(x1 + kage.kMinWidthT, y1 + kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2);
\r
201 polygons.push(poly);
\r
204 poly = new Polygon();
\r
205 poly.push(x1 + kage.kMinWidthT * XX + (kage.kMinWidthY * 0.5) * YX,
\r
206 y1 + kage.kMinWidthT * XY + (kage.kMinWidthY * 0.5) * YY);
\r
207 poly.push(x1 + (kage.kMinWidthT + kage.kMinWidthT * 0.5) * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY) * YX,
\r
208 y1 + (kage.kMinWidthT + kage.kMinWidthT * 0.5) * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY) * YY);
\r
209 poly.push(x1 + kage.kMinWidthT * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YX,
\r
210 y1 + kage.kMinWidthT * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YY);
\r
211 polygons.push(poly);
\r
214 else{ //from bottom to up
\r
215 if(x1 == x2){ //is it right?
\r
216 poly = new Polygon();
\r
217 poly.push(x1 + kage.kMinWidthT, y1 - kage.kMinWidthY * 0.5);
\r
218 poly.push(x1 + kage.kMinWidthT + kage.kMinWidthT * 0.5, y1 - kage.kMinWidthY * 0.5 - kage.kMinWidthY);
\r
219 poly.push(x1 + kage.kMinWidthT, y1 - kage.kMinWidthY * 0.5 - kage.kMinWidthY * 2);
\r
220 polygons.push(poly);
\r
222 else{ //SETSUGOUMEN GA KAKERUNODE HOKYOU
\r
223 poly = new Polygon();
\r
224 poly.push(x1 - (kage.kMinWidthT - 1) * XX + (kage.kMinWidthY * 0.5) * YX,
\r
225 y1 - (kage.kMinWidthT - 1) * XY + (kage.kMinWidthY * 0.5) * YY);
\r
226 poly.push(x1 - (kage.kMinWidthT - 0) * XX + (kage.kMinWidthY * 0.5) * YX,
\r
227 y1 - (kage.kMinWidthT - 0) * XY + (kage.kMinWidthY * 0.5) * YY);
\r
228 poly.push(x1 - (kage.kMinWidthT + kage.kMinWidthT * 0.5) * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY) * YX,
\r
229 y1 - (kage.kMinWidthT + kage.kMinWidthT * 0.5) * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY) * YY);
\r
230 poly.push(x1 - (kage.kMinWidthT - 0) * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YX,
\r
231 y1 - (kage.kMinWidthT - 0) * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YY);
\r
232 poly.push(x1 - (kage.kMinWidthT - 1) * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YX,
\r
233 y1 - (kage.kMinWidthT - 1) * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YY);
\r
234 polygons.push(poly);
\r
240 rad = Math.atan((y4 - y3) / (x4 - x3));
\r
241 if(x3 < x4){ v = 1; } else{ v = -1; }
\r
242 YX = Math.sin(rad) * v * -1;
\r
243 YY = Math.cos(rad) * v;
\r
244 XX = Math.cos(rad) * v;
\r
245 XY = Math.sin(rad) * v;
\r
247 if(a2 == 1 || a2 == 8 || a2 == 15){ //the last filled circle
\r
250 poly.push(x4 - kage.kMinWidthT, y4);
\r
251 poly.push(x4 - kage.kMinWidthT * 0.6, y4 + kage.kMinWidthT * 0.6);
\r
252 poly.push(x4, y4 + kage.kMinWidthT);
\r
253 poly.push(x4 + kage.kMinWidthT * 0.6, y4 + kage.kMinWidthT * 0.6);
\r
254 poly.push(x4 + kage.kMinWidthT, y4);
\r
255 polygons.push(poly);
\r
258 poly = new Polygon();
\r
259 poly.push(x4, y4 - kage.kMinWidthT);
\r
260 poly.push(x4 + kage.kMinWidthT * 0.6, y4 - kage.kMinWidthT * 0.6);
\r
261 poly.push(x4 + kage.kMinWidthT, y4);
\r
262 poly.push(x4 + kage.kMinWidthT * 0.6, y4 + kage.kMinWidthT * 0.6);
\r
263 poly.push(x4, y4 + kage.kMinWidthT);
\r
264 polygons.push(poly);
\r
267 poly = new Polygon();
\r
268 poly.push(x4 + Math.sin(rad) * kage.kMinWidthT * v, y4 - Math.cos(rad) * kage.kMinWidthT * v);
\r
269 poly.push(x4 + Math.cos(rad) * kage.kMinWidthT * 0.8 * v + Math.sin(rad) * kage.kMinWidthT * 0.6 * v,
\r
270 y4 + Math.sin(rad) * kage.kMinWidthT * 0.8 * v - Math.cos(rad) * kage.kMinWidthT * 0.6 * v);
\r
271 poly.push(x4 + Math.cos(rad) * kage.kMinWidthT * v, y4 + Math.sin(rad) * kage.kMinWidthT * v);
\r
272 poly.push(x4 + Math.cos(rad) * kage.kMinWidthT * 0.8 * v - Math.sin(rad) * kage.kMinWidthT * 0.6 * v,
\r
273 y4 + Math.sin(rad) * kage.kMinWidthT * 0.8 * v + Math.cos(rad) * kage.kMinWidthT * 0.6 * v);
\r
274 poly.push(x4 - Math.sin(rad) * kage.kMinWidthT * v, y4 + Math.cos(rad) * kage.kMinWidthT * v);
\r
275 polygons.push(poly);
\r
279 if(a2 == 9 || (a1 == 7 && a2 == 0)){ // Math.sinnyu & L2RD Harai
\r
281 poly = new Polygon();
\r
282 poly.push(x4, y4 + kage.kMinWidthT);
\r
283 poly.push(x4, y4 - kage.kMinWidthT);
\r
284 poly.push(x4 + kage.kMinWidthT, y4 - kage.kMinWidthT);
\r
285 polygons.push(poly);
\r
288 poly = new Polygon();
\r
289 poly.push(x4 + kage.kMinWidthT * YX, y4 + kage.kMinWidthT * YY);
\r
290 poly.push(x4 - kage.kMinWidthT * YX, y4 - kage.kMinWidthT * YY);
\r
291 poly.push(x4 + kage.kMinWidthT * XX - kage.kMinWidthT * YX, y4 + kage.kMinWidthT * XY - kage.kMinWidthT * YY);
\r
292 polygons.push(poly);
\r
296 if(a2 == 15){ //jump up
\r
298 poly = new Polygon();
\r
299 poly.push(x4, y4 - kage.kMinWidthT + 1);
\r
300 poly.push(x4 + 2, y4 - kage.kMinWidthT - kage.kWidth * 5);
\r
301 poly.push(x4, y4 - kage.kMinWidthT - kage.kWidth * 5);
\r
302 poly.push(x4 - kage.kMinWidthT, y4 - kage.kMinWidthT + 1);
\r
303 polygons.push(poly);
\r
306 poly = new Polygon();
\r
307 poly.push(x4 + (kage.kMinWidthT - 1) * Math.sin(rad) * v, y4 - (kage.kMinWidthT - 1) * Math.cos(rad) * v);
\r
308 poly.push(x4 + 2 * Math.cos(rad) * v + (kage.kMinWidthT + kage.kWidth * 5) * Math.sin(rad) * v,
\r
309 y4 + 2 * Math.sin(rad) * v - (kage.kMinWidthT + kage.kWidth * 5) * Math.cos(rad) * v);
\r
310 poly.push(x4 + (kage.kMinWidthT + kage.kWidth * 5) * Math.sin(rad) * v,
\r
311 y4 - (kage.kMinWidthT + kage.kWidth * 5) * Math.cos(rad) * v);
\r
312 poly.push(x4 + (kage.kMinWidthT - 1) * Math.sin(rad) * v - kage.kMinWidthT * Math.cos(rad) * v,
\r
313 y4 - (kage.kMinWidthT - 1) * Math.cos(rad) * v - kage.kMinWidthT * Math.sin(rad) * v);
\r
314 polygons.push(poly);
\r
318 if(a2 == 14){ //jump to left, allways go left
\r
319 poly = new Polygon();
\r
321 poly.push(x4, y4 - kage.kMinWidthT);
\r
322 poly.push(x4 - kage.kWidth * 4, y4 - kage.kMinWidthT);
\r
323 poly.push(x4 - kage.kWidth * 4, y4 - kage.kMinWidthT * 0.5);
\r
324 polygons.push(poly);
\r
330 if(y1 < y2){ y1 = y1 - kage.kWidth; } else{ y1 = y1 + kage.kWidth; }
\r
333 if(x1 < x2){ x1 = x1 - kage.kWidth; } else{ x1 = x1 + kage.kWidth; }
\r
336 rad = Math.atan((y2 - y1) / (x2 - x1));
\r
337 if(x1 < x2){ v = 1; } else{ v = -1; }
\r
338 x1 = x1 - kage.kWidth * Math.cos(rad) * v;
\r
339 y1 = y1 - kage.kWidth * Math.sin(rad) * v;
\r
346 y1 = y1 - kage.kWidth * kage.kKakato;
\r
349 y1 = y1 + kage.kWidth * kage.kKakato;
\r
354 x1 = x1 - kage.kWidth * kage.kKakato;
\r
357 x1 = x1 + kage.kWidth * kage.kKakato;
\r
361 rad = Math.atan((y2 - y1) / (x2 - x1));
\r
362 if(x1 < x2){ v = 1; } else{ v = -1; }
\r
363 x1 = x1 - kage.kWidth * Math.cos(rad) * v * kage.kKakato;
\r
364 y1 = y1 - kage.kWidth * Math.sin(rad) * v * kage.kKakato;
\r
369 if(y3 < y4){ y4 = y4 + kage.kWidth; } else{ y4 = y4 - kage.kWidth; }
\r
372 if(x3 < x4){ x4 = x4 + kage.kWidth; } else{ x4 = x4 - kage.kWidth; }
\r
375 rad = Math.atan((y4 - y3) / (x4 - x3));
\r
376 if(x3 < x4){ v = 1; } else{ v = -1; }
\r
377 x4 = x4 + kage.kWidth * Math.cos(rad) * v;
\r
378 y4 = y4 + kage.kWidth * Math.sin(rad) * v;
\r
385 y4 = y4 + kage.kWidth * kage.kKakato;
\r
388 y4 = y4 - kage.kWidth * kage.kKakato;
\r
393 x4 = x4 + kage.kWidth * kage.kKakato;
\r
396 x4 = x4 - kage.kWidth * kage.kKakato;
\r
400 rad = Math.atan((y4 - y3) / (x4 - x3));
\r
401 if(x3 < x4){ v = 1; } else{ v = -1; }
\r
402 x4 = x4 + kage.kWidth * Math.cos(rad) * v * kage.kKakato;
\r
403 y4 = y4 + kage.kWidth * Math.sin(rad) * v * kage.kKakato;
\r
407 poly = new Polygon();
\r
408 poly2= new Polygon();
\r
410 for(tt = 0; tt <= 1000; tt = tt + kage.kRate){
\r
414 x = (1.0 - t) * (1.0 - t) * (1.0 - t) * x1 + 3.0 * t * (1.0 - t) * (1.0 - t) * x2 + 3 * t * t * (1.0 - t) * x3 + t * t * t * x4;
\r
415 y = (1.0 - t) * (1.0 - t) * (1.0 - t) * y1 + 3.0 * t * (1.0 - t) * (1.0 - t) * y2 + 3 * t * t * (1.0 - t) * y3 + t * t * t * y4;
\r
416 //KATAMUKI of vector by BIBUN
\r
417 ix = t * t * (-3 * x1 + 9 * x2 + -9 * x3 + 3 * x4) + t * (6 * x1 + -12 * x2 + 6 * x3) + -3 * x1 + 3 * x2;
\r
418 iy = t * t * (-3 * y1 + 9 * y2 + -9 * y3 + 3 * y4) + t * (6 * y1 + -12 * y2 + 6 * y3) + -3 * y1 + 3 * y2;
\r
420 //SESSEN NI SUICHOKU NA CHOKUSEN NO KEISAN
\r
421 if(kage.kShotai == kage.kMincho){ //always false ?
\r
422 if(ix != 0 && iy != 0){
\r
423 ir = Math.atan(iy / ix * -1.0);
\r
424 ia = Math.sin(ir) * kage.kMinWidthT;
\r
425 ib = Math.cos(ir) * kage.kMinWidthT;
\r
428 ia = kage.kMinWidthT;
\r
433 ib = kage.kMinWidthT;
\r
435 ia = ia * Math.sqrt(1.0 - t);
\r
436 ib = ib * Math.sqrt(1.0 - t);
\r
439 if(ix != 0 && iy != 0){
\r
440 ir = Math.atan(iy / ix * -1.0);
\r
441 ia = Math.sin(ir) * kage.kWidth;
\r
442 ib = Math.cos(ir) * kage.kWidth;
\r
454 //reverse if vector is going 2nd/3rd quadrants
\r
461 poly.push(x - ia, y - ib);
\r
462 poly2.push(x + ia, y + ib);
\r
466 poly.concat(poly2);
\r
467 polygons.push(poly);
\r
471 function cdDrawCurve(kage, polygons, x1, y1, x2, y2, x3, y3, a1, a2){
\r
474 var ix, iy, ia, ib, ir;
\r
478 var XX, XY, YX, YY;
\r
481 if(kage.kShotai == kage.kMincho){ // mincho
\r
485 delta = -1 * kage.kMinWidthY * 0.5;
\r
495 delta = kage.kMinWidthY;
\r
502 if(y1 < y2){ y1 = y1 - delta; }
\r
503 else{ y1 = y1 + delta; }
\r
506 if(x1 < x2){ x1 = x1 - delta; }
\r
507 else{ x1 = x1 + delta; }
\r
510 rad = Math.atan((y2 - y1) / (x2 - x1));
\r
511 if(x1 < x2){ v = 1; } else{ v = -1; }
\r
512 x1 = x1 - delta * Math.cos(rad) * v;
\r
513 y1 = y1 - delta * Math.sin(rad) * v;
\r
527 case 8: // get shorten for tail's circle
\r
528 delta = -1 * kage.kMinWidthT * 0.5;
\r
535 if(y2 < y3){ y3 = y3 + delta; }
\r
536 else{ y3 = y3 - delta; }
\r
539 if(x2 < x3){ x3 = x3 + delta; }
\r
540 else{ x3 = x3 - delta; }
\r
543 rad = Math.atan((y3 - y2) / (x3 - x2));
\r
544 if(x2 < x3){ v = 1; } else{ v = -1; }
\r
545 x3 = x3 + delta * Math.cos(rad) * v;
\r
546 y3 = y3 + delta * Math.sin(rad) * v;
\r
549 poly = new Polygon();
\r
550 poly2 = new Polygon();
\r
552 for(tt = 0; tt <= 1000; tt = tt + kage.kRate){
\r
556 x = ((1.0 - t) * (1.0 - t) * x1 + 2.0 * t * (1.0 - t) * x2 + t * t * x3);
\r
557 y = ((1.0 - t) * (1.0 - t) * y1 + 2.0 * t * (1.0 - t) * y2 + t * t * y3);
\r
559 //KATAMUKI of vector by BIBUN
\r
560 ix = (x1 - 2.0 * x2 + x3) * 2.0 * t + (-2.0 * x1 + 2.0 * x2);
\r
561 iy = (y1 - 2.0 * y2 + y3) * 2.0 * t + (-2.0 * y1 + 2.0 * y2);
\r
563 //line SUICHOKU by vector
\r
564 if(ix != 0 && iy != 0){
\r
565 ir = Math.atan(iy / ix * -1);
\r
566 ia = Math.sin(ir) * (kage.kMinWidthT);
\r
567 ib = Math.cos(ir) * (kage.kMinWidthT);
\r
570 ia = kage.kMinWidthT;
\r
575 ib = kage.kMinWidthT;
\r
578 if(a1 == 7 && a2 == 0){ deltad = Math.sqrt(t) * kage.kL2RDfatten; } //L2RD: fatten
\r
579 else if(a1 == 7){ deltad = Math.sqrt(t); }
\r
580 else if(a2 == 7){ deltad = Math.sqrt(1.0 - t); }
\r
581 else{ deltad = 1; }
\r
585 //reverse if vector is going 2nd/3rd quadrants
\r
591 //copy to polygon structure
\r
592 poly.push(x - ia, y - ib);
\r
593 poly2.push(x + ia, y + ib);
\r
597 poly.concat(poly2);
\r
598 polygons.push(poly);
\r
600 //process for head of stroke
\r
601 rad = Math.atan((y2 - y1) / (x2 - x1));
\r
602 if(x1 < x2){ v = 1; } else{ v = -1; }
\r
603 XX = Math.sin(rad) * v;
\r
604 XY = Math.cos(rad) * v * -1;
\r
605 YX = Math.cos(rad) * v;
\r
606 YY = Math.sin(rad) * v;
\r
610 poly= new Polygon();
\r
611 poly.push(x1 - kage.kMinWidthT, y1);
\r
612 poly.push(x1 + kage.kMinWidthT, y1);
\r
613 poly.push(x1 - kage.kMinWidthT, y1 - kage.kMinWidthT);
\r
614 polygons.push(poly);
\r
617 poly = new Polygon();
\r
618 poly.push(x1 - kage.kMinWidthT * XX, y1 - kage.kMinWidthT * XY);
\r
619 poly.push(x1 + kage.kMinWidthT * XX, y1 + kage.kMinWidthT * XY);
\r
620 poly.push(x1 - kage.kMinWidthT * XX - kage.kMinWidthT * YX, y1 - kage.kMinWidthT * XY - kage.kMinWidthT * YY);
\r
621 polygons.push(poly);
\r
626 if(y1 <= y3){ //from up to bottom
\r
628 poly = new Polygon();
\r
629 poly.push(x1 - kage.kMinWidthT, y1);
\r
630 poly.push(x1 + kage.kMinWidthT, y1);
\r
631 poly.push(x1 - kage.kMinWidthT, y1 - kage.kMinWidthY);
\r
632 polygons.push(poly);
\r
635 poly = new Polygon();
\r
636 poly.push(x1 - kage.kMinWidthT * XX, y1 - kage.kMinWidthT * XY);
\r
637 poly.push(x1 + kage.kMinWidthT * XX, y1 + kage.kMinWidthT * XY);
\r
638 poly.push(x1 - kage.kMinWidthT * XX - kage.kMinWidthY * YX, y1 - kage.kMinWidthT * XY - kage.kMinWidthY * YY);
\r
639 polygons.push(poly);
\r
642 else{ //bottom to up
\r
643 if(x1 == x2){ //is it right?
\r
644 poly = new Polygon();
\r
645 poly.push(x1 - kage.kMinWidthT, y1);
\r
646 poly.push(x1 + kage.kMinWidthT, y1);
\r
647 poly.push(x1 - kage.kMinWidthT, y1 + kage.kMinWidthY);
\r
648 polygons.push(poly);
\r
651 poly = new Polygon();
\r
652 poly.push(x1 - kage.kMinWidthT * XX, y1 - kage.kMinWidthT * XY);
\r
653 poly.push(x1 + kage.kMinWidthT * XX, y1 + kage.kMinWidthT * XY);
\r
654 poly.push(x1 + kage.kMinWidthT * XX - kage.kMinWidthY * YX, y1 + kage.kMinWidthT * XY - kage.kMinWidthY * YY);
\r
655 polygons.push(poly);
\r
660 if(a1 == 22){ //box's up-right corner, any time same degree
\r
661 poly = new Polygon();
\r
662 poly.push(x1 - kage.kMinWidthT, y1 - kage.kMinWidthY);
\r
663 poly.push(x1, y1 - kage.kMinWidthY - kage.kWidth);
\r
664 poly.push(x1 + kage.kMinWidthT + kage.kWidth, y1 + kage.kMinWidthY);
\r
665 poly.push(x1 + kage.kMinWidthT, y1 + kage.kMinWidthT);
\r
666 poly.push(x1 - kage.kMinWidthT, y1);
\r
667 polygons.push(poly);
\r
670 if(a1 == 0){ //beginning of the stroke
\r
671 if(y1 <= y3){ //from up to bottom
\r
673 poly = new Polygon();
\r
674 poly.push(x1 + kage.kMinWidthT, y1 + kage.kMinWidthY * 0.5);
\r
675 poly.push(x1 + kage.kMinWidthT + kage.kMinWidthT * 0.5, y1 + kage.kMinWidthY * 0.5 + kage.kMinWidthY);
\r
676 poly.push(x1 + kage.kMinWidthT, y1 + kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2);
\r
677 polygons.push(poly);
\r
680 poly = new Polygon();
\r
681 poly.push(x1 + kage.kMinWidthT * XX + (kage.kMinWidthY * 0.5) * YX,
\r
682 y1 + kage.kMinWidthT * XY + (kage.kMinWidthY * 0.5) * YY);
\r
683 poly.push(x1 + (kage.kMinWidthT + kage.kMinWidthT * 0.5) * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY) * YX,
\r
684 y1 + (kage.kMinWidthT + kage.kMinWidthT * 0.5) * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY) * YY);
\r
685 poly.push(x1 + kage.kMinWidthT * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YX,
\r
686 y1 + kage.kMinWidthT * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YY);
\r
687 polygons.push(poly);
\r
690 else{ //from bottom to up
\r
691 if(x1 == x2){ //is it right?
\r
692 poly = new Polygon();
\r
693 poly.push(x1 + kage.kMinWidthT, poly2[0].Y = y1 - kage.kMinWidthY * 0.5);
\r
694 poly.push(x1 + kage.kMinWidthT + kage.kMinWidthT * 0.5, y1 - kage.kMinWidthY * 0.5 - kage.kMinWidthY);
\r
695 poly.push(x1 + kage.kMinWidthT, y1 - kage.kMinWidthY * 0.5 - kage.kMinWidthY * 2);
\r
696 polygons.push(poly);
\r
698 else{ //SETSUGOUMEN GA KAKERUNODE HOKYOU
\r
699 poly = new Polygon();
\r
700 poly.push(x1 - (kage.kMinWidthT - 1) * XX + (kage.kMinWidthY * 0.5) * YX,
\r
701 y1 - (kage.kMinWidthT - 1) * XY + (kage.kMinWidthY * 0.5) * YY);
\r
702 poly.push(x1 - (kage.kMinWidthT - 0) * XX + (kage.kMinWidthY * 0.5) * YX,
\r
703 y1 - (kage.kMinWidthT - 0) * XY + (kage.kMinWidthY * 0.5) * YY);
\r
704 poly.push(x1 - (kage.kMinWidthT + kage.kMinWidthT * 0.5) * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY) * YX,
\r
705 y1 - (kage.kMinWidthT + kage.kMinWidthT * 0.5) * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY) * YY);
\r
706 poly.push(x1 - (kage.kMinWidthT - 0) * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YX,
\r
707 y1 - (kage.kMinWidthT - 0) * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YY);
\r
708 poly.push(x1 - (kage.kMinWidthT - 1) * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YX,
\r
709 y1 - (kage.kMinWidthT - 1) * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YY);
\r
710 polygons.push(poly);
\r
716 rad = Math.atan((y3 - y2) / (x3 - x2));
\r
717 if(x2 < x3){ v = 1; } else{ v = -1; }
\r
718 YX = Math.sin(rad) * v * -1;
\r
719 YY = Math.cos(rad) * v;
\r
720 XX = Math.cos(rad) * v;
\r
721 XY = Math.sin(rad) * v;
\r
723 if(a2 == 1 || a2 == 8 || a2 == 15){ //the last filled circle
\r
725 poly = new Polygon();
\r
726 poly.push(x3 - kage.kMinWidthT, y3);
\r
727 poly.push(x3 - kage.kMinWidthT * 0.6, y3 + kage.kMinWidthT * 0.6);
\r
728 poly.push(x3, y3 + kage.kMinWidthT);
\r
729 poly.push(x3 + kage.kMinWidthT * 0.6, y3 + kage.kMinWidthT * 0.6);
\r
730 poly.push(x3 + kage.kMinWidthT, y3);
\r
731 polygons.push(poly);
\r
734 poly = new Polygon();
\r
735 poly.push(x3, y3 - kage.kMinWidthT);
\r
736 poly.push(x3 + kage.kMinWidthT * 0.6, y3 - kage.kMinWidthT * 0.6);
\r
737 poly.push(x3 + kage.kMinWidthT, y3);
\r
738 poly.push(x3 + kage.kMinWidthT * 0.6, y3 + kage.kMinWidthT * 0.6);
\r
739 poly.push(x3, y3 + kage.kMinWidthT);
\r
740 polygons.push(poly);
\r
743 poly = new Polygon();
\r
744 poly.push(x3 + Math.sin(rad) * kage.kMinWidthT * v, y3 - Math.cos(rad) * kage.kMinWidthT * v);
\r
745 poly.push(x3 + Math.cos(rad) * kage.kMinWidthT * 0.8 * v + Math.sin(rad) * kage.kMinWidthT * 0.6 * v,
\r
746 y3 + Math.sin(rad) * kage.kMinWidthT * 0.8 * v - Math.cos(rad) * kage.kMinWidthT * 0.6 * v);
\r
747 poly.push(x3 + Math.cos(rad) * kage.kMinWidthT * v, y3 + Math.sin(rad) * kage.kMinWidthT * v);
\r
748 poly.push(x3 + Math.cos(rad) * kage.kMinWidthT * 0.8 * v - Math.sin(rad) * kage.kMinWidthT * 0.6 * v,
\r
749 y3 + Math.sin(rad) * kage.kMinWidthT * 0.8 * v + Math.cos(rad) * kage.kMinWidthT * 0.6 * v);
\r
750 poly.push(x3 - Math.sin(rad) * kage.kMinWidthT * v, y3 + Math.cos(rad) * kage.kMinWidthT * v);
\r
751 polygons.push(poly);
\r
755 if(a2 == 9 || (a1 == 7 && a2 == 0)){ // Math.sinnyu & L2RD Harai
\r
757 poly = new Polygon();
\r
758 poly.push(x3, y3 + kage.kMinWidthT * kage.kL2RDfatten);
\r
759 poly.push(x3, y3 - kage.kMinWidthT * kage.kL2RDfatten);
\r
760 poly.push(x3 + kage.kMinWidthT * kage.kL2RDfatten, y3 - kage.kMinWidthT * kage.kL2RDfatten);
\r
761 polygons.push(poly);
\r
764 poly = new Polygon();
\r
765 poly.push(x3 + kage.kMinWidthT * kage.kL2RDfatten * YX, y3 + kage.kMinWidthT * kage.kL2RDfatten * YY);
\r
766 poly.push(x3 - kage.kMinWidthT * kage.kL2RDfatten * YX, y3 - kage.kMinWidthT * kage.kL2RDfatten * YY);
\r
767 poly.push(x3 + kage.kMinWidthT * kage.kL2RDfatten * XX - kage.kMinWidthT * kage.kL2RDfatten * YX,
\r
768 y3 + kage.kMinWidthT * kage.kL2RDfatten * XY - kage.kMinWidthT * kage.kL2RDfatten * YY);
\r
769 polygons.push(poly);
\r
773 if(a2 == 15){ //jump up
\r
775 poly = new Polygon();
\r
776 poly.push(x3, y3 - kage.kMinWidthT + 1);
\r
777 poly.push(x3 + 2, y3 - kage.kMinWidthT - kage.kWidth * 5);
\r
778 poly.push(x3, y3 - kage.kMinWidthT - kage.kWidth * 5);
\r
779 poly.push(x3 - kage.kMinWidthT, y3 - kage.kMinWidthT + 1);
\r
780 polygons.push(poly);
\r
783 poly = new Polygon();
\r
784 poly.push(x3 + (kage.kMinWidthT - 1) * Math.sin(rad) * v, y3 - (kage.kMinWidthT - 1) * Math.cos(rad) * v);
\r
785 poly.push(x3 + 2 * Math.cos(rad) * v + (kage.kMinWidthT + kage.kWidth * 5) * Math.sin(rad) * v,
\r
786 y3 + 2 * Math.sin(rad) * v - (kage.kMinWidthT + kage.kWidth * 5) * Math.cos(rad) * v);
\r
787 poly.push(x3 + (kage.kMinWidthT + kage.kWidth * 5) * Math.sin(rad) * v,
\r
788 y3 - (kage.kMinWidthT + kage.kWidth * 5) * Math.cos(rad) * v);
\r
789 poly.push(x3 + (kage.kMinWidthT - 1) * Math.sin(rad) * v - kage.kMinWidthT * Math.cos(rad) * v,
\r
790 y3 - (kage.kMinWidthT - 1) * Math.cos(rad) * v - kage.kMinWidthT * Math.sin(rad) * v);
\r
791 polygons.push(poly);
\r
795 if(a2 == 14){ //jump to left, allways go left
\r
796 poly = new Polygon();
\r
798 poly.push(x3, y3 - kage.kMinWidthT);
\r
799 poly.push(x3 - kage.kWidth * 4, y3 - kage.kMinWidthT);
\r
800 poly.push(x3 - kage.kWidth * 4, y3 - kage.kMinWidthT * 0.5);
\r
801 polygons.push(poly);
\r
807 if(y1 < y2){ y1 = y1 - kage.kWidth; } else{ y1 = y1 + kage.kWidth; }
\r
810 if(x1 < x2){ x1 = x1 - kage.kWidth; } else{ x1 = x1 + kage.kWidth; }
\r
813 rad = Math.atan((y2 - y1) / (x2 - x1));
\r
814 if(x1 < x2){ v = 1; } else{ v = -1; }
\r
815 x1 = x1 - kage.kWidth * Math.cos(rad) * v;
\r
816 y1 = y1 - kage.kWidth * Math.sin(rad) * v;
\r
823 y1 = y1 - kage.kWidth * kage.kKakato;
\r
826 y1 = y1 + kage.kWidth * kage.kKakato;
\r
831 x1 = x1 - kage.kWidth * kage.kKakato;
\r
834 x1 = x1 + kage.kWidth * kage.kKakato;
\r
838 rad = Math.atan((y2 - y1) / (x2 - x1));
\r
839 if(x1 < x2){ v = 1; } else{ v = -1; }
\r
840 x1 = x1 - kage.kWidth * Math.cos(rad) * v * kage.kKakato;
\r
841 y1 = y1 - kage.kWidth * Math.sin(rad) * v * kage.kKakato;
\r
846 if(y2 < y3){ y3 = y3 + kage.kWidth; } else{ y3 = y3 - kage.kWidth; }
\r
849 if(x2 < x3){ x3 = x3 + kage.kWidth; } else{ x3 = x3 - kage.kWidth; }
\r
852 rad = Math.atan((y3 - y2) / (x3 - x2));
\r
853 if(x2 < x3){ v = 1; } else{ v = -1; }
\r
854 x3 = x3 + kage.kWidth * Math.cos(rad) * v;
\r
855 y3 = y3 + kage.kWidth * Math.sin(rad) * v;
\r
862 y3 = y3 + kage.kWidth * kage.kKakato;
\r
865 y3 = y3 - kage.kWidth * kage.kKakato;
\r
870 x3 = x3 + kage.kWidth * kage.kKakato;
\r
873 x3 = x3 - kage.kWidth * kage.kKakato;
\r
877 rad = Math.atan((y3 - y2) / (x3 - x2));
\r
878 if(x2 < x3){ v = 1; } else{ v = -1; }
\r
879 x3 = x3 + kage.kWidth * Math.cos(rad) * v * kage.kKakato;
\r
880 y3 = y3 + kage.kWidth * Math.sin(rad) * v * kage.kKakato;
\r
884 poly = new Polygon();
\r
885 poly2 = new Polygon();
\r
887 for(tt = 0; tt <= 1000; tt = tt + kage.kRate){
\r
890 //calculating each point
\r
891 x = ((1.0 - t) * (1.0 - t) * x1 + 2.0 * t * (1.0 - t) * x2 + t * t * x3);
\r
892 y = ((1.0 - t) * (1.0 - t) * y1 + 2.0 * t * (1.0 - t) * y2 + t * t * y3);
\r
894 //SESSEN NO KATAMUKI NO KEISAN(BIBUN)
\r
895 ix = (x1 - 2.0 * x2 + x3) * 2.0 * t + (-2.0 * x1 + 2.0 * x2);
\r
896 iy = (y1 - 2.0 * y2 + y3) * 2.0 * t + (-2.0 * y1 + 2.0 * y2);
\r
898 //SESSEN NI SUICHOKU NA CHOKUSEN NO KEISAN
\r
899 if(kage.kShotai == kage.kMincho){ //always false ?
\r
900 if(ix != 0 && iy != 0){
\r
901 ir = Math.atan(iy / ix * -1.0);
\r
902 ia = Math.sin(ir) * kage.kMinWidthT;
\r
903 ib = Math.cos(ir) * kage.kMinWidthT;
\r
906 ia = kage.kMinWidthT;
\r
911 ib = kage.kMinWidthT;
\r
913 ia = ia * Math.sqrt(1.0 - t);
\r
914 ib = ib * Math.sqrt(1.0 - t);
\r
917 if(ix != 0 && iy != 0){
\r
918 ir = Math.atan(iy / ix * -1.0);
\r
919 ia = Math.sin(ir) * kage.kWidth;
\r
920 ib = Math.cos(ir) * kage.kWidth;
\r
932 //reverse if vector is going 2nd/3rd quadrants
\r
939 poly.push(x - ia, y - ib);
\r
940 poly2.push(x + ia, y + ib);
\r
944 poly.concat(poly2);
\r
945 polygons.push(poly);
\r
949 function cdDrawLine(kage, polygons, tx1, ty1, tx2, ty2, ta1, ta2){
\r
951 var v, x1, y1, x2, y2;
\r
953 var XX, XY, YX, YY;
\r
956 if(kage.kShotai == kage.kMincho){ //mincho
\r
964 if(x1 == x2){ //if TATE stroke, use y-axis
\r
965 poly = new Polygon(4);
\r
968 poly.set(3, x1 - kage.kMinWidthT, y1 - kage.kMinWidthY / 2);
\r
969 poly.set(0, x1 + kage.kMinWidthT, y1 + kage.kMinWidthY / 2);
\r
974 poly.set(3, x1 - kage.kMinWidthT, y1);
\r
975 poly.set(0, x1 + kage.kMinWidthT, y1);
\r
978 poly.set(3, x1 - kage.kMinWidthT, y1 - kage.kMinWidthY - kage.kMinWidthT);
\r
979 poly.set(0, x1 + kage.kMinWidthT, y1 - kage.kMinWidthY);
\r
982 poly.set(3, x1 - kage.kMinWidthT, y1 - kage.kMinWidthY);
\r
983 poly.set(0, x1 + kage.kMinWidthT, y1 - kage.kMinWidthY);
\r
989 if(a1 == 6){ //KAGI's tail
\r
990 poly.set(2, x2 - kage.kMinWidthT, y2);
\r
991 poly.set(1, x2 + kage.kMinWidthT, y2);
\r
994 poly.set(2, x2 - kage.kMinWidthT, y2 + kage.kMinWidthT / 2);
\r
995 poly.set(1, x2 + kage.kMinWidthT, y2 - kage.kMinWidthT / 2);
\r
999 poly.set(2, x2 - kage.kMinWidthT, y2);
\r
1000 poly.set(1, x2 + kage.kMinWidthT, y2);
\r
1003 poly.set(2, x2 - kage.kMinWidthT, y2 + kage.kWidth * kage.kKakato + kage.kMinWidthT);
\r
1004 poly.set(1, x2 + kage.kMinWidthT, y2 + kage.kWidth * kage.kKakato);
\r
1007 poly.set(2, x2 - kage.kMinWidthT, y2 + kage.kWidth * kage.kKakato * 0.5 + kage.kMinWidthT);
\r
1008 poly.set(1, x2 + kage.kMinWidthT, y2 + kage.kWidth * kage.kKakato * 0.5);
\r
1011 poly.set(2, x2 - kage.kMinWidthT, y2 + kage.kMinWidthY);
\r
1012 poly.set(1, x2 + kage.kMinWidthT, y2 + kage.kMinWidthY);
\r
1016 polygons.push(poly);
\r
1018 if(a1 == 22){ //box's right top corner
\r
1019 poly = new Polygon();
\r
1020 poly.push(x1 - kage.kMinWidthT, y1 - kage.kMinWidthY);
\r
1021 poly.push(x1, y1 - kage.kMinWidthY - kage.kWidth);
\r
1022 poly.push(x1 + kage.kMinWidthT + kage.kWidth, y1 + kage.kMinWidthY);
\r
1023 poly.push(x1 + kage.kMinWidthT, y1 + kage.kMinWidthT);
\r
1024 poly.push(x1 - kage.kMinWidthT, y1);
\r
1025 polygons.push(poly);
\r
1028 if(a1 == 0){ //beginning of the stroke
\r
1029 poly = new Polygon();
\r
1030 poly.push(x1 + kage.kMinWidthT, y1 + kage.kMinWidthY * 0.5);
\r
1031 poly.push(x1 + kage.kMinWidthT + kage.kMinWidthT * 0.5, y1 + kage.kMinWidthY * 0.5 + kage.kMinWidthY);
\r
1032 poly.push(x1 + kage.kMinWidthT, y1 + kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2);
\r
1033 polygons.push(poly);
\r
1036 if((a1 == 6 && a2 == 0) || a2 == 1){ //KAGI NO YOKO BOU NO SAIGO NO MARU
\r
1037 poly = new Polygon();
\r
1038 poly.push(x2 - kage.kMinWidthT, y2);
\r
1039 poly.push(x2 - kage.kMinWidthT * 0.6, y2 + kage.kMinWidthT * 0.6);
\r
1040 poly.push(x2, y2 + kage.kMinWidthT);
\r
1041 poly.push(x2 + kage.kMinWidthT * 0.6, y2 + kage.kMinWidthT * 0.6);
\r
1042 poly.push(x2 + kage.kMinWidthT, y2);
\r
1043 poly.reverse(); // for fill-rule
\r
1044 polygons.push(poly);
\r
1047 else if(y1 == y2){ //if it is YOKO stroke, use x-axis
\r
1048 if(a1 == 6){ //if it is KAGI's YOKO stroke, get bold
\r
1049 poly = new Polygon();
\r
1050 poly.push(x1, y1 - kage.kMinWidthT);
\r
1051 poly.push(x2, y2 - kage.kMinWidthT);
\r
1052 poly.push(x2, y2 + kage.kMinWidthT);
\r
1053 poly.push(x1, y1 + kage.kMinWidthT);
\r
1054 polygons.push(poly);
\r
1056 if(a2 == 1 || a2 == 0 || a2 == 5){
\r
1057 //KAGI NO YOKO BOU NO SAIGO NO MARU
\r
1058 poly = new Polygon();
\r
1059 poly.push(x2, y2 - kage.kMinWidthT);
\r
1060 poly.push(x2 + kage.kMinWidthT * 0.6, y2 - kage.kMinWidthT * 0.6);
\r
1061 poly.push(x2 + kage.kMinWidthT, y2);
\r
1062 poly.push(x2 + kage.kMinWidthT * 0.6, y2 + kage.kMinWidthT * 0.6);
\r
1063 poly.push(x2, y2 + kage.kMinWidthT);
\r
1064 polygons.push(poly);
\r
1068 //KAGI NO YOKO BOU NO HANE
\r
1069 poly = new Polygon();
\r
1070 poly.push(x2, y2 - kage.kMinWidthT + 1);
\r
1071 poly.push(x2 + 2, y2 - kage.kMinWidthT - kage.kWidth * 5);
\r
1072 poly.push(x2, y2 - kage.kMinWidthT - kage.kWidth * 5);
\r
1073 poly.push(x2 - kage.kMinWidthT, y2 - kage.kMinWidthT + 1);
\r
1074 poly.reverse(); // for fill-rule
\r
1075 polygons.push(poly);
\r
1079 poly = new Polygon(4);
\r
1082 poly.set(0, x1, y1 - kage.kMinWidthY);
\r
1083 poly.set(3, x1, y1 + kage.kMinWidthY);
\r
1086 poly.set(0, x1 - kage.kMinWidthT, y1 - kage.kMinWidthY);
\r
1087 poly.set(3, x1 - kage.kMinWidthT, y1 + kage.kMinWidthY);
\r
1093 poly.set(1, x2, y2 - kage.kMinWidthY);
\r
1094 poly.set(2, x2, y2 + kage.kMinWidthY);
\r
1097 poly.set(1, x2 + kage.kMinWidthT, y2 - kage.kMinWidthY);
\r
1098 poly.set(2, x2 + kage.kMinWidthT, y2 + kage.kMinWidthY);
\r
1101 polygons.push(poly);
\r
1105 poly = new Polygon();
\r
1106 poly.push(x2, y2 - kage.kMinWidthY);
\r
1107 poly.push(x2 - 24, y2);
\r
1108 poly.push(x2 - 12, y2 - 12);
\r
1109 polygons.push(poly);
\r
1113 else{ //for others, use x-axis
\r
1114 rad = Math.atan((y2 - y1) / (x2 - x1));
\r
1115 if((Math.abs(y2 - y1) < Math.abs(x2 - x1)) && (a1 != 6) && (a2 != 6) && !(x1 > x2)){ //ASAI KAUDO
\r
1116 poly = new Polygon(4);
\r
1117 switch(a1){ //must be 0 or 2
\r
1119 poly.set(0, x1 + Math.sin(rad) * kage.kMinWidthY, y1 - Math.cos(rad) * kage.kMinWidthY);
\r
1120 poly.set(3, x1 - Math.sin(rad) * kage.kMinWidthY, y1 + Math.cos(rad) * kage.kMinWidthY);
\r
1123 poly.set(0, x1 + Math.sin(rad) * kage.kMinWidthY - kage.kMinWidthT * Math.cos(rad),
\r
1124 y1 - Math.cos(rad) * kage.kMinWidthY - kage.kMinWidthT * Math.sin(rad));
\r
1125 poly.set(3, x1 - Math.sin(rad) * kage.kMinWidthY - kage.kMinWidthT * Math.cos(rad),
\r
1126 y1 + Math.cos(rad) * kage.kMinWidthY - kage.kMinWidthT * Math.sin(rad));
\r
1130 switch(a2){ //must be 0 or 2
\r
1132 poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthY, y2 - Math.cos(rad) * kage.kMinWidthY);
\r
1133 poly.set(2, x2 - Math.sin(rad) * kage.kMinWidthY, y2 + Math.cos(rad) * kage.kMinWidthY);
\r
1136 poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthY + kage.kMinWidthT * Math.cos(rad),
\r
1137 y2 - Math.cos(rad) * kage.kMinWidthY + kage.kMinWidthT * Math.sin(rad));
\r
1138 poly.set(2, x2 - Math.sin(rad) * kage.kMinWidthY + kage.kMinWidthT * Math.cos(rad),
\r
1139 y2 + Math.cos(rad) * kage.kMinWidthY + kage.kMinWidthT * Math.sin(rad));
\r
1142 polygons.push(poly);
\r
1146 poly = new Polygon();
\r
1147 poly.push(x2 + Math.sin(rad) * kage.kMinWidthY, y2 - Math.cos(rad) * kage.kMinWidthY);
\r
1148 poly.push(x2 - Math.cos(rad) * 24, y2 - Math.sin(rad) * 24);
\r
1149 poly.push(x2 - Math.cos(rad) * 12 + Math.sin(rad) * 12, y2 - Math.sin(rad) * 12 - Math.cos(rad) * 12);
\r
1150 polygons.push(poly);
\r
1154 else{ //KAKUDO GA FUKAI or KAGI NO YOKO BOU
\r
1155 if(x1 > x2){ v = -1; } else{ v = 1; }
\r
1156 poly = new Polygon(4);
\r
1159 poly.set(0, x1 + Math.sin(rad) * kage.kMinWidthT * v + kage.kMinWidthY * Math.cos(rad) * 0.5 * v,
\r
1160 y1 - Math.cos(rad) * kage.kMinWidthT * v + kage.kMinWidthY * Math.sin(rad) * 0.5 * v);
\r
1161 poly.set(3, x1 - Math.sin(rad) * kage.kMinWidthT * v - kage.kMinWidthY * Math.cos(rad) * 0.5 * v,
\r
1162 y1 + Math.cos(rad) * kage.kMinWidthT * v - kage.kMinWidthY * Math.sin(rad) * 0.5 * v);
\r
1167 poly.set(0, x1 + Math.sin(rad) * kage.kMinWidthT * v, y1 - Math.cos(rad) * kage.kMinWidthT * v);
\r
1168 poly.set(3, x1 - Math.sin(rad) * kage.kMinWidthT * v, y1 + Math.cos(rad) * kage.kMinWidthT * v);
\r
1171 poly.set(0, x1 + Math.sin(rad) * kage.kMinWidthT * v - kage.kMinWidthY * Math.cos(rad) * v,
\r
1172 y1 - Math.cos(rad) * kage.kMinWidthT * v - kage.kMinWidthY * Math.sin(rad) * v);
\r
1173 poly.set(3, x1 - Math.sin(rad) * kage.kMinWidthT * v - (kage.kMinWidthT + kage.kMinWidthY) * Math.cos(rad) * v,
\r
1174 y1 + Math.cos(rad) * kage.kMinWidthT * v - (kage.kMinWidthT + kage.kMinWidthY) * Math.sin(rad) * v);
\r
1177 poly.set(0, x1 + Math.sin(rad) * kage.kMinWidthT * v - kage.kMinWidthY * Math.cos(rad) * v,
\r
1178 y1 - Math.cos(rad) * kage.kMinWidthT * v - kage.kMinWidthY * Math.sin(rad) * v);
\r
1179 poly.set(3, x1 - Math.sin(rad) * kage.kMinWidthT * v - kage.kMinWidthY * Math.cos(rad) * v,
\r
1180 y1 + Math.cos(rad) * kage.kMinWidthT * v - kage.kMinWidthY * Math.sin(rad) * v);
\r
1187 poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthT * v, y2 - Math.cos(rad) * kage.kMinWidthT * v);
\r
1188 poly.set(2, x2 - Math.sin(rad) * kage.kMinWidthT * v, y2 + Math.cos(rad) * kage.kMinWidthT * v);
\r
1191 poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthT * v - kage.kMinWidthT * 0.5 * Math.cos(rad) * v,
\r
1192 y2 - Math.cos(rad) * kage.kMinWidthT * v - kage.kMinWidthT * 0.5 * Math.sin(rad) * v);
\r
1193 poly.set(2, x2 - Math.sin(rad) * kage.kMinWidthT * v + kage.kMinWidthT * 0.5 * Math.cos(rad) * v,
\r
1194 y2 + Math.cos(rad) * kage.kMinWidthT * v + kage.kMinWidthT * 0.5 * Math.sin(rad) * v);
\r
1199 poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthT * v, y2 - Math.cos(rad) * kage.kMinWidthT * v);
\r
1200 poly.set(2, x2 - Math.sin(rad) * kage.kMinWidthT * v, y2 + Math.cos(rad) * kage.kMinWidthT * v);
\r
1203 poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthT * v + kage.kWidth * kage.kKakato * Math.cos(rad) * v,
\r
1204 y2 - Math.cos(rad) * kage.kMinWidthT * v + kage.kWidth * kage.kKakato * Math.sin(rad) * v);
\r
1205 poly.set(2, x2 - Math.sin(rad) * kage.kMinWidthT * v + (kage.kWidth * kage.kKakato + kage.kMinWidthT) * Math.cos(rad) * v,
\r
1206 y2 + Math.cos(rad) * kage.kMinWidthT * v + (kage.kWidth * kage.kKakato + kage.kMinWidthT) * Math.sin(rad) * v);
\r
1209 poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthT * v + kage.kWidth * kage.kKakato * 0.5 * Math.cos(rad) * v,
\r
1210 y2 - Math.cos(rad) * kage.kMinWidthT * v + kage.kWidth * kage.kKakato * 0.5 * Math.sin(rad) * v);
\r
1212 x2 - Math.sin(rad) * kage.kMinWidthT * v + (kage.kWidth * kage.kKakato * 0.5 + kage.kMinWidthT) * Math.cos(rad) * v,
\r
1213 y2 + Math.cos(rad) * kage.kMinWidthT * v + (kage.kWidth * kage.kKakato * 0.5 + kage.kMinWidthT) * Math.sin(rad) * v);
\r
1216 poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthT * v + kage.kMinWidthY * Math.cos(rad) * v,
\r
1217 y2 - Math.cos(rad) * kage.kMinWidthT * v + kage.kMinWidthY * Math.sin(rad) * v);
\r
1218 poly.set(2, x2 - Math.sin(rad) * kage.kMinWidthT * v + kage.kMinWidthY * Math.cos(rad) * v,
\r
1219 y2 + Math.cos(rad) * kage.kMinWidthT * v + kage.kMinWidthY * Math.sin(rad) * v);
\r
1223 polygons.push(poly);
\r
1225 if((a1 == 6) && (a2 == 0 || a2 == 5)){ //KAGI NO YOKO BOU NO SAIGO NO MARU
\r
1226 poly = new Polygon();
\r
1227 poly.push(x2 + Math.sin(rad) * kage.kMinWidthT * v, y2 - Math.cos(rad) * kage.kMinWidthT * v);
\r
1228 poly.push(x2 + Math.cos(rad) * kage.kMinWidthT * 0.8 * v + Math.sin(rad) * kage.kMinWidthT * 0.6 * v,
\r
1229 y2 + Math.sin(rad) * kage.kMinWidthT * 0.8 * v - Math.cos(rad) * kage.kMinWidthT * 0.6 * v);
\r
1230 poly.push(x2 + Math.cos(rad) * kage.kMinWidthT * v, y2 + Math.sin(rad) * kage.kMinWidthT * v);
\r
1231 poly.push(x2 + Math.cos(rad) * kage.kMinWidthT * 0.8 * v - Math.sin(rad) * kage.kMinWidthT * 0.6 * v,
\r
1232 y2 + Math.sin(rad) * kage.kMinWidthT * 0.8 * v + Math.cos(rad) * kage.kMinWidthT * 0.6 * v);
\r
1233 poly.push(x2 - Math.sin(rad) * kage.kMinWidthT * v, y2 + Math.cos(rad) * kage.kMinWidthT * v);
\r
1234 polygons.push(poly);
\r
1237 if(a1 == 6 && a2 == 5){
\r
1238 //KAGI NO YOKO BOU NO HANE
\r
1239 poly = new Polygon();
\r
1240 poly.push(x2 + (kage.kMinWidthT - 1) * Math.sin(rad) * v, y2 - (kage.kMinWidthT - 1) * Math.cos(rad) * v);
\r
1241 poly.push(x2 + 2 * Math.cos(rad) * v + (kage.kMinWidthT + kage.kWidth * 5) * Math.sin(rad) * v,
\r
1242 y2 + 2 * Math.sin(rad) * v - (kage.kMinWidthT + kage.kWidth * 5) * Math.cos(rad) * v);
\r
1243 poly.push(x2 + (kage.kMinWidthT + kage.kWidth * 5) * Math.sin(rad) * v,
\r
1244 y2 - (kage.kMinWidthT + kage.kWidth * 5) * Math.cos(rad) * v);
\r
1245 poly.push(x2 + (kage.kMinWidthT - 1) * Math.sin(rad) * v - kage.kMinWidthT * Math.cos(rad) * v,
\r
1246 y2 - (kage.kMinWidthT - 1) * Math.cos(rad) * v - kage.kMinWidthT * Math.sin(rad) * v);
\r
1247 polygons.push(poly);
\r
1250 if(a1 == 22){ //SHIKAKU MIGIUE UROKO NANAME DEMO MASSUGU MUKI
\r
1251 poly = new Polygon();
\r
1252 poly.push(x1 - kage.kMinWidthT, y1 - kage.kMinWidthY);
\r
1253 poly.push(x1, y1 - kage.kMinWidthY - kage.kWidth);
\r
1254 poly.push(x1 + kage.kMinWidthT + kage.kWidth, y1 + kage.kMinWidthY);
\r
1255 poly.push(x1 + kage.kMinWidthT, y1 + kage.kMinWidthT);
\r
1256 poly.push(x1 - kage.kMinWidthT, y1);
\r
1257 polygons.push(poly);
\r
1260 XX = Math.sin(rad) * v;
\r
1261 XY = Math.cos(rad) * v * -1;
\r
1262 YX = Math.cos(rad) * v;
\r
1263 YY = Math.sin(rad) * v;
\r
1265 if(a1 == 0){ //beginning of the storke
\r
1266 poly = new Polygon();
\r
1267 poly.push(x1 + kage.kMinWidthT * XX + (kage.kMinWidthY * 0.5) * YX,
\r
1268 y1 + kage.kMinWidthT * XY + (kage.kMinWidthY * 0.5) * YY);
\r
1269 poly.push(x1 + (kage.kMinWidthT + kage.kMinWidthT * 0.5) * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY) * YX,
\r
1270 y1 + (kage.kMinWidthT + kage.kMinWidthT * 0.5) * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY) * YY);
\r
1271 poly.push(x1 + kage.kMinWidthT * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YX,
\r
1272 y1 + kage.kMinWidthT * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YY);
\r
1273 polygons.push(poly);
\r
1279 if(tx1 == tx2){ //if TATE stroke, use y-axis
\r
1297 if(a1 % 10 == 2){ y1 = y1 - kage.kWidth; }
\r
1298 if(a2 % 10 == 2){ y2 = y2 + kage.kWidth; }
\r
1299 if(a1 % 10 == 3){ y1 = y1 - kage.kWidth * kage.kKakato; }
\r
1300 if(a2 % 10 == 3){ y2 = y2 + kage.kWidth * kage.kKakato; }
\r
1302 poly = new Polygon();
\r
1303 poly.push(x1 - kage.kWidth, y1);
\r
1304 poly.push(x2 - kage.kWidth, y2);
\r
1305 poly.push(x2 + kage.kWidth, y2);
\r
1306 poly.push(x1 + kage.kWidth, y1);
\r
1307 poly.reverse(); // for fill-rule
\r
1309 polygons.push(poly);
\r
1311 else if(ty1 == ty2){ //if YOKO stroke, use x-axis
\r
1328 if(a1 % 10 == 2){ x1 = x1 - kage.kWidth; }
\r
1329 if(a2 % 10 == 2){ x2 = x2 + kage.kWidth; }
\r
1330 if(a1 % 10 == 3){ x1 = x1 - kage.kWidth * kage.kKakato; }
\r
1331 if(a2 % 10 == 3){ x2 = x2 + kage.kWidth * kage.kKakato; }
\r
1333 poly = new Polygon();
\r
1334 poly.push(x1, y1 - kage.kWidth);
\r
1335 poly.push(x2, y2 - kage.kWidth);
\r
1336 poly.push(x2, y2 + kage.kWidth);
\r
1337 poly.push(x1, y1 + kage.kWidth);
\r
1339 polygons.push(poly);
\r
1341 else{ //for others, use x-axis
\r
1358 rad = Math.atan((y2 - y1) / (x2 - x1));
\r
1360 x1 = x1 - kage.kWidth * Math.cos(rad);
\r
1361 y1 = y1 - kage.kWidth * Math.sin(rad);
\r
1364 x2 = x2 + kage.kWidth * Math.cos(rad);
\r
1365 y2 = y2 + kage.kWidth * Math.sin(rad);
\r
1368 x1 = x1 - kage.kWidth * Math.cos(rad) * kage.kKakato;
\r
1369 y1 = y1 - kage.kWidth * Math.sin(rad) * kage.kKakato;
\r
1372 x2 = x2 + kage.kWidth * Math.cos(rad) * kage.kKakato;
\r
1373 y2 = y2 + kage.kWidth * Math.sin(rad) * kage.kKakato;
\r
1376 //SUICHOKU NO ICHI ZURASHI HA Math.sin TO Math.cos NO IREKAE + x-axis MAINASU KA
\r
1377 poly = new Polygon();
\r
1378 poly.push(x1 + Math.sin(rad) * kage.kWidth, y1 - Math.cos(rad) * kage.kWidth);
\r
1379 poly.push(x2 + Math.sin(rad) * kage.kWidth, y2 - Math.cos(rad) * kage.kWidth);
\r
1380 poly.push(x2 - Math.sin(rad) * kage.kWidth, y2 + Math.cos(rad) * kage.kWidth);
\r
1381 poly.push(x1 - Math.sin(rad) * kage.kWidth, y1 + Math.cos(rad) * kage.kWidth);
\r
1383 polygons.push(poly);
\r