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
13 if(kage.kShotai == kage.kMincho){ // mincho
\r
17 delta = -1 * kage.kMinWidthY * 0.5;
\r
20 case 2: // must be 32
\r
27 delta = kage.kMinWidthY;
\r
34 if(y1 < y2){ y1 = y1 - delta; }
\r
35 else{ y1 = y1 + delta; }
\r
38 if(x1 < x2){ x1 = x1 - delta; }
\r
39 else{ x1 = x1 + delta; }
\r
42 rad = Math.atan((y2 - y1) / (x2 - x1));
\r
43 if(x1 < x2){ v = 1; } else{ v = -1; }
\r
44 x1 = x1 - delta * Math.cos(rad) * v;
\r
45 y1 = y1 - delta * Math.sin(rad) * v;
\r
54 case 15: // it can change to 15->5
\r
55 case 14: // it can change to 14->4
\r
65 if(y3 < y4){ y4 = y4 + delta; }
\r
66 else{ y4 = y4 - delta; }
\r
69 if(x3 < x4){ x4 = x4 + delta; }
\r
70 else{ x4 = x4 - delta; }
\r
73 rad = Math.atan((y4 - y3) / (x4 - x3));
\r
74 if(x3 < x4){ v = 1; } else{ v = -1; }
\r
75 x4 = x4 + delta * Math.cos(rad) * v;
\r
76 y4 = y4 + delta * Math.sin(rad) * v;
\r
79 poly = new Polygon();
\r
80 poly2 = new Polygon();
\r
81 for(tt = 0; tt <= 1000; tt = tt + kage.kRate){
\r
85 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
86 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
87 //KATAMUKI of vector by BIBUN
\r
88 ix = t * t * (-3 * x1 + 9 * x2 + -9 * x3 + 3 * x4) + t * (6 * x1 + -12 * x2 + 6 * x3) + -3 * x1 + 3 * x2;
\r
89 iy = t * t * (-3 * y1 + 9 * y2 + -9 * y3 + 3 * y4) + t * (6 * y1 + -12 * y2 + 6 * y3) + -3 * y1 + 3 * y2;
\r
91 //line SUICHOKU by vector
\r
92 if(ix != 0 && iy != 0){
\r
93 ir = Math.atan(iy / ix * -1);
\r
94 ia = Math.sin(ir) * (kage.kMinWidthT);
\r
95 ib = Math.cos(ir) * (kage.kMinWidthT);
\r
98 ia = kage.kMinWidthT;
\r
103 ib = kage.kMinWidthT;
\r
106 if(a1 == 7){ deltad = Math.sqrt(t); }
\r
107 else if(a2 == 7){ deltad = Math.sqrt(1.0 - t); }
\r
108 else{ deltad = 1; }
\r
112 //reverse if vector is going 2nd/3rd quadrants
\r
118 //copy to polygon structuer
\r
119 poly.push(x - ia, y - ib);
\r
120 poly2.push(x + ia, y + ib);
\r
123 poly.concat(poly2);
\r
124 polygons.push(poly);
\r
126 //process for head of stroke
\r
127 rad = Math.atan((y2 - y1) / (x2 - x1));
\r
128 if(x1 < x2){ v = 1; } else{ v = -1; }
\r
129 XX = Math.sin(rad) * v;
\r
130 XY = Math.cos(rad) * v * -1;
\r
131 YX = Math.cos(rad) * v;
\r
132 YY = Math.sin(rad) * v;
\r
136 poly = new Polygon();
\r
137 poly.push(x1 - kage.kMinWidthT, y1);
\r
138 poly.push(x1 + kage.kMinWidthT, y1);
\r
139 poly.push(x1 - kage.kMinWidthT, y1 - kage.kMinWidthT);
\r
140 polygons.push(poly);
\r
143 poly = new Polygon();
\r
144 poly.push(x1 - kage.kMinWidthT * XX, y1 - kage.kMinWidthT * XY);
\r
145 poly.push(x1 + kage.kMinWidthT * XX, y1 + kage.kMinWidthT * XY);
\r
146 poly.push(x1 - kage.kMinWidthT * XX - kage.kMinWidthT * YX, y1 - kage.kMinWidthT * XY - kage.kMinWidthT * YY);
\r
147 polygons.push(poly);
\r
152 if(y1 <= y4){ //from up to bottom
\r
154 poly = new Polygon();
\r
155 poly.push(x1 - kage.kMinWidthT, y1);
\r
156 poly.push(x1 + kage.kMinWidthT, y1);
\r
157 poly.push(x1 - kage.kMinWidthT, y1 - kage.kMinWidthY);
\r
158 polygons.push(poly);
\r
161 poly = new Polygon();
\r
162 poly.push(x1 - kage.kMinWidthT * XX, y1 - kage.kMinWidthT * XY);
\r
163 poly.push(x1 + kage.kMinWidthT * XX, y1 + kage.kMinWidthT * XY);
\r
164 poly.push(x1 - kage.kMinWidthT * XX - kage.kMinWidthY * YX, y1 - kage.kMinWidthT * XY - kage.kMinWidthY * YY);
\r
165 polygons.push(poly);
\r
168 else{ //bottom to up
\r
169 if(x1 == x2){ //is it right?
\r
170 poly = new Polygon();
\r
171 poly.push(x1 - kage.kMinWidthT, y1);
\r
172 poly.push(x1 + kage.kMinWidthT, y1);
\r
173 poly.push(x1 - kage.kMinWidthT, y1 + kage.kMinWidthY);
\r
174 polygons.push(poly);
\r
177 poly = new Polygon();
\r
178 poly.push(x1 - kage.kMinWidthT * XX, y1 - kage.kMinWidthT * XY);
\r
179 poly.push(x1 + kage.kMinWidthT * XX, y1 + kage.kMinWidthT * XY);
\r
180 poly.push(x1 + kage.kMinWidthT * XX - kage.kMinWidthY * YX, y1 + kage.kMinWidthT * XY - kage.kMinWidthY * YY);
\r
181 polygons.push(poly);
\r
186 if(a1 == 22){ //box's up-right corner, any time same degree
\r
187 poly = new Polygon();
\r
188 poly.push(x1 - kage.kMinWidthT, y1 - kage.kMinWidthY);
\r
189 poly.push(x1, y1 - kage.kMinWidthY - kage.kWidth);
\r
190 poly.push(x1 + kage.kMinWidthT + kage.kWidth, y1 + kage.kMinWidthY);
\r
191 poly.push(x1 + kage.kMinWidthT, y1 + kage.kMinWidthT);
\r
192 poly.push(x1 - kage.kMinWidthT, y1);
\r
193 polygons.push(poly);
\r
196 if(a1 == 0){ //beginning of the stroke
\r
197 if(y1 <= y4){ //from up to bottom
\r
199 poly = new Polygon();
\r
200 poly.push(x1 + kage.kMinWidthT, y1 + kage.kMinWidthY * 0.5);
\r
201 poly.push(x1 + kage.kMinWidthT + kage.kMinWidthT * 0.5, y1 + kage.kMinWidthY * 0.5 + kage.kMinWidthY);
\r
202 poly.push(x1 + kage.kMinWidthT, y1 + kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2);
\r
203 polygons.push(poly);
\r
206 poly = new Polygon();
\r
207 poly.push(x1 + kage.kMinWidthT * XX + (kage.kMinWidthY * 0.5) * YX,
\r
208 y1 + kage.kMinWidthT * XY + (kage.kMinWidthY * 0.5) * YY);
\r
209 poly.push(x1 + (kage.kMinWidthT + kage.kMinWidthT * 0.5) * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY) * YX,
\r
210 y1 + (kage.kMinWidthT + kage.kMinWidthT * 0.5) * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY) * YY);
\r
211 poly.push(x1 + kage.kMinWidthT * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YX,
\r
212 y1 + kage.kMinWidthT * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YY);
\r
213 polygons.push(poly);
\r
216 else{ //from bottom to up
\r
217 if(x1 == x2){ //is it right?
\r
218 poly = new Polygon();
\r
219 poly.push(x1 + kage.kMinWidthT, y1 - kage.kMinWidthY * 0.5);
\r
220 poly.push(x1 + kage.kMinWidthT + kage.kMinWidthT * 0.5, y1 - kage.kMinWidthY * 0.5 - kage.kMinWidthY);
\r
221 poly.push(x1 + kage.kMinWidthT, y1 - kage.kMinWidthY * 0.5 - kage.kMinWidthY * 2);
\r
222 polygons.push(poly);
\r
224 else{ //SETSUGOUMEN GA KAKERUNODE HOKYOU
\r
225 poly = new Polygon();
\r
226 poly.push(x1 - (kage.kMinWidthT - 1) * XX + (kage.kMinWidthY * 0.5) * YX,
\r
227 y1 - (kage.kMinWidthT - 1) * XY + (kage.kMinWidthY * 0.5) * YY);
\r
228 poly.push(x1 - (kage.kMinWidthT - 0) * XX + (kage.kMinWidthY * 0.5) * YX,
\r
229 y1 - (kage.kMinWidthT - 0) * XY + (kage.kMinWidthY * 0.5) * YY);
\r
230 poly.push(x1 - (kage.kMinWidthT + kage.kMinWidthT * 0.5) * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY) * YX,
\r
231 y1 - (kage.kMinWidthT + kage.kMinWidthT * 0.5) * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY) * YY);
\r
232 poly.push(x1 - (kage.kMinWidthT - 0) * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YX,
\r
233 y1 - (kage.kMinWidthT - 0) * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YY);
\r
234 poly.push(x1 - (kage.kMinWidthT - 1) * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YX,
\r
235 y1 - (kage.kMinWidthT - 1) * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YY);
\r
236 polygons.push(poly);
\r
242 rad = Math.atan((y4 - y3) / (x4 - x3));
\r
243 if(x3 < x4){ v = 1; } else{ v = -1; }
\r
244 YX = Math.sin(rad) * v * -1;
\r
245 YY = Math.cos(rad) * v;
\r
246 XX = Math.cos(rad) * v;
\r
247 XY = Math.sin(rad) * v;
\r
249 if(a2 == 1 || a2 == 8 || a2 == 15){ //the last filled circle ... it can change to 15->5
\r
252 poly.push(x4 - kage.kMinWidthT, y4);
\r
253 poly.push(x4 - kage.kMinWidthT * 0.7, y4 + kage.kMinWidthT * 0.7);
\r
254 poly.push(x4, y4 + kage.kMinWidthT);
\r
255 poly.push(x4 + kage.kMinWidthT * 0.7, y4 + kage.kMinWidthT * 0.7);
\r
256 poly.push(x4 + kage.kMinWidthT, y4);
\r
257 polygons.push(poly);
\r
260 poly = new Polygon();
\r
261 poly.push(x4, y4 - kage.kMinWidthT);
\r
262 poly.push(x4 + kage.kMinWidthT * 0.7, y4 - kage.kMinWidthT * 0.7);
\r
263 poly.push(x4 + kage.kMinWidthT, y4);
\r
264 poly.push(x4 + kage.kMinWidthT * 0.7, y4 + kage.kMinWidthT * 0.7);
\r
265 poly.push(x4, y4 + kage.kMinWidthT);
\r
266 polygons.push(poly);
\r
269 poly = new Polygon();
\r
270 poly.push(x4 + Math.sin(rad) * kage.kMinWidthT * v, y4 - Math.cos(rad) * kage.kMinWidthT * v);
\r
271 poly.push(x4 + Math.cos(rad) * kage.kMinWidthT * 0.7 * v + Math.sin(rad) * kage.kMinWidthT * 0.7 * v,
\r
272 y4 + Math.sin(rad) * kage.kMinWidthT * 0.7 * v - Math.cos(rad) * kage.kMinWidthT * 0.7 * v);
\r
273 poly.push(x4 + Math.cos(rad) * kage.kMinWidthT * v, y4 + Math.sin(rad) * kage.kMinWidthT * v);
\r
274 poly.push(x4 + Math.cos(rad) * kage.kMinWidthT * 0.7 * v - Math.sin(rad) * kage.kMinWidthT * 0.7 * v,
\r
275 y4 + Math.sin(rad) * kage.kMinWidthT * 0.7 * v + Math.cos(rad) * kage.kMinWidthT * 0.7 * v);
\r
276 poly.push(x4 - Math.sin(rad) * kage.kMinWidthT * v, y4 + Math.cos(rad) * kage.kMinWidthT * v);
\r
277 polygons.push(poly);
\r
281 if(a2 == 9 || (a1 == 7 && a2 == 0)){ // Math.sinnyu & L2RD Harai
\r
283 poly = new Polygon();
\r
284 poly.push(x4, y4 + kage.kMinWidthT);
\r
285 poly.push(x4, y4 - kage.kMinWidthT);
\r
286 poly.push(x4 + kage.kMinWidthT, y4 - kage.kMinWidthT);
\r
287 polygons.push(poly);
\r
290 poly = new Polygon();
\r
291 poly.push(x4 + kage.kMinWidthT * YX, y4 + kage.kMinWidthT * YY);
\r
292 poly.push(x4 - kage.kMinWidthT * YX, y4 - kage.kMinWidthT * YY);
\r
293 poly.push(x4 + kage.kMinWidthT * XX - kage.kMinWidthT * YX, y4 + kage.kMinWidthT * XY - kage.kMinWidthT * YY);
\r
294 polygons.push(poly);
\r
298 if(a2 == 15){ //jump up ... it can change to 15->5
\r
300 poly = new Polygon();
\r
301 poly.push(x4, y4 - kage.kMinWidthT + 1);
\r
302 poly.push(x4 + 2, y4 - kage.kMinWidthT - kage.kWidth * 5);
\r
303 poly.push(x4, y4 - kage.kMinWidthT - kage.kWidth * 5);
\r
304 poly.push(x4 - kage.kMinWidthT, y4 - kage.kMinWidthT + 1);
\r
305 polygons.push(poly);
\r
308 poly = new Polygon();
\r
309 poly.push(x4 + (kage.kMinWidthT - 1) * Math.sin(rad) * v, y4 - (kage.kMinWidthT - 1) * Math.cos(rad) * v);
\r
310 poly.push(x4 + 2 * Math.cos(rad) * v + (kage.kMinWidthT + kage.kWidth * 5) * Math.sin(rad) * v,
\r
311 y4 + 2 * Math.sin(rad) * v - (kage.kMinWidthT + kage.kWidth * 5) * Math.cos(rad) * v);
\r
312 poly.push(x4 + (kage.kMinWidthT + kage.kWidth * 5) * Math.sin(rad) * v,
\r
313 y4 - (kage.kMinWidthT + kage.kWidth * 5) * Math.cos(rad) * v);
\r
314 poly.push(x4 + (kage.kMinWidthT - 1) * Math.sin(rad) * v - kage.kMinWidthT * Math.cos(rad) * v,
\r
315 y4 - (kage.kMinWidthT - 1) * Math.cos(rad) * v - kage.kMinWidthT * Math.sin(rad) * v);
\r
316 polygons.push(poly);
\r
320 if(a2 == 14){ //jump to left, allways go left ... it can change to 14->4
\r
321 poly = new Polygon();
\r
323 poly.push(x4, y4 - kage.kMinWidthT);
\r
324 poly.push(x4 - kage.kWidth * 4, y4 - kage.kMinWidthT);
\r
325 poly.push(x4 - kage.kWidth * 4, y4 - kage.kMinWidthT * 0.5);
\r
326 polygons.push(poly);
\r
332 if(y1 < y2){ y1 = y1 - kage.kWidth; } else{ y1 = y1 + kage.kWidth; }
\r
335 if(x1 < x2){ x1 = x1 - kage.kWidth; } else{ x1 = x1 + kage.kWidth; }
\r
338 rad = Math.atan((y2 - y1) / (x2 - x1));
\r
339 if(x1 < x2){ v = 1; } else{ v = -1; }
\r
340 x1 = x1 - kage.kWidth * Math.cos(rad) * v;
\r
341 y1 = y1 - kage.kWidth * Math.sin(rad) * v;
\r
348 y1 = y1 - kage.kWidth * kage.kKakato;
\r
351 y1 = y1 + kage.kWidth * kage.kKakato;
\r
356 x1 = x1 - kage.kWidth * kage.kKakato;
\r
359 x1 = x1 + kage.kWidth * kage.kKakato;
\r
363 rad = Math.atan((y2 - y1) / (x2 - x1));
\r
364 if(x1 < x2){ v = 1; } else{ v = -1; }
\r
365 x1 = x1 - kage.kWidth * Math.cos(rad) * v * kage.kKakato;
\r
366 y1 = y1 - kage.kWidth * Math.sin(rad) * v * kage.kKakato;
\r
371 if(y3 < y4){ y4 = y4 + kage.kWidth; } else{ y4 = y4 - kage.kWidth; }
\r
374 if(x3 < x4){ x4 = x4 + kage.kWidth; } else{ x4 = x4 - kage.kWidth; }
\r
377 rad = Math.atan((y4 - y3) / (x4 - x3));
\r
378 if(x3 < x4){ v = 1; } else{ v = -1; }
\r
379 x4 = x4 + kage.kWidth * Math.cos(rad) * v;
\r
380 y4 = y4 + kage.kWidth * Math.sin(rad) * v;
\r
387 y4 = y4 + kage.kWidth * kage.kKakato;
\r
390 y4 = y4 - kage.kWidth * kage.kKakato;
\r
395 x4 = x4 + kage.kWidth * kage.kKakato;
\r
398 x4 = x4 - kage.kWidth * kage.kKakato;
\r
402 rad = Math.atan((y4 - y3) / (x4 - x3));
\r
403 if(x3 < x4){ v = 1; } else{ v = -1; }
\r
404 x4 = x4 + kage.kWidth * Math.cos(rad) * v * kage.kKakato;
\r
405 y4 = y4 + kage.kWidth * Math.sin(rad) * v * kage.kKakato;
\r
409 poly = new Polygon();
\r
410 poly2= new Polygon();
\r
412 for(tt = 0; tt <= 1000; tt = tt + kage.kRate){
\r
416 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
417 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
418 //KATAMUKI of vector by BIBUN
\r
419 ix = t * t * (-3 * x1 + 9 * x2 + -9 * x3 + 3 * x4) + t * (6 * x1 + -12 * x2 + 6 * x3) + -3 * x1 + 3 * x2;
\r
420 iy = t * t * (-3 * y1 + 9 * y2 + -9 * y3 + 3 * y4) + t * (6 * y1 + -12 * y2 + 6 * y3) + -3 * y1 + 3 * y2;
\r
422 //SESSEN NI SUICHOKU NA CHOKUSEN NO KEISAN
\r
423 if(kage.kShotai == kage.kMincho){ //always false ?
\r
424 if(ix != 0 && iy != 0){
\r
425 ir = Math.atan(iy / ix * -1.0);
\r
426 ia = Math.sin(ir) * kage.kMinWidthT;
\r
427 ib = Math.cos(ir) * kage.kMinWidthT;
\r
430 ia = kage.kMinWidthT;
\r
435 ib = kage.kMinWidthT;
\r
437 ia = ia * Math.sqrt(1.0 - t);
\r
438 ib = ib * Math.sqrt(1.0 - t);
\r
441 if(ix != 0 && iy != 0){
\r
442 ir = Math.atan(iy / ix * -1.0);
\r
443 ia = Math.sin(ir) * kage.kWidth;
\r
444 ib = Math.cos(ir) * kage.kWidth;
\r
456 //reverse if vector is going 2nd/3rd quadrants
\r
463 poly.push(x - ia, y - ib);
\r
464 poly2.push(x + ia, y + ib);
\r
468 poly.concat(poly2);
\r
469 polygons.push(poly);
\r
473 function cdDrawCurve(kage, polygons, x1, y1, x2, y2, x3, y3, a1, a2){
\r
476 var ix, iy, ia, ib, ir;
\r
480 var XX, XY, YX, YY;
\r
483 if(kage.kShotai == kage.kMincho){ // mincho
\r
487 delta = -1 * kage.kMinWidthY * 0.5;
\r
490 case 2: // ... must be 32
\r
497 delta = kage.kMinWidthY;
\r
504 if(y1 < y2){ y1 = y1 - delta; }
\r
505 else{ y1 = y1 + delta; }
\r
508 if(x1 < x2){ x1 = x1 - delta; }
\r
509 else{ x1 = x1 + delta; }
\r
512 rad = Math.atan((y2 - y1) / (x2 - x1));
\r
513 if(x1 < x2){ v = 1; } else{ v = -1; }
\r
514 x1 = x1 - delta * Math.cos(rad) * v;
\r
515 y1 = y1 - delta * Math.sin(rad) * v;
\r
523 case 15: // it can change to 15->5
\r
524 case 14: // it can change to 14->4
\r
525 case 17: // no need
\r
529 case 8: // get shorten for tail's circle
\r
530 delta = -1 * kage.kMinWidthT * 0.5;
\r
537 if(y2 < y3){ y3 = y3 + delta; }
\r
538 else{ y3 = y3 - delta; }
\r
541 if(x2 < x3){ x3 = x3 + delta; }
\r
542 else{ x3 = x3 - delta; }
\r
545 rad = Math.atan((y3 - y2) / (x3 - x2));
\r
546 if(x2 < x3){ v = 1; } else{ v = -1; }
\r
547 x3 = x3 + delta * Math.cos(rad) * v;
\r
548 y3 = y3 + delta * Math.sin(rad) * v;
\r
551 poly = new Polygon();
\r
552 poly2 = new Polygon();
\r
554 for(tt = 0; tt <= 1000; tt = tt + kage.kRate){
\r
558 x = ((1.0 - t) * (1.0 - t) * x1 + 2.0 * t * (1.0 - t) * x2 + t * t * x3);
\r
559 y = ((1.0 - t) * (1.0 - t) * y1 + 2.0 * t * (1.0 - t) * y2 + t * t * y3);
\r
561 //KATAMUKI of vector by BIBUN
\r
562 ix = (x1 - 2.0 * x2 + x3) * 2.0 * t + (-2.0 * x1 + 2.0 * x2);
\r
563 iy = (y1 - 2.0 * y2 + y3) * 2.0 * t + (-2.0 * y1 + 2.0 * y2);
\r
565 //line SUICHOKU by vector
\r
566 if(ix != 0 && iy != 0){
\r
567 ir = Math.atan(iy / ix * -1);
\r
568 ia = Math.sin(ir) * (kage.kMinWidthT);
\r
569 ib = Math.cos(ir) * (kage.kMinWidthT);
\r
572 ia = kage.kMinWidthT;
\r
577 ib = kage.kMinWidthT;
\r
580 if(a1 == 7 && a2 == 0){ deltad = Math.sqrt(t) * kage.kL2RDfatten; } //L2RD: fatten
\r
581 else if(a1 == 7){ deltad = Math.sqrt(t); }
\r
582 else if(a2 == 7){ deltad = Math.sqrt(1.0 - t); }
\r
583 else{ deltad = 1; }
\r
587 //reverse if vector is going 2nd/3rd quadrants
\r
593 //copy to polygon structure
\r
594 poly.push(x - ia, y - ib);
\r
595 poly2.push(x + ia, y + ib);
\r
599 poly.concat(poly2);
\r
600 polygons.push(poly);
\r
602 //process for head of stroke
\r
603 rad = Math.atan((y2 - y1) / (x2 - x1));
\r
604 if(x1 < x2){ v = 1; } else{ v = -1; }
\r
605 XX = Math.sin(rad) * v;
\r
606 XY = Math.cos(rad) * v * -1;
\r
607 YX = Math.cos(rad) * v;
\r
608 YY = Math.sin(rad) * v;
\r
612 poly= new Polygon();
\r
613 poly.push(x1 - kage.kMinWidthT, y1);
\r
614 poly.push(x1 + kage.kMinWidthT, y1);
\r
615 poly.push(x1 - kage.kMinWidthT, y1 - kage.kMinWidthT);
\r
616 polygons.push(poly);
\r
619 poly = new Polygon();
\r
620 poly.push(x1 - kage.kMinWidthT * XX, y1 - kage.kMinWidthT * XY);
\r
621 poly.push(x1 + kage.kMinWidthT * XX, y1 + kage.kMinWidthT * XY);
\r
622 poly.push(x1 - kage.kMinWidthT * XX - kage.kMinWidthT * YX, y1 - kage.kMinWidthT * XY - kage.kMinWidthT * YY);
\r
623 polygons.push(poly);
\r
628 if(y1 <= y3){ //from up to bottom
\r
630 poly = new Polygon();
\r
631 poly.push(x1 - kage.kMinWidthT, y1);
\r
632 poly.push(x1 + kage.kMinWidthT, y1);
\r
633 poly.push(x1 - kage.kMinWidthT, y1 - kage.kMinWidthY);
\r
634 polygons.push(poly);
\r
637 poly = new Polygon();
\r
638 poly.push(x1 - kage.kMinWidthT * XX, y1 - kage.kMinWidthT * XY);
\r
639 poly.push(x1 + kage.kMinWidthT * XX, y1 + kage.kMinWidthT * XY);
\r
640 poly.push(x1 - kage.kMinWidthT * XX - kage.kMinWidthY * YX, y1 - kage.kMinWidthT * XY - kage.kMinWidthY * YY);
\r
641 polygons.push(poly);
\r
644 else{ //bottom to up
\r
646 poly = new Polygon();
\r
647 poly.push(x1 - kage.kMinWidthT, y1);
\r
648 poly.push(x1 + kage.kMinWidthT, y1);
\r
649 poly.push(x1 + kage.kMinWidthT, y1 - kage.kMinWidthY);
\r
650 polygons.push(poly);
\r
653 poly = new Polygon();
\r
654 poly.push(x1 - kage.kMinWidthT * XX, y1 - kage.kMinWidthT * XY);
\r
655 poly.push(x1 + kage.kMinWidthT * XX, y1 + kage.kMinWidthT * XY);
\r
656 poly.push(x1 + kage.kMinWidthT * XX - kage.kMinWidthY * YX, y1 + kage.kMinWidthT * XY - kage.kMinWidthY * YY);
\r
657 polygons.push(poly);
\r
662 if(a1 == 22){ //box's up-right corner, any time same degree
\r
663 poly = new Polygon();
\r
664 poly.push(x1 - kage.kMinWidthT, y1 - kage.kMinWidthY);
\r
665 poly.push(x1, y1 - kage.kMinWidthY - kage.kWidth);
\r
666 poly.push(x1 + kage.kMinWidthT + kage.kWidth, y1 + kage.kMinWidthY);
\r
667 poly.push(x1 + kage.kMinWidthT, y1 + kage.kMinWidthT);
\r
668 poly.push(x1, y1 + kage.kMinWidthT);
\r
669 polygons.push(poly);
\r
672 if(a1 == 0){ //beginning of the stroke
\r
673 if(y1 <= y3){ //from up to bottom
\r
675 poly = new Polygon();
\r
676 poly.push(x1 + kage.kMinWidthT, y1 + kage.kMinWidthY * 0.5);
\r
677 poly.push(x1 + kage.kMinWidthT + kage.kMinWidthT * 0.5, y1 + kage.kMinWidthY * 0.5 + kage.kMinWidthY);
\r
678 poly.push(x1 + kage.kMinWidthT, y1 + kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2);
\r
679 polygons.push(poly);
\r
682 poly = new Polygon();
\r
683 poly.push(x1 + kage.kMinWidthT * XX + (kage.kMinWidthY * 0.5) * YX,
\r
684 y1 + kage.kMinWidthT * XY + (kage.kMinWidthY * 0.5) * YY);
\r
685 poly.push(x1 + (kage.kMinWidthT + kage.kMinWidthT * 0.5) * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY) * YX,
\r
686 y1 + (kage.kMinWidthT + kage.kMinWidthT * 0.5) * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY) * YY);
\r
687 poly.push(x1 + kage.kMinWidthT * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YX,
\r
688 y1 + kage.kMinWidthT * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YY);
\r
689 polygons.push(poly);
\r
692 else{ //from bottom to up
\r
693 if(x1 == x2){ //is it right?
\r
694 poly = new Polygon();
\r
695 poly.push(x1 + kage.kMinWidthT, poly2[0].Y = y1 - kage.kMinWidthY * 0.5);
\r
696 poly.push(x1 + kage.kMinWidthT + kage.kMinWidthT * 0.5, y1 - kage.kMinWidthY * 0.5 - kage.kMinWidthY);
\r
697 poly.push(x1 + kage.kMinWidthT, y1 - kage.kMinWidthY * 0.5 - kage.kMinWidthY * 2);
\r
698 polygons.push(poly);
\r
700 else{ //SETSUGOUMEN GA KAKERUNODE HOKYOU
\r
701 poly = new Polygon();
\r
702 poly.push(x1 - (kage.kMinWidthT - 1) * XX + (kage.kMinWidthY * 0.5) * YX,
\r
703 y1 - (kage.kMinWidthT - 1) * XY + (kage.kMinWidthY * 0.5) * YY);
\r
704 poly.push(x1 - (kage.kMinWidthT - 0) * XX + (kage.kMinWidthY * 0.5) * YX,
\r
705 y1 - (kage.kMinWidthT - 0) * XY + (kage.kMinWidthY * 0.5) * YY);
\r
706 poly.push(x1 - (kage.kMinWidthT + kage.kMinWidthT * 0.5) * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY) * YX,
\r
707 y1 - (kage.kMinWidthT + kage.kMinWidthT * 0.5) * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY) * YY);
\r
708 poly.push(x1 - (kage.kMinWidthT - 0) * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YX,
\r
709 y1 - (kage.kMinWidthT - 0) * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YY);
\r
710 poly.push(x1 - (kage.kMinWidthT - 1) * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YX,
\r
711 y1 - (kage.kMinWidthT - 1) * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YY);
\r
712 polygons.push(poly);
\r
718 rad = Math.atan((y3 - y2) / (x3 - x2));
\r
719 if(x2 < x3){ v = 1; } else{ v = -1; }
\r
720 YX = Math.sin(rad) * v * -1;
\r
721 YY = Math.cos(rad) * v;
\r
722 XX = Math.cos(rad) * v;
\r
723 XY = Math.sin(rad) * v;
\r
725 if(a2 == 1 || a2 == 8 || a2 == 15){ //the last filled circle ... it can change 15->5
\r
727 poly = new Polygon();
\r
728 poly.push(x3 - kage.kMinWidthT, y3);
\r
729 poly.push(x3 - kage.kMinWidthT * 0.7, y3 + kage.kMinWidthT * 0.7);
\r
730 poly.push(x3, y3 + kage.kMinWidthT);
\r
731 poly.push(x3 + kage.kMinWidthT * 0.7, y3 + kage.kMinWidthT * 0.7);
\r
732 poly.push(x3 + kage.kMinWidthT, y3);
\r
733 polygons.push(poly);
\r
736 poly = new Polygon();
\r
737 poly.push(x3, y3 - kage.kMinWidthT);
\r
738 poly.push(x3 + kage.kMinWidthT * 0.7, y3 - kage.kMinWidthT * 0.7);
\r
739 poly.push(x3 + kage.kMinWidthT, y3);
\r
740 poly.push(x3 + kage.kMinWidthT * 0.7, y3 + kage.kMinWidthT * 0.7);
\r
741 poly.push(x3, y3 + kage.kMinWidthT);
\r
742 polygons.push(poly);
\r
745 poly = new Polygon();
\r
746 poly.push(x3 + Math.sin(rad) * kage.kMinWidthT * v, y3 - Math.cos(rad) * kage.kMinWidthT * v);
\r
747 poly.push(x3 + Math.cos(rad) * kage.kMinWidthT * 0.7 * v + Math.sin(rad) * kage.kMinWidthT * 0.7 * v,
\r
748 y3 + Math.sin(rad) * kage.kMinWidthT * 0.7 * v - Math.cos(rad) * kage.kMinWidthT * 0.7 * v);
\r
749 poly.push(x3 + Math.cos(rad) * kage.kMinWidthT * v, y3 + Math.sin(rad) * kage.kMinWidthT * v);
\r
750 poly.push(x3 + Math.cos(rad) * kage.kMinWidthT * 0.7 * v - Math.sin(rad) * kage.kMinWidthT * 0.7 * v,
\r
751 y3 + Math.sin(rad) * kage.kMinWidthT * 0.7 * v + Math.cos(rad) * kage.kMinWidthT * 0.7 * v);
\r
752 poly.push(x3 - Math.sin(rad) * kage.kMinWidthT * v, y3 + Math.cos(rad) * kage.kMinWidthT * v);
\r
753 polygons.push(poly);
\r
757 if(a2 == 9 || (a1 == 7 && a2 == 0)){ // Math.sinnyu & L2RD Harai ... no need for a2=9
\r
759 poly = new Polygon();
\r
760 poly.push(x3, y3 + kage.kMinWidthT * kage.kL2RDfatten);
\r
761 poly.push(x3, y3 - kage.kMinWidthT * kage.kL2RDfatten);
\r
762 poly.push(x3 + kage.kMinWidthT * kage.kL2RDfatten, y3 - kage.kMinWidthT * kage.kL2RDfatten);
\r
763 polygons.push(poly);
\r
766 poly = new Polygon();
\r
767 poly.push(x3 + kage.kMinWidthT * kage.kL2RDfatten * YX, y3 + kage.kMinWidthT * kage.kL2RDfatten * YY);
\r
768 poly.push(x3 - kage.kMinWidthT * kage.kL2RDfatten * YX, y3 - kage.kMinWidthT * kage.kL2RDfatten * YY);
\r
769 poly.push(x3 + kage.kMinWidthT * kage.kL2RDfatten * XX - kage.kMinWidthT * kage.kL2RDfatten * YX,
\r
770 y3 + kage.kMinWidthT * kage.kL2RDfatten * XY - kage.kMinWidthT * kage.kL2RDfatten * YY);
\r
771 polygons.push(poly);
\r
775 if(a2 == 15){ //jump up ... it can change 15->5
\r
777 poly = new Polygon();
\r
778 poly.push(x3, y3 - kage.kMinWidthT + 1);
\r
779 poly.push(x3 + 2, y3 - kage.kMinWidthT - kage.kWidth * 5);
\r
780 poly.push(x3, y3 - kage.kMinWidthT - kage.kWidth * 5);
\r
781 poly.push(x3 - kage.kMinWidthT, y3 - kage.kMinWidthT + 1);
\r
782 polygons.push(poly);
\r
785 poly = new Polygon();
\r
786 poly.push(x3 + (kage.kMinWidthT - 1) * Math.sin(rad) * v, y3 - (kage.kMinWidthT - 1) * Math.cos(rad) * v);
\r
787 poly.push(x3 + 2 * Math.cos(rad) * v + (kage.kMinWidthT + kage.kWidth * 5) * Math.sin(rad) * v,
\r
788 y3 + 2 * Math.sin(rad) * v - (kage.kMinWidthT + kage.kWidth * 5) * Math.cos(rad) * v);
\r
789 poly.push(x3 + (kage.kMinWidthT + kage.kWidth * 5) * Math.sin(rad) * v,
\r
790 y3 - (kage.kMinWidthT + kage.kWidth * 5) * Math.cos(rad) * v);
\r
791 poly.push(x3 + (kage.kMinWidthT - 1) * Math.sin(rad) * v - kage.kMinWidthT * Math.cos(rad) * v,
\r
792 y3 - (kage.kMinWidthT - 1) * Math.cos(rad) * v - kage.kMinWidthT * Math.sin(rad) * v);
\r
793 polygons.push(poly);
\r
797 if(a2 == 14){ //jump to left, allways go left ... it can change 14->4
\r
798 poly = new Polygon();
\r
800 poly.push(x3, y3 - kage.kMinWidthT);
\r
801 poly.push(x3 - kage.kWidth * 4, y3 - kage.kMinWidthT);
\r
802 poly.push(x3 - kage.kWidth * 4, y3 - kage.kMinWidthT * 0.5);
\r
803 polygons.push(poly);
\r
809 if(y1 < y2){ y1 = y1 - kage.kWidth; } else{ y1 = y1 + kage.kWidth; }
\r
812 if(x1 < x2){ x1 = x1 - kage.kWidth; } else{ x1 = x1 + kage.kWidth; }
\r
815 rad = Math.atan((y2 - y1) / (x2 - x1));
\r
816 if(x1 < x2){ v = 1; } else{ v = -1; }
\r
817 x1 = x1 - kage.kWidth * Math.cos(rad) * v;
\r
818 y1 = y1 - kage.kWidth * Math.sin(rad) * v;
\r
825 y1 = y1 - kage.kWidth * kage.kKakato;
\r
828 y1 = y1 + kage.kWidth * kage.kKakato;
\r
833 x1 = x1 - kage.kWidth * kage.kKakato;
\r
836 x1 = x1 + kage.kWidth * kage.kKakato;
\r
840 rad = Math.atan((y2 - y1) / (x2 - x1));
\r
841 if(x1 < x2){ v = 1; } else{ v = -1; }
\r
842 x1 = x1 - kage.kWidth * Math.cos(rad) * v * kage.kKakato;
\r
843 y1 = y1 - kage.kWidth * Math.sin(rad) * v * kage.kKakato;
\r
848 if(y2 < y3){ y3 = y3 + kage.kWidth; } else{ y3 = y3 - kage.kWidth; }
\r
851 if(x2 < x3){ x3 = x3 + kage.kWidth; } else{ x3 = x3 - kage.kWidth; }
\r
854 rad = Math.atan((y3 - y2) / (x3 - x2));
\r
855 if(x2 < x3){ v = 1; } else{ v = -1; }
\r
856 x3 = x3 + kage.kWidth * Math.cos(rad) * v;
\r
857 y3 = y3 + kage.kWidth * Math.sin(rad) * v;
\r
864 y3 = y3 + kage.kWidth * kage.kKakato;
\r
867 y3 = y3 - kage.kWidth * kage.kKakato;
\r
872 x3 = x3 + kage.kWidth * kage.kKakato;
\r
875 x3 = x3 - kage.kWidth * kage.kKakato;
\r
879 rad = Math.atan((y3 - y2) / (x3 - x2));
\r
880 if(x2 < x3){ v = 1; } else{ v = -1; }
\r
881 x3 = x3 + kage.kWidth * Math.cos(rad) * v * kage.kKakato;
\r
882 y3 = y3 + kage.kWidth * Math.sin(rad) * v * kage.kKakato;
\r
886 poly = new Polygon();
\r
887 poly2 = new Polygon();
\r
889 for(tt = 0; tt <= 1000; tt = tt + kage.kRate){
\r
892 //calculating each point
\r
893 x = ((1.0 - t) * (1.0 - t) * x1 + 2.0 * t * (1.0 - t) * x2 + t * t * x3);
\r
894 y = ((1.0 - t) * (1.0 - t) * y1 + 2.0 * t * (1.0 - t) * y2 + t * t * y3);
\r
896 //SESSEN NO KATAMUKI NO KEISAN(BIBUN)
\r
897 ix = (x1 - 2.0 * x2 + x3) * 2.0 * t + (-2.0 * x1 + 2.0 * x2);
\r
898 iy = (y1 - 2.0 * y2 + y3) * 2.0 * t + (-2.0 * y1 + 2.0 * y2);
\r
900 //SESSEN NI SUICHOKU NA CHOKUSEN NO KEISAN
\r
901 if(kage.kShotai == kage.kMincho){ //always false ?
\r
902 if(ix != 0 && iy != 0){
\r
903 ir = Math.atan(iy / ix * -1.0);
\r
904 ia = Math.sin(ir) * kage.kMinWidthT;
\r
905 ib = Math.cos(ir) * kage.kMinWidthT;
\r
908 ia = kage.kMinWidthT;
\r
913 ib = kage.kMinWidthT;
\r
915 ia = ia * Math.sqrt(1.0 - t);
\r
916 ib = ib * Math.sqrt(1.0 - t);
\r
919 if(ix != 0 && iy != 0){
\r
920 ir = Math.atan(iy / ix * -1.0);
\r
921 ia = Math.sin(ir) * kage.kWidth;
\r
922 ib = Math.cos(ir) * kage.kWidth;
\r
934 //reverse if vector is going 2nd/3rd quadrants
\r
941 poly.push(x - ia, y - ib);
\r
942 poly2.push(x + ia, y + ib);
\r
946 poly.concat(poly2);
\r
947 polygons.push(poly);
\r
951 function cdDrawLine(kage, polygons, tx1, ty1, tx2, ty2, ta1, ta2){
\r
953 var v, x1, y1, x2, y2;
\r
955 var XX, XY, YX, YY;
\r
958 if(kage.kShotai == kage.kMincho){ //mincho
\r
966 if(x1 == x2){ //if TATE stroke, use y-axis
\r
967 poly = new Polygon(4);
\r
970 poly.set(3, x1 - kage.kMinWidthT, y1 - kage.kMinWidthY / 2);
\r
971 poly.set(0, x1 + kage.kMinWidthT, y1 + kage.kMinWidthY / 2);
\r
974 case 6: //... no need
\r
976 poly.set(3, x1 - kage.kMinWidthT, y1);
\r
977 poly.set(0, x1 + kage.kMinWidthT, y1);
\r
980 poly.set(3, x1 - kage.kMinWidthT, y1 - kage.kMinWidthY - kage.kMinWidthT);
\r
981 poly.set(0, x1 + kage.kMinWidthT, y1 - kage.kMinWidthY);
\r
984 poly.set(3, x1 - kage.kMinWidthT, y1 - kage.kMinWidthY);
\r
985 poly.set(0, x1 + kage.kMinWidthT, y1 - kage.kMinWidthY);
\r
991 if(a1 == 6){ //KAGI's tail ... no need
\r
992 poly.set(2, x2 - kage.kMinWidthT, y2);
\r
993 poly.set(1, x2 + kage.kMinWidthT, y2);
\r
996 poly.set(2, x2 - kage.kMinWidthT, y2 + kage.kMinWidthT / 2);
\r
997 poly.set(1, x2 + kage.kMinWidthT, y2 - kage.kMinWidthT / 2);
\r
1001 poly.set(2, x2 - kage.kMinWidthT, y2);
\r
1002 poly.set(1, x2 + kage.kMinWidthT, y2);
\r
1005 poly.set(2, x2 - kage.kMinWidthT, y2 + kage.kWidth * kage.kKakato + kage.kMinWidthT);
\r
1006 poly.set(1, x2 + kage.kMinWidthT, y2 + kage.kWidth * kage.kKakato);
\r
1009 poly.set(2, x2 - kage.kMinWidthT, y2 + kage.kWidth * kage.kKakato * 0.5 + kage.kMinWidthT);
\r
1010 poly.set(1, x2 + kage.kMinWidthT, y2 + kage.kWidth * kage.kKakato * 0.5);
\r
1013 poly.set(2, x2 - kage.kMinWidthT, y2 + kage.kMinWidthY);
\r
1014 poly.set(1, x2 + kage.kMinWidthT, y2 + kage.kMinWidthY);
\r
1018 polygons.push(poly);
\r
1020 if(a1 == 22){ //box's right top corner
\r
1021 poly = new Polygon();
\r
1022 poly.push(x1 - kage.kMinWidthT, y1 - kage.kMinWidthY);
\r
1023 poly.push(x1, y1 - kage.kMinWidthY - kage.kWidth);
\r
1024 poly.push(x1 + kage.kMinWidthT + kage.kWidth, y1 + kage.kMinWidthY);
\r
1025 poly.push(x1 + kage.kMinWidthT, y1 + kage.kMinWidthT);
\r
1026 poly.push(x1 - kage.kMinWidthT, y1);
\r
1027 polygons.push(poly);
\r
1030 if(a1 == 0){ //beginning of the stroke
\r
1031 poly = new Polygon();
\r
1032 poly.push(x1 + kage.kMinWidthT, y1 + kage.kMinWidthY * 0.5);
\r
1033 poly.push(x1 + kage.kMinWidthT + kage.kMinWidthT * 0.5, y1 + kage.kMinWidthY * 0.5 + kage.kMinWidthY);
\r
1034 poly.push(x1 + kage.kMinWidthT, y1 + kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2);
\r
1035 polygons.push(poly);
\r
1038 if((a1 == 6 && a2 == 0) || a2 == 1){ //KAGI NO YOKO BOU NO SAIGO NO MARU ... no need only used at 1st=yoko
\r
1039 poly = new Polygon();
\r
1040 poly.push(x2 - kage.kMinWidthT, y2);
\r
1041 poly.push(x2 - kage.kMinWidthT * 0.6, y2 + kage.kMinWidthT * 0.6);
\r
1042 poly.push(x2, y2 + kage.kMinWidthT);
\r
1043 poly.push(x2 + kage.kMinWidthT * 0.6, y2 + kage.kMinWidthT * 0.6);
\r
1044 poly.push(x2 + kage.kMinWidthT, y2);
\r
1045 poly.reverse(); // for fill-rule
\r
1046 polygons.push(poly);
\r
1049 else if(y1 == y2){ //if it is YOKO stroke, use x-axis
\r
1050 if(a1 == 6){ //if it is KAGI's YOKO stroke, get bold
\r
1051 poly = new Polygon();
\r
1052 poly.push(x1, y1 - kage.kMinWidthT);
\r
1053 poly.push(x2, y2 - kage.kMinWidthT);
\r
1054 poly.push(x2, y2 + kage.kMinWidthT);
\r
1055 poly.push(x1, y1 + kage.kMinWidthT);
\r
1056 polygons.push(poly);
\r
1058 if(a2 == 1 || a2 == 0 || a2 == 5){ // no need a2=1
\r
1059 //KAGI NO YOKO BOU NO SAIGO NO MARU
\r
1060 poly = new Polygon();
\r
1061 poly.push(x2, y2 - kage.kMinWidthT);
\r
1062 poly.push(x2 + kage.kMinWidthT * 0.6, y2 - kage.kMinWidthT * 0.6);
\r
1063 poly.push(x2 + kage.kMinWidthT, y2);
\r
1064 poly.push(x2 + kage.kMinWidthT * 0.6, y2 + kage.kMinWidthT * 0.6);
\r
1065 poly.push(x2, y2 + kage.kMinWidthT);
\r
1066 polygons.push(poly);
\r
1070 //KAGI NO YOKO BOU NO HANE
\r
1071 poly = new Polygon();
\r
1072 poly.push(x2, y2 - kage.kMinWidthT + 1);
\r
1073 poly.push(x2 + 2, y2 - kage.kMinWidthT - kage.kWidth * 5);
\r
1074 poly.push(x2, y2 - kage.kMinWidthT - kage.kWidth * 5);
\r
1075 poly.push(x2 - kage.kMinWidthT, y2 - kage.kMinWidthT + 1);
\r
1076 poly.reverse(); // for fill-rule
\r
1077 polygons.push(poly);
\r
1081 poly = new Polygon(4);
\r
1084 poly.set(0, x1, y1 - kage.kMinWidthY);
\r
1085 poly.set(3, x1, y1 + kage.kMinWidthY);
\r
1088 poly.set(0, x1 - kage.kMinWidthT, y1 - kage.kMinWidthY);
\r
1089 poly.set(3, x1 - kage.kMinWidthT, y1 + kage.kMinWidthY);
\r
1095 poly.set(1, x2, y2 - kage.kMinWidthY);
\r
1096 poly.set(2, x2, y2 + kage.kMinWidthY);
\r
1099 poly.set(1, x2 + kage.kMinWidthT, y2 - kage.kMinWidthY);
\r
1100 poly.set(2, x2 + kage.kMinWidthT, y2 + kage.kMinWidthY);
\r
1103 polygons.push(poly);
\r
1107 poly = new Polygon();
\r
1108 poly.push(x2, y2 - kage.kMinWidthY);
\r
1109 poly.push(x2 - 24, y2);
\r
1110 poly.push(x2 - 12, y2 - 12);
\r
1111 polygons.push(poly);
\r
1115 else{ //for others, use x-axis
\r
1116 rad = Math.atan((y2 - y1) / (x2 - x1));
\r
1117 if((Math.abs(y2 - y1) < Math.abs(x2 - x1)) && (a1 != 6) && (a2 != 6) && !(x1 > x2)){ //ASAI KAUDO
\r
1118 poly = new Polygon(4);
\r
1119 switch(a1){ //must be 0 or 2
\r
1121 poly.set(0, x1 + Math.sin(rad) * kage.kMinWidthY, y1 - Math.cos(rad) * kage.kMinWidthY);
\r
1122 poly.set(3, x1 - Math.sin(rad) * kage.kMinWidthY, y1 + Math.cos(rad) * kage.kMinWidthY);
\r
1125 poly.set(0, 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
1127 poly.set(3, x1 - Math.sin(rad) * kage.kMinWidthY - kage.kMinWidthT * Math.cos(rad),
\r
1128 y1 + Math.cos(rad) * kage.kMinWidthY - kage.kMinWidthT * Math.sin(rad));
\r
1132 switch(a2){ //must be 0 or 2
\r
1134 poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthY, y2 - Math.cos(rad) * kage.kMinWidthY);
\r
1135 poly.set(2, x2 - Math.sin(rad) * kage.kMinWidthY, y2 + Math.cos(rad) * kage.kMinWidthY);
\r
1138 poly.set(1, 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
1140 poly.set(2, x2 - Math.sin(rad) * kage.kMinWidthY + kage.kMinWidthT * Math.cos(rad),
\r
1141 y2 + Math.cos(rad) * kage.kMinWidthY + kage.kMinWidthT * Math.sin(rad));
\r
1144 polygons.push(poly);
\r
1148 poly = new Polygon();
\r
1149 poly.push(x2 + Math.sin(rad) * kage.kMinWidthY, y2 - Math.cos(rad) * kage.kMinWidthY);
\r
1150 poly.push(x2 - Math.cos(rad) * 24, y2 - Math.sin(rad) * 24);
\r
1151 poly.push(x2 - Math.cos(rad) * 12 + Math.sin(rad) * 12, y2 - Math.sin(rad) * 12 - Math.cos(rad) * 12);
\r
1152 polygons.push(poly);
\r
1156 else{ //KAKUDO GA FUKAI or KAGI NO YOKO BOU
\r
1157 if(x1 > x2){ v = -1; } else{ v = 1; }
\r
1158 poly = new Polygon(4);
\r
1161 poly.set(0, 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
1163 poly.set(3, x1 - Math.sin(rad) * kage.kMinWidthT * v - kage.kMinWidthY * Math.cos(rad) * 0.5 * v,
\r
1164 y1 + Math.cos(rad) * kage.kMinWidthT * v - kage.kMinWidthY * Math.sin(rad) * 0.5 * v);
\r
1169 poly.set(0, x1 + Math.sin(rad) * kage.kMinWidthT * v, y1 - Math.cos(rad) * kage.kMinWidthT * v);
\r
1170 poly.set(3, x1 - Math.sin(rad) * kage.kMinWidthT * v, y1 + Math.cos(rad) * kage.kMinWidthT * v);
\r
1173 poly.set(0, x1 + Math.sin(rad) * kage.kMinWidthT * v - kage.kMinWidthY * Math.cos(rad) * v,
\r
1174 y1 - Math.cos(rad) * kage.kMinWidthT * v - kage.kMinWidthY * Math.sin(rad) * v);
\r
1175 poly.set(3, x1 - Math.sin(rad) * kage.kMinWidthT * v - (kage.kMinWidthT + kage.kMinWidthY) * Math.cos(rad) * v,
\r
1176 y1 + Math.cos(rad) * kage.kMinWidthT * v - (kage.kMinWidthT + kage.kMinWidthY) * Math.sin(rad) * v);
\r
1179 poly.set(0, 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
1181 poly.set(3, x1 - Math.sin(rad) * kage.kMinWidthT * v - kage.kMinWidthY * Math.cos(rad) * v,
\r
1182 y1 + Math.cos(rad) * kage.kMinWidthT * v - kage.kMinWidthY * Math.sin(rad) * v);
\r
1189 poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthT * v, y2 - Math.cos(rad) * kage.kMinWidthT * v);
\r
1190 poly.set(2, x2 - Math.sin(rad) * kage.kMinWidthT * v, y2 + Math.cos(rad) * kage.kMinWidthT * v);
\r
1193 poly.set(1, 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
1195 poly.set(2, x2 - Math.sin(rad) * kage.kMinWidthT * v + kage.kMinWidthT * 0.5 * Math.cos(rad) * v,
\r
1196 y2 + Math.cos(rad) * kage.kMinWidthT * v + kage.kMinWidthT * 0.5 * Math.sin(rad) * v);
\r
1199 case 1: // is needed?
\r
1201 poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthT * v, y2 - Math.cos(rad) * kage.kMinWidthT * v);
\r
1202 poly.set(2, x2 - Math.sin(rad) * kage.kMinWidthT * v, y2 + Math.cos(rad) * kage.kMinWidthT * v);
\r
1205 poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthT * v + kage.kWidth * kage.kKakato * Math.cos(rad) * v,
\r
1206 y2 - Math.cos(rad) * kage.kMinWidthT * v + kage.kWidth * kage.kKakato * Math.sin(rad) * v);
\r
1207 poly.set(2, x2 - Math.sin(rad) * kage.kMinWidthT * v + (kage.kWidth * kage.kKakato + kage.kMinWidthT) * Math.cos(rad) * v,
\r
1208 y2 + Math.cos(rad) * kage.kMinWidthT * v + (kage.kWidth * kage.kKakato + kage.kMinWidthT) * Math.sin(rad) * v);
\r
1211 poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthT * v + kage.kWidth * kage.kKakato * 0.5 * Math.cos(rad) * v,
\r
1212 y2 - Math.cos(rad) * kage.kMinWidthT * v + kage.kWidth * kage.kKakato * 0.5 * Math.sin(rad) * v);
\r
1214 x2 - Math.sin(rad) * kage.kMinWidthT * v + (kage.kWidth * kage.kKakato * 0.5 + kage.kMinWidthT) * Math.cos(rad) * v,
\r
1215 y2 + Math.cos(rad) * kage.kMinWidthT * v + (kage.kWidth * kage.kKakato * 0.5 + kage.kMinWidthT) * Math.sin(rad) * v);
\r
1218 poly.set(1, 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
1220 poly.set(2, x2 - Math.sin(rad) * kage.kMinWidthT * v + kage.kMinWidthY * Math.cos(rad) * v,
\r
1221 y2 + Math.cos(rad) * kage.kMinWidthT * v + kage.kMinWidthY * Math.sin(rad) * v);
\r
1225 polygons.push(poly);
\r
1227 if((a1 == 6) && (a2 == 0 || a2 == 5)){ //KAGI NO YOKO BOU NO SAIGO NO MARU
\r
1228 poly = new Polygon();
\r
1229 poly.push(x2 + Math.sin(rad) * kage.kMinWidthT * v, y2 - Math.cos(rad) * kage.kMinWidthT * v);
\r
1230 poly.push(x2 + Math.cos(rad) * kage.kMinWidthT * 0.8 * v + Math.sin(rad) * kage.kMinWidthT * 0.6 * v,
\r
1231 y2 + Math.sin(rad) * kage.kMinWidthT * 0.8 * v - Math.cos(rad) * kage.kMinWidthT * 0.6 * v);
\r
1232 poly.push(x2 + Math.cos(rad) * kage.kMinWidthT * v, y2 + Math.sin(rad) * kage.kMinWidthT * v);
\r
1233 poly.push(x2 + Math.cos(rad) * kage.kMinWidthT * 0.8 * v - Math.sin(rad) * kage.kMinWidthT * 0.6 * v,
\r
1234 y2 + Math.sin(rad) * kage.kMinWidthT * 0.8 * v + Math.cos(rad) * kage.kMinWidthT * 0.6 * v);
\r
1235 poly.push(x2 - Math.sin(rad) * kage.kMinWidthT * v, y2 + Math.cos(rad) * kage.kMinWidthT * v);
\r
1236 polygons.push(poly);
\r
1239 if(a1 == 6 && a2 == 5){
\r
1240 //KAGI NO YOKO BOU NO HANE
\r
1241 poly = new Polygon();
\r
1242 poly.push(x2 + (kage.kMinWidthT - 1) * Math.sin(rad) * v, y2 - (kage.kMinWidthT - 1) * Math.cos(rad) * v);
\r
1243 poly.push(x2 + 2 * Math.cos(rad) * v + (kage.kMinWidthT + kage.kWidth * 5) * Math.sin(rad) * v,
\r
1244 y2 + 2 * Math.sin(rad) * v - (kage.kMinWidthT + kage.kWidth * 5) * Math.cos(rad) * v);
\r
1245 poly.push(x2 + (kage.kMinWidthT + kage.kWidth * 5) * Math.sin(rad) * v,
\r
1246 y2 - (kage.kMinWidthT + kage.kWidth * 5) * Math.cos(rad) * v);
\r
1247 poly.push(x2 + (kage.kMinWidthT - 1) * Math.sin(rad) * v - kage.kMinWidthT * Math.cos(rad) * v,
\r
1248 y2 - (kage.kMinWidthT - 1) * Math.cos(rad) * v - kage.kMinWidthT * Math.sin(rad) * v);
\r
1249 polygons.push(poly);
\r
1252 if(a1 == 22){ //SHIKAKU MIGIUE UROKO NANAME DEMO MASSUGU MUKI
\r
1253 poly = new Polygon();
\r
1254 poly.push(x1 - kage.kMinWidthT, y1 - kage.kMinWidthY);
\r
1255 poly.push(x1, y1 - kage.kMinWidthY - kage.kWidth);
\r
1256 poly.push(x1 + kage.kMinWidthT + kage.kWidth, y1 + kage.kMinWidthY);
\r
1257 poly.push(x1 + kage.kMinWidthT, y1 + kage.kMinWidthT);
\r
1258 poly.push(x1 - kage.kMinWidthT, y1);
\r
1259 polygons.push(poly);
\r
1262 XX = Math.sin(rad) * v;
\r
1263 XY = Math.cos(rad) * v * -1;
\r
1264 YX = Math.cos(rad) * v;
\r
1265 YY = Math.sin(rad) * v;
\r
1267 if(a1 == 0){ //beginning of the storke
\r
1268 poly = new Polygon();
\r
1269 poly.push(x1 + kage.kMinWidthT * XX + (kage.kMinWidthY * 0.5) * YX,
\r
1270 y1 + kage.kMinWidthT * XY + (kage.kMinWidthY * 0.5) * YY);
\r
1271 poly.push(x1 + (kage.kMinWidthT + kage.kMinWidthT * 0.5) * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY) * YX,
\r
1272 y1 + (kage.kMinWidthT + kage.kMinWidthT * 0.5) * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY) * YY);
\r
1273 poly.push(x1 + kage.kMinWidthT * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YX,
\r
1274 y1 + kage.kMinWidthT * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YY);
\r
1275 polygons.push(poly);
\r
1281 if(tx1 == tx2){ //if TATE stroke, use y-axis
\r
1299 if(a1 % 10 == 2){ y1 = y1 - kage.kWidth; }
\r
1300 if(a2 % 10 == 2){ y2 = y2 + kage.kWidth; }
\r
1301 if(a1 % 10 == 3){ y1 = y1 - kage.kWidth * kage.kKakato; }
\r
1302 if(a2 % 10 == 3){ y2 = y2 + kage.kWidth * kage.kKakato; }
\r
1304 poly = new Polygon();
\r
1305 poly.push(x1 - kage.kWidth, y1);
\r
1306 poly.push(x2 - kage.kWidth, y2);
\r
1307 poly.push(x2 + kage.kWidth, y2);
\r
1308 poly.push(x1 + kage.kWidth, y1);
\r
1309 poly.reverse(); // for fill-rule
\r
1311 polygons.push(poly);
\r
1313 else if(ty1 == ty2){ //if YOKO stroke, use x-axis
\r
1330 if(a1 % 10 == 2){ x1 = x1 - kage.kWidth; }
\r
1331 if(a2 % 10 == 2){ x2 = x2 + kage.kWidth; }
\r
1332 if(a1 % 10 == 3){ x1 = x1 - kage.kWidth * kage.kKakato; }
\r
1333 if(a2 % 10 == 3){ x2 = x2 + kage.kWidth * kage.kKakato; }
\r
1335 poly = new Polygon();
\r
1336 poly.push(x1, y1 - kage.kWidth);
\r
1337 poly.push(x2, y2 - kage.kWidth);
\r
1338 poly.push(x2, y2 + kage.kWidth);
\r
1339 poly.push(x1, y1 + kage.kWidth);
\r
1341 polygons.push(poly);
\r
1343 else{ //for others, use x-axis
\r
1360 rad = Math.atan((y2 - y1) / (x2 - x1));
\r
1362 x1 = x1 - kage.kWidth * Math.cos(rad);
\r
1363 y1 = y1 - kage.kWidth * Math.sin(rad);
\r
1366 x2 = x2 + kage.kWidth * Math.cos(rad);
\r
1367 y2 = y2 + kage.kWidth * Math.sin(rad);
\r
1370 x1 = x1 - kage.kWidth * Math.cos(rad) * kage.kKakato;
\r
1371 y1 = y1 - kage.kWidth * Math.sin(rad) * kage.kKakato;
\r
1374 x2 = x2 + kage.kWidth * Math.cos(rad) * kage.kKakato;
\r
1375 y2 = y2 + kage.kWidth * Math.sin(rad) * kage.kKakato;
\r
1378 //SUICHOKU NO ICHI ZURASHI HA Math.sin TO Math.cos NO IREKAE + x-axis MAINASU KA
\r
1379 poly = new Polygon();
\r
1380 poly.push(x1 + Math.sin(rad) * kage.kWidth, y1 - Math.cos(rad) * kage.kWidth);
\r
1381 poly.push(x2 + Math.sin(rad) * kage.kWidth, y2 - Math.cos(rad) * kage.kWidth);
\r
1382 poly.push(x2 - Math.sin(rad) * kage.kWidth, y2 + Math.cos(rad) * kage.kWidth);
\r
1383 poly.push(x1 - Math.sin(rad) * kage.kWidth, y1 + Math.cos(rad) * kage.kWidth);
\r
1385 polygons.push(poly);
\r