1 // may be it can join 3curve and 4curve. the difference is may be only calculating x,y,ix,iy
\r
3 function cdDrawBezier(kage, polygons, x1, y1, x2, y2, x3, y3, x4, y4, a1, a2){
\r
6 var ix, iy, ia, ib, ir;
\r
14 if(kage.kShotai == kage.kMincho){ // mincho
\r
18 delta = -1 * kage.kMinWidthY * 0.5;
\r
21 case 2: // must be 32
\r
28 delta = kage.kMinWidthY;
\r
35 if(y1 < y2){ y1 = y1 - delta; }
\r
36 else{ y1 = y1 + delta; }
\r
39 if(x1 < x2){ x1 = x1 - delta; }
\r
40 else{ x1 = x1 + delta; }
\r
43 rad = Math.atan((y2 - y1) / (x2 - x1));
\r
44 if(x1 < x2){ v = 1; } else{ v = -1; }
\r
45 x1 = x1 - delta * Math.cos(rad) * v;
\r
46 y1 = y1 - delta * Math.sin(rad) * v;
\r
55 case 15: // it can change to 15->5
\r
56 case 14: // it can change to 14->4
\r
66 if(y3 < y4){ y4 = y4 + delta; }
\r
67 else{ y4 = y4 - delta; }
\r
70 if(x3 < x4){ x4 = x4 + delta; }
\r
71 else{ x4 = x4 - delta; }
\r
74 rad = Math.atan((y4 - y3) / (x4 - x3));
\r
75 if(x3 < x4){ v = 1; } else{ v = -1; }
\r
76 x4 = x4 + delta * Math.cos(rad) * v;
\r
77 y4 = y4 + delta * Math.sin(rad) * v;
\r
81 if(Math.sqrt((x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1)) < 50){
\r
82 hosomi += 0.4 * (1 - Math.sqrt((x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1)) / 50);
\r
85 poly = new Polygon();
\r
86 poly2 = new Polygon();
\r
87 for(tt = 0; tt <= 1000; tt = tt + kage.kRate){
\r
91 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
92 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
93 //KATAMUKI of vector by BIBUN
\r
94 ix = t * t * (-3 * x1 + 9 * x2 + -9 * x3 + 3 * x4) + t * (6 * x1 + -12 * x2 + 6 * x3) + -3 * x1 + 3 * x2;
\r
95 iy = t * t * (-3 * y1 + 9 * y2 + -9 * y3 + 3 * y4) + t * (6 * y1 + -12 * y2 + 6 * y3) + -3 * y1 + 3 * y2;
\r
97 //line SUICHOKU by vector
\r
98 if(ix != 0 && iy != 0){
\r
99 ir = Math.atan(iy / ix * -1);
\r
100 ia = Math.sin(ir) * (kage.kMinWidthT);
\r
101 ib = Math.cos(ir) * (kage.kMinWidthT);
\r
104 ia = kage.kMinWidthT;
\r
109 ib = kage.kMinWidthT;
\r
112 if(a1 == 7 && a2 == 0){ // L2RD: fatten
\r
113 deltad = Math.pow(t, hosomi) * kage.kL2RDfatten;
\r
116 deltad = Math.pow(t, hosomi);
\r
119 deltad = Math.pow(1.0 - t, hosomi);
\r
121 else{ deltad = 1; }
\r
129 //reverse if vector is going 2nd/3rd quadrants
\r
135 //copy to polygon structuer
\r
136 poly.push(x - ia, y - ib);
\r
137 poly2.push(x + ia, y + ib);
\r
140 poly.concat(poly2);
\r
141 polygons.push(poly);
\r
143 //process for head of stroke
\r
144 rad = Math.atan((y2 - y1) / (x2 - x1));
\r
145 if(x1 < x2){ v = 1; } else{ v = -1; }
\r
146 XX = Math.sin(rad) * v;
\r
147 XY = Math.cos(rad) * v * -1;
\r
148 YX = Math.cos(rad) * v;
\r
149 YY = Math.sin(rad) * v;
\r
153 poly = new Polygon();
\r
154 poly.push(x1 - kage.kMinWidthT, y1);
\r
155 poly.push(x1 + kage.kMinWidthT, y1);
\r
156 poly.push(x1 - kage.kMinWidthT, y1 - kage.kMinWidthT);
\r
157 polygons.push(poly);
\r
160 poly = new Polygon();
\r
161 poly.push(x1 - kage.kMinWidthT * XX, y1 - kage.kMinWidthT * XY);
\r
162 poly.push(x1 + kage.kMinWidthT * XX, y1 + kage.kMinWidthT * XY);
\r
163 poly.push(x1 - kage.kMinWidthT * XX - kage.kMinWidthT * YX, y1 - kage.kMinWidthT * XY - kage.kMinWidthT * YY);
\r
164 polygons.push(poly);
\r
169 if(y1 <= y4){ //from up to bottom
\r
171 poly = new Polygon();
\r
172 poly.push(x1 - kage.kMinWidthT, y1);
\r
173 poly.push(x1 + kage.kMinWidthT, y1);
\r
174 poly.push(x1 - kage.kMinWidthT, y1 - kage.kMinWidthY);
\r
175 polygons.push(poly);
\r
178 poly = new Polygon();
\r
179 poly.push(x1 - kage.kMinWidthT * XX, y1 - kage.kMinWidthT * XY);
\r
180 poly.push(x1 + kage.kMinWidthT * XX, y1 + kage.kMinWidthT * XY);
\r
181 poly.push(x1 - kage.kMinWidthT * XX - kage.kMinWidthY * YX, y1 - kage.kMinWidthT * XY - kage.kMinWidthY * YY);
\r
182 polygons.push(poly);
\r
185 else{ //bottom to up
\r
187 poly = new Polygon();
\r
188 poly.push(x1 - kage.kMinWidthT, y1);
\r
189 poly.push(x1 + kage.kMinWidthT, y1);
\r
190 poly.push(x1 + kage.kMinWidthT, y1 - kage.kMinWidthY);
\r
191 polygons.push(poly);
\r
194 poly = new Polygon();
\r
195 poly.push(x1 - kage.kMinWidthT * XX, y1 - kage.kMinWidthT * XY);
\r
196 poly.push(x1 + kage.kMinWidthT * XX, y1 + kage.kMinWidthT * XY);
\r
197 poly.push(x1 + kage.kMinWidthT * XX - kage.kMinWidthY * YX, y1 + kage.kMinWidthT * XY - kage.kMinWidthY * YY);
\r
198 polygons.push(poly);
\r
203 if(a1 == 22){ //box's up-right corner, any time same degree
\r
204 poly = new Polygon();
\r
205 poly.push(x1 - kage.kMinWidthT, y1 - kage.kMinWidthY);
\r
206 poly.push(x1, y1 - kage.kMinWidthY - kage.kWidth);
\r
207 poly.push(x1 + kage.kMinWidthT + kage.kWidth, y1 + kage.kMinWidthY);
\r
208 poly.push(x1 + kage.kMinWidthT, y1 + kage.kMinWidthT);
\r
209 poly.push(x1, y1 + kage.kMinWidthT);
\r
210 polygons.push(poly);
\r
213 if(a1 == 0){ //beginning of the stroke
\r
214 if(y1 <= y4){ //from up to bottom
\r
216 poly = new Polygon();
\r
217 poly.push(x1 + kage.kMinWidthT, y1);
\r
218 poly.push(x1 + kage.kMinWidthT * 1.5, y1 + kage.kMinWidthY);
\r
219 poly.push(x1 + kage.kMinWidthT * 0.5, y1 + kage.kMinWidthY * 3);
\r
220 polygons.push(poly);
\r
223 poly = new Polygon();
\r
224 poly.push(x1 + kage.kMinWidthT * XX,
\r
225 y1 + kage.kMinWidthT * XY);
\r
226 poly.push(x1 + kage.kMinWidthT * 1.5 * XX + kage.kMinWidthY * YX,
\r
227 y1 + kage.kMinWidthT * 1.5 * XY + kage.kMinWidthY * YY);
\r
228 poly.push(x1 + kage.kMinWidthT * 0.5 * XX + kage.kMinWidthY * 3 * YX,
\r
229 y1 + kage.kMinWidthT * 0.5 * XY + kage.kMinWidthY * 3 * YY);
\r
230 polygons.push(poly);
\r
233 else{ //from bottom to up
\r
235 poly = new Polygon();
\r
236 poly.push(x1 - kage.kMinWidthT, y1);
\r
237 poly.push(x1 - kage.kMinWidthT * 1.5, y1 + kage.kMinWidthY);
\r
238 poly.push(x1 - kage.kMinWidthT * 0.5, y1 + kage.kMinWidthY * 3);
\r
239 polygons.push(poly);
\r
242 poly = new Polygon();
\r
243 poly.push(x1 - kage.kMinWidthT * XX, y1 - kage.kMinWidthT * XY);
\r
244 poly.push(x1 - kage.kMinWidthT * 1.5 * XX + kage.kMinWidthY * YX, y1 + kage.kMinWidthY * YY - kage.kMinWidthT * 1.5 * XY);
\r
245 poly.push(x1 - kage.kMinWidthT * 0.5 * XX + kage.kMinWidthY * 3 * YX, y1 + kage.kMinWidthY * 3 * YY - kage.kMinWidthT * 0.5 * XY);
\r
246 polygons.push(poly);
\r
252 rad = Math.atan((y4 - y3) / (x4 - x3));
\r
253 if(x3 < x4){ v = 1; } else{ v = -1; }
\r
254 YX = Math.sin(rad) * v * -1;
\r
255 YY = Math.cos(rad) * v;
\r
256 XX = Math.cos(rad) * v;
\r
257 XY = Math.sin(rad) * v;
\r
259 if(a2 == 1 || a2 == 8 || a2 == 15){ //the last filled circle ... it can change to 15->5
\r
262 poly.push(x4 - kage.kMinWidthT, y4);
\r
263 poly.push(x4 - kage.kMinWidthT * 0.7, y4 + kage.kMinWidthT * 0.7);
\r
264 poly.push(x4, y4 + kage.kMinWidthT);
\r
265 poly.push(x4 + kage.kMinWidthT * 0.7, y4 + kage.kMinWidthT * 0.7);
\r
266 poly.push(x4 + kage.kMinWidthT, y4);
\r
267 polygons.push(poly);
\r
270 poly = new Polygon();
\r
271 poly.push(x4, y4 - kage.kMinWidthT);
\r
272 poly.push(x4 + kage.kMinWidthT * 0.7, y4 - kage.kMinWidthT * 0.7);
\r
273 poly.push(x4 + kage.kMinWidthT, y4);
\r
274 poly.push(x4 + kage.kMinWidthT * 0.7, y4 + kage.kMinWidthT * 0.7);
\r
275 poly.push(x4, y4 + kage.kMinWidthT);
\r
276 polygons.push(poly);
\r
279 poly = new Polygon();
\r
280 poly.push(x4 + Math.sin(rad) * kage.kMinWidthT * v, y4 - Math.cos(rad) * kage.kMinWidthT * v);
\r
281 poly.push(x4 + Math.cos(rad) * kage.kMinWidthT * 0.7 * v + Math.sin(rad) * kage.kMinWidthT * 0.7 * v,
\r
282 y4 + Math.sin(rad) * kage.kMinWidthT * 0.7 * v - Math.cos(rad) * kage.kMinWidthT * 0.7 * v);
\r
283 poly.push(x4 + Math.cos(rad) * kage.kMinWidthT * v, y4 + Math.sin(rad) * kage.kMinWidthT * v);
\r
284 poly.push(x4 + Math.cos(rad) * kage.kMinWidthT * 0.7 * v - Math.sin(rad) * kage.kMinWidthT * 0.7 * v,
\r
285 y4 + Math.sin(rad) * kage.kMinWidthT * 0.7 * v + Math.cos(rad) * kage.kMinWidthT * 0.7 * v);
\r
286 poly.push(x4 - Math.sin(rad) * kage.kMinWidthT * v, y4 + Math.cos(rad) * kage.kMinWidthT * v);
\r
287 polygons.push(poly);
\r
291 if(a2 == 9 || (a1 == 7 && a2 == 0)){ // Math.sinnyu & L2RD Harai
\r
293 poly = new Polygon();
\r
294 poly.push(x4, y4 + kage.kMinWidthT);
\r
295 poly.push(x4, y4 - kage.kMinWidthT);
\r
296 poly.push(x4 + kage.kMinWidthT, y4 - kage.kMinWidthT);
\r
297 polygons.push(poly);
\r
300 poly = new Polygon();
\r
301 poly.push(x4 + kage.kMinWidthT * YX, y4 + kage.kMinWidthT * YY);
\r
302 poly.push(x4 - kage.kMinWidthT * YX, y4 - kage.kMinWidthT * YY);
\r
303 poly.push(x4 + kage.kMinWidthT * XX - kage.kMinWidthT * YX, y4 + kage.kMinWidthT * XY - kage.kMinWidthT * YY);
\r
304 polygons.push(poly);
\r
308 if(a2 == 15){ //jump up ... it can change to 15->5
\r
310 poly = new Polygon();
\r
311 poly.push(x4, y4 - kage.kMinWidthT + 1);
\r
312 poly.push(x4 + 2, y4 - kage.kMinWidthT - kage.kWidth * 5);
\r
313 poly.push(x4, y4 - kage.kMinWidthT - kage.kWidth * 5);
\r
314 poly.push(x4 - kage.kMinWidthT, y4 - kage.kMinWidthT + 1);
\r
315 polygons.push(poly);
\r
318 poly = new Polygon();
\r
319 poly.push(x4 + (kage.kMinWidthT - 1) * Math.sin(rad) * v, y4 - (kage.kMinWidthT - 1) * Math.cos(rad) * v);
\r
320 poly.push(x4 + 2 * Math.cos(rad) * v + (kage.kMinWidthT + kage.kWidth * 5) * Math.sin(rad) * v,
\r
321 y4 + 2 * Math.sin(rad) * v - (kage.kMinWidthT + kage.kWidth * 5) * Math.cos(rad) * v);
\r
322 poly.push(x4 + (kage.kMinWidthT + kage.kWidth * 5) * Math.sin(rad) * v,
\r
323 y4 - (kage.kMinWidthT + kage.kWidth * 5) * Math.cos(rad) * v);
\r
324 poly.push(x4 + (kage.kMinWidthT - 1) * Math.sin(rad) * v - kage.kMinWidthT * Math.cos(rad) * v,
\r
325 y4 - (kage.kMinWidthT - 1) * Math.cos(rad) * v - kage.kMinWidthT * Math.sin(rad) * v);
\r
326 polygons.push(poly);
\r
330 if(a2 == 14){ //jump to left, allways go left ... it can change to 14->4
\r
331 poly = new Polygon();
\r
333 poly.push(x4, y4 - kage.kMinWidthT);
\r
334 poly.push(x4 - kage.kWidth * 4, y4 - kage.kMinWidthT);
\r
335 poly.push(x4 - kage.kWidth * 4, y4 - kage.kMinWidthT * 0.5);
\r
336 polygons.push(poly);
\r
342 if(y1 < y2){ y1 = y1 - kage.kWidth; } else{ y1 = y1 + kage.kWidth; }
\r
345 if(x1 < x2){ x1 = x1 - kage.kWidth; } else{ x1 = x1 + kage.kWidth; }
\r
348 rad = Math.atan((y2 - y1) / (x2 - x1));
\r
349 if(x1 < x2){ v = 1; } else{ v = -1; }
\r
350 x1 = x1 - kage.kWidth * Math.cos(rad) * v;
\r
351 y1 = y1 - kage.kWidth * Math.sin(rad) * v;
\r
358 y1 = y1 - kage.kWidth * kage.kKakato;
\r
361 y1 = y1 + kage.kWidth * kage.kKakato;
\r
366 x1 = x1 - kage.kWidth * kage.kKakato;
\r
369 x1 = x1 + kage.kWidth * kage.kKakato;
\r
373 rad = Math.atan((y2 - y1) / (x2 - x1));
\r
374 if(x1 < x2){ v = 1; } else{ v = -1; }
\r
375 x1 = x1 - kage.kWidth * Math.cos(rad) * v * kage.kKakato;
\r
376 y1 = y1 - kage.kWidth * Math.sin(rad) * v * kage.kKakato;
\r
381 if(y3 < y4){ y4 = y4 + kage.kWidth; } else{ y4 = y4 - kage.kWidth; }
\r
384 if(x3 < x4){ x4 = x4 + kage.kWidth; } else{ x4 = x4 - kage.kWidth; }
\r
387 rad = Math.atan((y4 - y3) / (x4 - x3));
\r
388 if(x3 < x4){ v = 1; } else{ v = -1; }
\r
389 x4 = x4 + kage.kWidth * Math.cos(rad) * v;
\r
390 y4 = y4 + kage.kWidth * Math.sin(rad) * v;
\r
397 y4 = y4 + kage.kWidth * kage.kKakato;
\r
400 y4 = y4 - kage.kWidth * kage.kKakato;
\r
405 x4 = x4 + kage.kWidth * kage.kKakato;
\r
408 x4 = x4 - kage.kWidth * kage.kKakato;
\r
412 rad = Math.atan((y4 - y3) / (x4 - x3));
\r
413 if(x3 < x4){ v = 1; } else{ v = -1; }
\r
414 x4 = x4 + kage.kWidth * Math.cos(rad) * v * kage.kKakato;
\r
415 y4 = y4 + kage.kWidth * Math.sin(rad) * v * kage.kKakato;
\r
419 poly = new Polygon();
\r
420 poly2= new Polygon();
\r
422 for(tt = 0; tt <= 1000; tt = tt + kage.kRate){
\r
426 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
427 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
428 //KATAMUKI of vector by BIBUN
\r
429 ix = t * t * (-3 * x1 + 9 * x2 + -9 * x3 + 3 * x4) + t * (6 * x1 + -12 * x2 + 6 * x3) + -3 * x1 + 3 * x2;
\r
430 iy = t * t * (-3 * y1 + 9 * y2 + -9 * y3 + 3 * y4) + t * (6 * y1 + -12 * y2 + 6 * y3) + -3 * y1 + 3 * y2;
\r
432 //SESSEN NI SUICHOKU NA CHOKUSEN NO KEISAN
\r
433 if(kage.kShotai == kage.kMincho){ //always false ?
\r
434 if(ix != 0 && iy != 0){
\r
435 ir = Math.atan(iy / ix * -1.0);
\r
436 ia = Math.sin(ir) * kage.kMinWidthT;
\r
437 ib = Math.cos(ir) * kage.kMinWidthT;
\r
440 ia = kage.kMinWidthT;
\r
445 ib = kage.kMinWidthT;
\r
447 ia = ia * Math.sqrt(1.0 - t);
\r
448 ib = ib * Math.sqrt(1.0 - t);
\r
451 if(ix != 0 && iy != 0){
\r
452 ir = Math.atan(iy / ix * -1.0);
\r
453 ia = Math.sin(ir) * kage.kWidth;
\r
454 ib = Math.cos(ir) * kage.kWidth;
\r
466 //reverse if vector is going 2nd/3rd quadrants
\r
473 poly.push(x - ia, y - ib);
\r
474 poly2.push(x + ia, y + ib);
\r
478 poly.concat(poly2);
\r
479 polygons.push(poly);
\r
483 function cdDrawCurve(kage, polygons, x1, y1, x2, y2, x3, y3, a1, a2){
\r
486 var ix, iy, ia, ib, ir;
\r
490 var XX, XY, YX, YY;
\r
494 if(kage.kShotai == kage.kMincho){ // mincho
\r
498 delta = -1 * kage.kMinWidthY * 0.5;
\r
501 case 2: // ... must be 32
\r
508 delta = kage.kMinWidthY;
\r
515 if(y1 < y2){ y1 = y1 - delta; }
\r
516 else{ y1 = y1 + delta; }
\r
519 if(x1 < x2){ x1 = x1 - delta; }
\r
520 else{ x1 = x1 + delta; }
\r
523 rad = Math.atan((y2 - y1) / (x2 - x1));
\r
524 if(x1 < x2){ v = 1; } else{ v = -1; }
\r
525 x1 = x1 - delta * Math.cos(rad) * v;
\r
526 y1 = y1 - delta * Math.sin(rad) * v;
\r
534 case 15: // it can change to 15->5
\r
535 case 14: // it can change to 14->4
\r
536 case 17: // no need
\r
540 case 8: // get shorten for tail's circle
\r
541 delta = -1 * kage.kMinWidthT * 0.5;
\r
548 if(y2 < y3){ y3 = y3 + delta; }
\r
549 else{ y3 = y3 - delta; }
\r
552 if(x2 < x3){ x3 = x3 + delta; }
\r
553 else{ x3 = x3 - delta; }
\r
556 rad = Math.atan((y3 - y2) / (x3 - x2));
\r
557 if(x2 < x3){ v = 1; } else{ v = -1; }
\r
558 x3 = x3 + delta * Math.cos(rad) * v;
\r
559 y3 = y3 + delta * Math.sin(rad) * v;
\r
563 if(Math.sqrt((x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1)) < 50){
\r
564 hosomi += 0.4 * (1 - Math.sqrt((x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1)) / 50);
\r
567 poly = new Polygon();
\r
568 poly2 = new Polygon();
\r
570 for(tt = 0; tt <= 1000; tt = tt + kage.kRate){
\r
574 x = ((1.0 - t) * (1.0 - t) * x1 + 2.0 * t * (1.0 - t) * x2 + t * t * x3);
\r
575 y = ((1.0 - t) * (1.0 - t) * y1 + 2.0 * t * (1.0 - t) * y2 + t * t * y3);
\r
577 //KATAMUKI of vector by BIBUN
\r
578 ix = (x1 - 2.0 * x2 + x3) * 2.0 * t + (-2.0 * x1 + 2.0 * x2);
\r
579 iy = (y1 - 2.0 * y2 + y3) * 2.0 * t + (-2.0 * y1 + 2.0 * y2);
\r
581 //line SUICHOKU by vector
\r
582 if(ix != 0 && iy != 0){
\r
583 ir = Math.atan(iy / ix * -1);
\r
584 ia = Math.sin(ir) * (kage.kMinWidthT);
\r
585 ib = Math.cos(ir) * (kage.kMinWidthT);
\r
588 ia = kage.kMinWidthT;
\r
593 ib = kage.kMinWidthT;
\r
596 if(a1 == 7 && a2 == 0){ // L2RD: fatten
\r
597 deltad = Math.pow(t, hosomi) * kage.kL2RDfatten;
\r
600 deltad = Math.pow(t, hosomi);
\r
603 deltad = Math.pow(1.0 - t, hosomi);
\r
605 else{ deltad = 1; }
\r
613 //reverse if vector is going 2nd/3rd quadrants
\r
619 //copy to polygon structure
\r
620 poly.push(x - ia, y - ib);
\r
621 poly2.push(x + ia, y + ib);
\r
625 poly.concat(poly2);
\r
626 polygons.push(poly);
\r
628 //process for head of stroke
\r
629 rad = Math.atan((y2 - y1) / (x2 - x1));
\r
630 if(x1 < x2){ v = 1; } else{ v = -1; }
\r
631 XX = Math.sin(rad) * v;
\r
632 XY = Math.cos(rad) * v * -1;
\r
633 YX = Math.cos(rad) * v;
\r
634 YY = Math.sin(rad) * v;
\r
638 poly= new Polygon();
\r
639 poly.push(x1 - kage.kMinWidthT, y1);
\r
640 poly.push(x1 + kage.kMinWidthT, y1);
\r
641 poly.push(x1 - kage.kMinWidthT, y1 - kage.kMinWidthT);
\r
642 polygons.push(poly);
\r
645 poly = new Polygon();
\r
646 poly.push(x1 - kage.kMinWidthT * XX, y1 - kage.kMinWidthT * XY);
\r
647 poly.push(x1 + kage.kMinWidthT * XX, y1 + kage.kMinWidthT * XY);
\r
648 poly.push(x1 - kage.kMinWidthT * XX - kage.kMinWidthT * YX, y1 - kage.kMinWidthT * XY - kage.kMinWidthT * YY);
\r
649 polygons.push(poly);
\r
654 if(y1 <= y3){ //from up to bottom
\r
656 poly = new Polygon();
\r
657 poly.push(x1 - kage.kMinWidthT, y1);
\r
658 poly.push(x1 + kage.kMinWidthT, y1);
\r
659 poly.push(x1 - kage.kMinWidthT, y1 - kage.kMinWidthY);
\r
660 polygons.push(poly);
\r
663 poly = new Polygon();
\r
664 poly.push(x1 - kage.kMinWidthT * XX, y1 - kage.kMinWidthT * XY);
\r
665 poly.push(x1 + kage.kMinWidthT * XX, y1 + kage.kMinWidthT * XY);
\r
666 poly.push(x1 - kage.kMinWidthT * XX - kage.kMinWidthY * YX, y1 - kage.kMinWidthT * XY - kage.kMinWidthY * YY);
\r
667 polygons.push(poly);
\r
670 else{ //bottom to up
\r
672 poly = new Polygon();
\r
673 poly.push(x1 - kage.kMinWidthT, y1);
\r
674 poly.push(x1 + kage.kMinWidthT, y1);
\r
675 poly.push(x1 + kage.kMinWidthT, y1 - kage.kMinWidthY);
\r
676 polygons.push(poly);
\r
679 poly = new Polygon();
\r
680 poly.push(x1 - kage.kMinWidthT * XX, y1 - kage.kMinWidthT * XY);
\r
681 poly.push(x1 + kage.kMinWidthT * XX, y1 + kage.kMinWidthT * XY);
\r
682 poly.push(x1 + kage.kMinWidthT * XX - kage.kMinWidthY * YX, y1 + kage.kMinWidthT * XY - kage.kMinWidthY * YY);
\r
683 polygons.push(poly);
\r
688 if(a1 == 22){ //box's up-right corner, any time same degree
\r
689 poly = new Polygon();
\r
690 poly.push(x1 - kage.kMinWidthT, y1 - kage.kMinWidthY);
\r
691 poly.push(x1, y1 - kage.kMinWidthY - kage.kWidth);
\r
692 poly.push(x1 + kage.kMinWidthT + kage.kWidth, y1 + kage.kMinWidthY);
\r
693 poly.push(x1 + kage.kMinWidthT, y1 + kage.kMinWidthT);
\r
694 poly.push(x1, y1 + kage.kMinWidthT);
\r
695 polygons.push(poly);
\r
698 if(a1 == 0){ //beginning of the stroke
\r
699 if(y1 <= y3){ //from up to bottom
\r
701 poly = new Polygon();
\r
702 poly.push(x1 + kage.kMinWidthT, y1);
\r
703 poly.push(x1 + kage.kMinWidthT * 1.5, y1 + kage.kMinWidthY);
\r
704 poly.push(x1 + kage.kMinWidthT * 0.5, y1 + kage.kMinWidthY * 3);
\r
705 polygons.push(poly);
\r
708 poly = new Polygon();
\r
709 poly.push(x1 + kage.kMinWidthT * XX,
\r
710 y1 + kage.kMinWidthT * XY);
\r
711 poly.push(x1 + kage.kMinWidthT * 1.5 * XX + kage.kMinWidthY * YX,
\r
712 y1 + kage.kMinWidthT * 1.5 * XY + kage.kMinWidthY * YY);
\r
713 poly.push(x1 + kage.kMinWidthT * 0.5 * XX + kage.kMinWidthY * 3 * YX,
\r
714 y1 + kage.kMinWidthT * 0.5 * XY + kage.kMinWidthY * 3 * YY);
\r
715 polygons.push(poly);
\r
718 else{ //from bottom to up
\r
720 poly = new Polygon();
\r
721 poly.push(x1 - kage.kMinWidthT, y1);
\r
722 poly.push(x1 - kage.kMinWidthT * 1.5, y1 + kage.kMinWidthY);
\r
723 poly.push(x1 - kage.kMinWidthT * 0.5, y1 + kage.kMinWidthY * 3);
\r
724 polygons.push(poly);
\r
727 poly = new Polygon();
\r
728 poly.push(x1 - kage.kMinWidthT * XX, y1 - kage.kMinWidthT * XY);
\r
729 poly.push(x1 - kage.kMinWidthT * 1.5 * XX + kage.kMinWidthY * YX, y1 + kage.kMinWidthY * YY - kage.kMinWidthT * 1.5 * XY);
\r
730 poly.push(x1 - kage.kMinWidthT * 0.5 * XX + kage.kMinWidthY * 3 * YX, y1 + kage.kMinWidthY * 3 * YY - kage.kMinWidthT * 0.5 * XY);
\r
731 polygons.push(poly);
\r
737 rad = Math.atan((y3 - y2) / (x3 - x2));
\r
738 if(x2 < x3){ v = 1; } else{ v = -1; }
\r
739 YX = Math.sin(rad) * v * -1;
\r
740 YY = Math.cos(rad) * v;
\r
741 XX = Math.cos(rad) * v;
\r
742 XY = Math.sin(rad) * v;
\r
744 if(a2 == 1 || a2 == 8 || a2 == 15){ //the last filled circle ... it can change 15->5
\r
746 poly = new Polygon();
\r
747 poly.push(x3 - kage.kMinWidthT, y3);
\r
748 poly.push(x3 - kage.kMinWidthT * 0.7, y3 + kage.kMinWidthT * 0.7);
\r
749 poly.push(x3, y3 + kage.kMinWidthT);
\r
750 poly.push(x3 + kage.kMinWidthT * 0.7, y3 + kage.kMinWidthT * 0.7);
\r
751 poly.push(x3 + kage.kMinWidthT, y3);
\r
752 polygons.push(poly);
\r
755 poly = new Polygon();
\r
756 poly.push(x3, y3 - kage.kMinWidthT);
\r
757 poly.push(x3 + kage.kMinWidthT * 0.7, y3 - kage.kMinWidthT * 0.7);
\r
758 poly.push(x3 + kage.kMinWidthT, y3);
\r
759 poly.push(x3 + kage.kMinWidthT * 0.7, y3 + kage.kMinWidthT * 0.7);
\r
760 poly.push(x3, y3 + kage.kMinWidthT);
\r
761 polygons.push(poly);
\r
764 poly = new Polygon();
\r
765 poly.push(x3 + Math.sin(rad) * kage.kMinWidthT * v, y3 - Math.cos(rad) * kage.kMinWidthT * v);
\r
766 poly.push(x3 + Math.cos(rad) * kage.kMinWidthT * 0.7 * v + Math.sin(rad) * kage.kMinWidthT * 0.7 * v,
\r
767 y3 + Math.sin(rad) * kage.kMinWidthT * 0.7 * v - Math.cos(rad) * kage.kMinWidthT * 0.7 * v);
\r
768 poly.push(x3 + Math.cos(rad) * kage.kMinWidthT * v, y3 + Math.sin(rad) * kage.kMinWidthT * v);
\r
769 poly.push(x3 + Math.cos(rad) * kage.kMinWidthT * 0.7 * v - Math.sin(rad) * kage.kMinWidthT * 0.7 * v,
\r
770 y3 + Math.sin(rad) * kage.kMinWidthT * 0.7 * v + Math.cos(rad) * kage.kMinWidthT * 0.7 * v);
\r
771 poly.push(x3 - Math.sin(rad) * kage.kMinWidthT * v, y3 + Math.cos(rad) * kage.kMinWidthT * v);
\r
772 polygons.push(poly);
\r
776 if(a2 == 9 || (a1 == 7 && a2 == 0)){ // Math.sinnyu & L2RD Harai ... no need for a2=9
\r
778 poly = new Polygon();
\r
779 poly.push(x3, y3 + kage.kMinWidthT * kage.kL2RDfatten);
\r
780 poly.push(x3, y3 - kage.kMinWidthT * kage.kL2RDfatten);
\r
781 poly.push(x3 + kage.kMinWidthT * kage.kL2RDfatten, y3 - kage.kMinWidthT * kage.kL2RDfatten);
\r
782 polygons.push(poly);
\r
785 poly = new Polygon();
\r
786 poly.push(x3 + kage.kMinWidthT * kage.kL2RDfatten * YX, y3 + kage.kMinWidthT * kage.kL2RDfatten * YY);
\r
787 poly.push(x3 - kage.kMinWidthT * kage.kL2RDfatten * YX, y3 - kage.kMinWidthT * kage.kL2RDfatten * YY);
\r
788 poly.push(x3 + kage.kMinWidthT * kage.kL2RDfatten * XX - kage.kMinWidthT * kage.kL2RDfatten * YX,
\r
789 y3 + kage.kMinWidthT * kage.kL2RDfatten * XY - kage.kMinWidthT * kage.kL2RDfatten * YY);
\r
790 polygons.push(poly);
\r
794 if(a2 == 15){ //jump up ... it can change 15->5
\r
796 poly = new Polygon();
\r
797 poly.push(x3, y3 - kage.kMinWidthT + 1);
\r
798 poly.push(x3 + 2, y3 - kage.kMinWidthT - kage.kWidth * 5);
\r
799 poly.push(x3, y3 - kage.kMinWidthT - kage.kWidth * 5);
\r
800 poly.push(x3 - kage.kMinWidthT, y3 - kage.kMinWidthT + 1);
\r
801 polygons.push(poly);
\r
804 poly = new Polygon();
\r
805 poly.push(x3 + (kage.kMinWidthT - 1) * Math.sin(rad) * v, y3 - (kage.kMinWidthT - 1) * Math.cos(rad) * v);
\r
806 poly.push(x3 + 2 * Math.cos(rad) * v + (kage.kMinWidthT + kage.kWidth * 5) * Math.sin(rad) * v,
\r
807 y3 + 2 * Math.sin(rad) * v - (kage.kMinWidthT + kage.kWidth * 5) * Math.cos(rad) * v);
\r
808 poly.push(x3 + (kage.kMinWidthT + kage.kWidth * 5) * Math.sin(rad) * v,
\r
809 y3 - (kage.kMinWidthT + kage.kWidth * 5) * Math.cos(rad) * v);
\r
810 poly.push(x3 + (kage.kMinWidthT - 1) * Math.sin(rad) * v - kage.kMinWidthT * Math.cos(rad) * v,
\r
811 y3 - (kage.kMinWidthT - 1) * Math.cos(rad) * v - kage.kMinWidthT * Math.sin(rad) * v);
\r
812 polygons.push(poly);
\r
816 if(a2 == 14){ //jump to left, allways go left ... it can change 14->4
\r
817 poly = new Polygon();
\r
819 poly.push(x3, y3 - kage.kMinWidthT);
\r
820 poly.push(x3 - kage.kWidth * 4, y3 - kage.kMinWidthT);
\r
821 poly.push(x3 - kage.kWidth * 4, y3 - kage.kMinWidthT * 0.5);
\r
822 polygons.push(poly);
\r
828 if(y1 < y2){ y1 = y1 - kage.kWidth; } else{ y1 = y1 + kage.kWidth; }
\r
831 if(x1 < x2){ x1 = x1 - kage.kWidth; } else{ x1 = x1 + kage.kWidth; }
\r
834 rad = Math.atan((y2 - y1) / (x2 - x1));
\r
835 if(x1 < x2){ v = 1; } else{ v = -1; }
\r
836 x1 = x1 - kage.kWidth * Math.cos(rad) * v;
\r
837 y1 = y1 - kage.kWidth * Math.sin(rad) * v;
\r
844 y1 = y1 - kage.kWidth * kage.kKakato;
\r
847 y1 = y1 + kage.kWidth * kage.kKakato;
\r
852 x1 = x1 - kage.kWidth * kage.kKakato;
\r
855 x1 = x1 + kage.kWidth * kage.kKakato;
\r
859 rad = Math.atan((y2 - y1) / (x2 - x1));
\r
860 if(x1 < x2){ v = 1; } else{ v = -1; }
\r
861 x1 = x1 - kage.kWidth * Math.cos(rad) * v * kage.kKakato;
\r
862 y1 = y1 - kage.kWidth * Math.sin(rad) * v * kage.kKakato;
\r
867 if(y2 < y3){ y3 = y3 + kage.kWidth; } else{ y3 = y3 - kage.kWidth; }
\r
870 if(x2 < x3){ x3 = x3 + kage.kWidth; } else{ x3 = x3 - kage.kWidth; }
\r
873 rad = Math.atan((y3 - y2) / (x3 - x2));
\r
874 if(x2 < x3){ v = 1; } else{ v = -1; }
\r
875 x3 = x3 + kage.kWidth * Math.cos(rad) * v;
\r
876 y3 = y3 + kage.kWidth * Math.sin(rad) * v;
\r
883 y3 = y3 + kage.kWidth * kage.kKakato;
\r
886 y3 = y3 - kage.kWidth * kage.kKakato;
\r
891 x3 = x3 + kage.kWidth * kage.kKakato;
\r
894 x3 = x3 - kage.kWidth * kage.kKakato;
\r
898 rad = Math.atan((y3 - y2) / (x3 - x2));
\r
899 if(x2 < x3){ v = 1; } else{ v = -1; }
\r
900 x3 = x3 + kage.kWidth * Math.cos(rad) * v * kage.kKakato;
\r
901 y3 = y3 + kage.kWidth * Math.sin(rad) * v * kage.kKakato;
\r
905 poly = new Polygon();
\r
906 poly2 = new Polygon();
\r
908 for(tt = 0; tt <= 1000; tt = tt + kage.kRate){
\r
911 //calculating each point
\r
912 x = ((1.0 - t) * (1.0 - t) * x1 + 2.0 * t * (1.0 - t) * x2 + t * t * x3);
\r
913 y = ((1.0 - t) * (1.0 - t) * y1 + 2.0 * t * (1.0 - t) * y2 + t * t * y3);
\r
915 //SESSEN NO KATAMUKI NO KEISAN(BIBUN)
\r
916 ix = (x1 - 2.0 * x2 + x3) * 2.0 * t + (-2.0 * x1 + 2.0 * x2);
\r
917 iy = (y1 - 2.0 * y2 + y3) * 2.0 * t + (-2.0 * y1 + 2.0 * y2);
\r
919 //SESSEN NI SUICHOKU NA CHOKUSEN NO KEISAN
\r
920 if(kage.kShotai == kage.kMincho){ //always false ?
\r
921 if(ix != 0 && iy != 0){
\r
922 ir = Math.atan(iy / ix * -1.0);
\r
923 ia = Math.sin(ir) * kage.kMinWidthT;
\r
924 ib = Math.cos(ir) * kage.kMinWidthT;
\r
927 ia = kage.kMinWidthT;
\r
932 ib = kage.kMinWidthT;
\r
934 ia = ia * Math.sqrt(1.0 - t);
\r
935 ib = ib * Math.sqrt(1.0 - t);
\r
938 if(ix != 0 && iy != 0){
\r
939 ir = Math.atan(iy / ix * -1.0);
\r
940 ia = Math.sin(ir) * kage.kWidth;
\r
941 ib = Math.cos(ir) * kage.kWidth;
\r
953 //reverse if vector is going 2nd/3rd quadrants
\r
960 poly.push(x - ia, y - ib);
\r
961 poly2.push(x + ia, y + ib);
\r
965 poly.concat(poly2);
\r
966 polygons.push(poly);
\r
970 function cdDrawLine(kage, polygons, tx1, ty1, tx2, ty2, ta1, ta2){
\r
972 var v, x1, y1, x2, y2;
\r
973 var a1, a2, opt1, opt2;
\r
974 var XX, XY, YX, YY;
\r
977 if(kage.kShotai == kage.kMincho){ //mincho
\r
984 opt1 = Math.floor(ta1 / 100);
\r
985 opt2 = Math.floor(ta2 / 100);
\r
987 if(x1 == x2){ //if TATE stroke, use y-axis
\r
988 poly = new Polygon(4);
\r
991 poly.set(3, x1 - kage.kMinWidthT, y1 - kage.kMinWidthY / 2);
\r
992 poly.set(0, x1 + kage.kMinWidthT, y1 + kage.kMinWidthY / 2);
\r
995 case 6: //... no need
\r
997 poly.set(3, x1 - kage.kMinWidthT, y1);
\r
998 poly.set(0, x1 + kage.kMinWidthT, y1);
\r
1001 poly.set(3, x1 - kage.kMinWidthT, y1 - kage.kMinWidthY - kage.kMinWidthT);
\r
1002 poly.set(0, x1 + kage.kMinWidthT, y1 - kage.kMinWidthY);
\r
1005 poly.set(3, x1 - kage.kMinWidthT, y1 - kage.kMinWidthY);
\r
1006 poly.set(0, x1 + kage.kMinWidthT, y1 - kage.kMinWidthY);
\r
1012 if(a1 == 6){ //KAGI's tail ... no need
\r
1013 poly.set(2, x2 - kage.kMinWidthT, y2);
\r
1014 poly.set(1, x2 + kage.kMinWidthT, y2);
\r
1017 poly.set(2, x2 - kage.kMinWidthT, y2 + kage.kMinWidthT / 2);
\r
1018 poly.set(1, x2 + kage.kMinWidthT, y2 - kage.kMinWidthT / 2);
\r
1022 poly.set(2, x2 - kage.kMinWidthT, y2);
\r
1023 poly.set(1, x2 + kage.kMinWidthT, y2);
\r
1026 poly.set(2, x2 - kage.kMinWidthT, y2 + kage.kAdjustKakatoL[opt2] + kage.kMinWidthT);
\r
1027 poly.set(1, x2 + kage.kMinWidthT, y2 + kage.kAdjustKakatoL[opt2]);
\r
1030 poly.set(2, x2 - kage.kMinWidthT, y2 + kage.kAdjustKakatoR[opt2] + kage.kMinWidthT);
\r
1031 poly.set(1, x2 + kage.kMinWidthT, y2 + kage.kAdjustKakatoR[opt2]);
\r
1034 poly.set(2, x2 - kage.kMinWidthT, y2 + kage.kMinWidthY);
\r
1035 poly.set(1, x2 + kage.kMinWidthT, y2 + kage.kMinWidthY);
\r
1039 polygons.push(poly);
\r
1041 if(a1 == 22){ //box's right top corner
\r
1042 poly = new Polygon();
\r
1043 poly.push(x1 - kage.kMinWidthT, y1 - kage.kMinWidthY);
\r
1044 poly.push(x1, y1 - kage.kMinWidthY - kage.kWidth);
\r
1045 poly.push(x1 + kage.kMinWidthT + kage.kWidth, y1 + kage.kMinWidthY);
\r
1046 poly.push(x1 + kage.kMinWidthT, y1 + kage.kMinWidthT);
\r
1047 poly.push(x1 - kage.kMinWidthT, y1);
\r
1048 polygons.push(poly);
\r
1051 if(a1 == 0){ //beginning of the stroke
\r
1052 poly = new Polygon();
\r
1053 poly.push(x1 + kage.kMinWidthT, y1 + kage.kMinWidthY * 0.5);
\r
1054 poly.push(x1 + kage.kMinWidthT + kage.kMinWidthT * 0.5, y1 + kage.kMinWidthY * 0.5 + kage.kMinWidthY);
\r
1055 poly.push(x1 + kage.kMinWidthT, y1 + kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2);
\r
1056 polygons.push(poly);
\r
1059 if((a1 == 6 && a2 == 0) || a2 == 1){ //KAGI NO YOKO BOU NO SAIGO NO MARU ... no need only used at 1st=yoko
\r
1060 poly = new Polygon();
\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 poly.push(x2 + kage.kMinWidthT * 0.6, y2 + kage.kMinWidthT * 0.6);
\r
1065 poly.push(x2 + kage.kMinWidthT, y2);
\r
1066 poly.reverse(); // for fill-rule
\r
1067 polygons.push(poly);
\r
1070 else if(y1 == y2){ //if it is YOKO stroke, use x-axis
\r
1071 if(a1 == 6){ //if it is KAGI's YOKO stroke, get bold
\r
1072 poly = new Polygon();
\r
1073 poly.push(x1, y1 - kage.kMinWidthT);
\r
1074 poly.push(x2, y2 - kage.kMinWidthT);
\r
1075 poly.push(x2, y2 + kage.kMinWidthT);
\r
1076 poly.push(x1, y1 + kage.kMinWidthT);
\r
1077 polygons.push(poly);
\r
1079 if(a2 == 1 || a2 == 0 || a2 == 5){ // no need a2=1
\r
1080 //KAGI NO YOKO BOU NO SAIGO NO MARU
\r
1081 poly = new Polygon();
\r
1082 poly.push(x2, y2 - kage.kMinWidthT);
\r
1083 poly.push(x2 + kage.kMinWidthT * 0.6, y2 - kage.kMinWidthT * 0.6);
\r
1084 poly.push(x2 + kage.kMinWidthT, y2);
\r
1085 poly.push(x2 + kage.kMinWidthT * 0.6, y2 + kage.kMinWidthT * 0.6);
\r
1086 poly.push(x2, y2 + kage.kMinWidthT);
\r
1087 polygons.push(poly);
\r
1091 //KAGI NO YOKO BOU NO HANE
\r
1092 poly = new Polygon();
\r
1093 poly.push(x2, y2 - kage.kMinWidthT + 1);
\r
1094 poly.push(x2 + 2, y2 - kage.kMinWidthT - kage.kWidth * 5);
\r
1095 poly.push(x2, y2 - kage.kMinWidthT - kage.kWidth * 5);
\r
1096 poly.push(x2 - kage.kMinWidthT, y2 - kage.kMinWidthT + 1);
\r
1097 poly.reverse(); // for fill-rule
\r
1098 polygons.push(poly);
\r
1102 poly = new Polygon(4);
\r
1105 poly.set(0, x1, y1 - kage.kMinWidthY);
\r
1106 poly.set(3, x1, y1 + kage.kMinWidthY);
\r
1109 poly.set(0, x1 - kage.kMinWidthT, y1 - kage.kMinWidthY);
\r
1110 poly.set(3, x1 - kage.kMinWidthT, y1 + kage.kMinWidthY);
\r
1116 poly.set(1, x2, y2 - kage.kMinWidthY);
\r
1117 poly.set(2, x2, y2 + kage.kMinWidthY);
\r
1120 poly.set(1, x2 + kage.kMinWidthT, y2 - kage.kMinWidthY);
\r
1121 poly.set(2, x2 + kage.kMinWidthT, y2 + kage.kMinWidthY);
\r
1124 polygons.push(poly);
\r
1128 poly = new Polygon();
\r
1129 poly.push(x2, y2 - kage.kMinWidthY);
\r
1130 poly.push(x2 - 24, y2);
\r
1131 poly.push(x2 - 12, y2 - 12);
\r
1132 polygons.push(poly);
\r
1136 else{ //for others, use x-axis
\r
1137 rad = Math.atan((y2 - y1) / (x2 - x1));
\r
1138 if((Math.abs(y2 - y1) < Math.abs(x2 - x1)) && (a1 != 6) && (a2 != 6) && !(x1 > x2)){ //ASAI KAUDO
\r
1139 poly = new Polygon(4);
\r
1140 switch(a1){ //must be 0 or 2
\r
1142 poly.set(0, x1 + Math.sin(rad) * kage.kMinWidthY, y1 - Math.cos(rad) * kage.kMinWidthY);
\r
1143 poly.set(3, x1 - Math.sin(rad) * kage.kMinWidthY, y1 + Math.cos(rad) * kage.kMinWidthY);
\r
1146 poly.set(0, x1 + Math.sin(rad) * kage.kMinWidthY - kage.kMinWidthT * Math.cos(rad),
\r
1147 y1 - Math.cos(rad) * kage.kMinWidthY - kage.kMinWidthT * Math.sin(rad));
\r
1148 poly.set(3, x1 - Math.sin(rad) * kage.kMinWidthY - kage.kMinWidthT * Math.cos(rad),
\r
1149 y1 + Math.cos(rad) * kage.kMinWidthY - kage.kMinWidthT * Math.sin(rad));
\r
1153 switch(a2){ //must be 0 or 2
\r
1155 poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthY, y2 - Math.cos(rad) * kage.kMinWidthY);
\r
1156 poly.set(2, x2 - Math.sin(rad) * kage.kMinWidthY, y2 + Math.cos(rad) * kage.kMinWidthY);
\r
1159 poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthY + kage.kMinWidthT * Math.cos(rad),
\r
1160 y2 - Math.cos(rad) * kage.kMinWidthY + kage.kMinWidthT * Math.sin(rad));
\r
1161 poly.set(2, x2 - Math.sin(rad) * kage.kMinWidthY + kage.kMinWidthT * Math.cos(rad),
\r
1162 y2 + Math.cos(rad) * kage.kMinWidthY + kage.kMinWidthT * Math.sin(rad));
\r
1165 polygons.push(poly);
\r
1169 poly = new Polygon();
\r
1170 poly.push(x2 + Math.sin(rad) * kage.kMinWidthY, y2 - Math.cos(rad) * kage.kMinWidthY);
\r
1171 poly.push(x2 - Math.cos(rad) * 24, y2 - Math.sin(rad) * 24);
\r
1172 poly.push(x2 - Math.cos(rad) * 12 + Math.sin(rad) * 12, y2 - Math.sin(rad) * 12 - Math.cos(rad) * 12);
\r
1173 polygons.push(poly);
\r
1177 else{ //KAKUDO GA FUKAI or KAGI NO YOKO BOU
\r
1178 if(x1 > x2){ v = -1; } else{ v = 1; }
\r
1179 poly = new Polygon(4);
\r
1182 poly.set(0, x1 + Math.sin(rad) * kage.kMinWidthT * v + kage.kMinWidthY * Math.cos(rad) * 0.5 * v,
\r
1183 y1 - Math.cos(rad) * kage.kMinWidthT * v + kage.kMinWidthY * Math.sin(rad) * 0.5 * v);
\r
1184 poly.set(3, x1 - Math.sin(rad) * kage.kMinWidthT * v - kage.kMinWidthY * Math.cos(rad) * 0.5 * v,
\r
1185 y1 + Math.cos(rad) * kage.kMinWidthT * v - kage.kMinWidthY * Math.sin(rad) * 0.5 * v);
\r
1190 poly.set(0, x1 + Math.sin(rad) * kage.kMinWidthT * v, y1 - Math.cos(rad) * kage.kMinWidthT * v);
\r
1191 poly.set(3, x1 - Math.sin(rad) * kage.kMinWidthT * v, y1 + Math.cos(rad) * kage.kMinWidthT * v);
\r
1194 poly.set(0, x1 + Math.sin(rad) * kage.kMinWidthT * v - kage.kMinWidthY * Math.cos(rad) * v,
\r
1195 y1 - Math.cos(rad) * kage.kMinWidthT * v - kage.kMinWidthY * Math.sin(rad) * v);
\r
1196 poly.set(3, x1 - Math.sin(rad) * kage.kMinWidthT * v - (kage.kMinWidthT + kage.kMinWidthY) * Math.cos(rad) * v,
\r
1197 y1 + Math.cos(rad) * kage.kMinWidthT * v - (kage.kMinWidthT + kage.kMinWidthY) * Math.sin(rad) * v);
\r
1200 poly.set(0, x1 + Math.sin(rad) * kage.kMinWidthT * v - kage.kMinWidthY * Math.cos(rad) * v,
\r
1201 y1 - Math.cos(rad) * kage.kMinWidthT * v - kage.kMinWidthY * Math.sin(rad) * v);
\r
1202 poly.set(3, x1 - Math.sin(rad) * kage.kMinWidthT * v - kage.kMinWidthY * Math.cos(rad) * v,
\r
1203 y1 + Math.cos(rad) * kage.kMinWidthT * v - kage.kMinWidthY * Math.sin(rad) * v);
\r
1210 poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthT * v, y2 - Math.cos(rad) * kage.kMinWidthT * v);
\r
1211 poly.set(2, x2 - Math.sin(rad) * kage.kMinWidthT * v, y2 + Math.cos(rad) * kage.kMinWidthT * v);
\r
1214 poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthT * v - kage.kMinWidthT * 0.5 * Math.cos(rad) * v,
\r
1215 y2 - Math.cos(rad) * kage.kMinWidthT * v - kage.kMinWidthT * 0.5 * Math.sin(rad) * v);
\r
1216 poly.set(2, x2 - Math.sin(rad) * kage.kMinWidthT * v + kage.kMinWidthT * 0.5 * Math.cos(rad) * v,
\r
1217 y2 + Math.cos(rad) * kage.kMinWidthT * v + kage.kMinWidthT * 0.5 * Math.sin(rad) * v);
\r
1220 case 1: // is needed?
\r
1222 poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthT * v, y2 - Math.cos(rad) * kage.kMinWidthT * v);
\r
1223 poly.set(2, x2 - Math.sin(rad) * kage.kMinWidthT * v, y2 + Math.cos(rad) * kage.kMinWidthT * v);
\r
1226 poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthT * v + kage.kAdjustKakatoL[opt2] * Math.cos(rad) * v,
\r
1227 y2 - Math.cos(rad) * kage.kMinWidthT * v + kage.kAdjustKakatoL[opt2] * Math.sin(rad) * v);
\r
1228 poly.set(2, x2 - Math.sin(rad) * kage.kMinWidthT * v + (kage.kAdjustKakatoL[opt2] + kage.kMinWidthT) * Math.cos(rad) * v,
\r
1229 y2 + Math.cos(rad) * kage.kMinWidthT * v + (kage.kAdjustKakatoL[opt2] + kage.kMinWidthT) * Math.sin(rad) * v);
\r
1232 poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthT * v + kage.kAdjustKakatoR[opt2] * Math.cos(rad) * v,
\r
1233 y2 - Math.cos(rad) * kage.kMinWidthT * v + kage.kAdjustKakatoR[opt2] * Math.sin(rad) * v);
\r
1235 x2 - Math.sin(rad) * kage.kMinWidthT * v + (kage.kAdjustKakatoR[opt2] + kage.kMinWidthT) * Math.cos(rad) * v,
\r
1236 y2 + Math.cos(rad) * kage.kMinWidthT * v + (kage.kAdjustKakatoR[opt2] + kage.kMinWidthT) * Math.sin(rad) * v);
\r
1239 poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthT * v + kage.kMinWidthY * Math.cos(rad) * v,
\r
1240 y2 - Math.cos(rad) * kage.kMinWidthT * v + kage.kMinWidthY * Math.sin(rad) * v);
\r
1241 poly.set(2, x2 - Math.sin(rad) * kage.kMinWidthT * v + kage.kMinWidthY * Math.cos(rad) * v,
\r
1242 y2 + Math.cos(rad) * kage.kMinWidthT * v + kage.kMinWidthY * Math.sin(rad) * v);
\r
1246 polygons.push(poly);
\r
1248 if((a1 == 6) && (a2 == 0 || a2 == 5)){ //KAGI NO YOKO BOU NO SAIGO NO MARU
\r
1249 poly = new Polygon();
\r
1250 poly.push(x2 + Math.sin(rad) * kage.kMinWidthT * v, y2 - Math.cos(rad) * kage.kMinWidthT * v);
\r
1251 poly.push(x2 + Math.cos(rad) * kage.kMinWidthT * 0.8 * v + Math.sin(rad) * kage.kMinWidthT * 0.6 * v,
\r
1252 y2 + Math.sin(rad) * kage.kMinWidthT * 0.8 * v - Math.cos(rad) * kage.kMinWidthT * 0.6 * v);
\r
1253 poly.push(x2 + Math.cos(rad) * kage.kMinWidthT * v, y2 + Math.sin(rad) * kage.kMinWidthT * v);
\r
1254 poly.push(x2 + Math.cos(rad) * kage.kMinWidthT * 0.8 * v - Math.sin(rad) * kage.kMinWidthT * 0.6 * v,
\r
1255 y2 + Math.sin(rad) * kage.kMinWidthT * 0.8 * v + Math.cos(rad) * kage.kMinWidthT * 0.6 * v);
\r
1256 poly.push(x2 - Math.sin(rad) * kage.kMinWidthT * v, y2 + Math.cos(rad) * kage.kMinWidthT * v);
\r
1257 polygons.push(poly);
\r
1260 if(a1 == 6 && a2 == 5){
\r
1261 //KAGI NO YOKO BOU NO HANE
\r
1262 poly = new Polygon();
\r
1263 poly.push(x2 + (kage.kMinWidthT - 1) * Math.sin(rad) * v, y2 - (kage.kMinWidthT - 1) * Math.cos(rad) * v);
\r
1264 poly.push(x2 + 2 * Math.cos(rad) * v + (kage.kMinWidthT + kage.kWidth * 5) * Math.sin(rad) * v,
\r
1265 y2 + 2 * Math.sin(rad) * v - (kage.kMinWidthT + kage.kWidth * 5) * Math.cos(rad) * v);
\r
1266 poly.push(x2 + (kage.kMinWidthT + kage.kWidth * 5) * Math.sin(rad) * v,
\r
1267 y2 - (kage.kMinWidthT + kage.kWidth * 5) * Math.cos(rad) * v);
\r
1268 poly.push(x2 + (kage.kMinWidthT - 1) * Math.sin(rad) * v - kage.kMinWidthT * Math.cos(rad) * v,
\r
1269 y2 - (kage.kMinWidthT - 1) * Math.cos(rad) * v - kage.kMinWidthT * Math.sin(rad) * v);
\r
1270 polygons.push(poly);
\r
1273 if(a1 == 22){ //SHIKAKU MIGIUE UROKO NANAME DEMO MASSUGU MUKI
\r
1274 poly = new Polygon();
\r
1275 poly.push(x1 - kage.kMinWidthT, y1 - kage.kMinWidthY);
\r
1276 poly.push(x1, y1 - kage.kMinWidthY - kage.kWidth);
\r
1277 poly.push(x1 + kage.kMinWidthT + kage.kWidth, y1 + kage.kMinWidthY);
\r
1278 poly.push(x1 + kage.kMinWidthT, y1 + kage.kMinWidthT);
\r
1279 poly.push(x1 - kage.kMinWidthT, y1);
\r
1280 polygons.push(poly);
\r
1283 XX = Math.sin(rad) * v;
\r
1284 XY = Math.cos(rad) * v * -1;
\r
1285 YX = Math.cos(rad) * v;
\r
1286 YY = Math.sin(rad) * v;
\r
1288 if(a1 == 0){ //beginning of the storke
\r
1289 poly = new Polygon();
\r
1290 poly.push(x1 + kage.kMinWidthT * XX + (kage.kMinWidthY * 0.5) * YX,
\r
1291 y1 + kage.kMinWidthT * XY + (kage.kMinWidthY * 0.5) * YY);
\r
1292 poly.push(x1 + (kage.kMinWidthT + kage.kMinWidthT * 0.5) * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY) * YX,
\r
1293 y1 + (kage.kMinWidthT + kage.kMinWidthT * 0.5) * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY) * YY);
\r
1294 poly.push(x1 + kage.kMinWidthT * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YX,
\r
1295 y1 + kage.kMinWidthT * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YY);
\r
1296 polygons.push(poly);
\r
1302 if(tx1 == tx2){ //if TATE stroke, use y-axis
\r
1320 if(a1 % 10 == 2){ y1 = y1 - kage.kWidth; }
\r
1321 if(a2 % 10 == 2){ y2 = y2 + kage.kWidth; }
\r
1322 if(a1 % 10 == 3){ y1 = y1 - kage.kWidth * kage.kKakato; }
\r
1323 if(a2 % 10 == 3){ y2 = y2 + kage.kWidth * kage.kKakato; }
\r
1325 poly = new Polygon();
\r
1326 poly.push(x1 - kage.kWidth, y1);
\r
1327 poly.push(x2 - kage.kWidth, y2);
\r
1328 poly.push(x2 + kage.kWidth, y2);
\r
1329 poly.push(x1 + kage.kWidth, y1);
\r
1330 poly.reverse(); // for fill-rule
\r
1332 polygons.push(poly);
\r
1334 else if(ty1 == ty2){ //if YOKO stroke, use x-axis
\r
1351 if(a1 % 10 == 2){ x1 = x1 - kage.kWidth; }
\r
1352 if(a2 % 10 == 2){ x2 = x2 + kage.kWidth; }
\r
1353 if(a1 % 10 == 3){ x1 = x1 - kage.kWidth * kage.kKakato; }
\r
1354 if(a2 % 10 == 3){ x2 = x2 + kage.kWidth * kage.kKakato; }
\r
1356 poly = new Polygon();
\r
1357 poly.push(x1, y1 - kage.kWidth);
\r
1358 poly.push(x2, y2 - kage.kWidth);
\r
1359 poly.push(x2, y2 + kage.kWidth);
\r
1360 poly.push(x1, y1 + kage.kWidth);
\r
1362 polygons.push(poly);
\r
1364 else{ //for others, use x-axis
\r
1381 rad = Math.atan((y2 - y1) / (x2 - x1));
\r
1383 x1 = x1 - kage.kWidth * Math.cos(rad);
\r
1384 y1 = y1 - kage.kWidth * Math.sin(rad);
\r
1387 x2 = x2 + kage.kWidth * Math.cos(rad);
\r
1388 y2 = y2 + kage.kWidth * Math.sin(rad);
\r
1391 x1 = x1 - kage.kWidth * Math.cos(rad) * kage.kKakato;
\r
1392 y1 = y1 - kage.kWidth * Math.sin(rad) * kage.kKakato;
\r
1395 x2 = x2 + kage.kWidth * Math.cos(rad) * kage.kKakato;
\r
1396 y2 = y2 + kage.kWidth * Math.sin(rad) * kage.kKakato;
\r
1399 //SUICHOKU NO ICHI ZURASHI HA Math.sin TO Math.cos NO IREKAE + x-axis MAINASU KA
\r
1400 poly = new Polygon();
\r
1401 poly.push(x1 + Math.sin(rad) * kage.kWidth, y1 - Math.cos(rad) * kage.kWidth);
\r
1402 poly.push(x2 + Math.sin(rad) * kage.kWidth, y2 - Math.cos(rad) * kage.kWidth);
\r
1403 poly.push(x2 - Math.sin(rad) * kage.kWidth, y2 + Math.cos(rad) * kage.kWidth);
\r
1404 poly.push(x1 - Math.sin(rad) * kage.kWidth, y1 + Math.cos(rad) * kage.kWidth);
\r
1406 polygons.push(poly);
\r