--- /dev/null
+function cdDrawBezier(kage, polygons, x1, y1, x2, y2, x3, y3, x4, y4, a1, a2){\r
+ var rad, t;\r
+ var x, y, v;\r
+ var ix, iy, ia, ib, ir;\r
+ var tt;\r
+ var delta;\r
+ var deltad;\r
+ var XX, XY, YX, YY;\r
+ var poly, poly2;\r
+ \r
+ if(kage.kShotai == kage.kMincho){ // mincho\r
+ switch(a1){\r
+ case 0:\r
+ case 7:\r
+ delta = -1 * kage.kMinWidthY * 0.5;\r
+ break;\r
+ case 1:\r
+ case 2:\r
+ case 6:\r
+ case 22:\r
+ delta = 0;\r
+ break;\r
+ case 12:\r
+ case 32:\r
+ delta = kage.kMinWidthY;\r
+ break;\r
+ default:\r
+ break;\r
+ }\r
+ \r
+ if(x1 == x2){\r
+ if(y1 < y2){ y1 = y1 - delta; }\r
+ else{ y1 = y1 + delta; }\r
+ }\r
+ else if(y1 == y2){\r
+ if(x1 < x2){ x1 = x1 - delta; }\r
+ else{ x1 = x1 + delta; }\r
+ }\r
+ else{\r
+ rad = Math.atan((y2 - y1) / (x2 - x1));\r
+ if(x1 < x2){ v = 1; } else{ v = -1; }\r
+ x1 = x1 - delta * Math.cos(rad) * v;\r
+ y1 = y1 - delta * Math.sin(rad) * v;\r
+ }\r
+ \r
+ switch(a2){\r
+ case 0:\r
+ case 1:\r
+ case 8:\r
+ case 7:\r
+ case 9:\r
+ case 15:\r
+ case 14:\r
+ case 17:\r
+ case 5:\r
+ delta = 0;\r
+ break;\r
+ default:\r
+ break;\r
+ }\r
+ \r
+ if(x3 == x4){\r
+ if(y3 < y4){ y4 = y4 + delta; }\r
+ else{ y4 = y4 - delta; }\r
+ }\r
+ else if(y3 == y4){\r
+ if(x3 < x4){ x4 = x4 + delta; }\r
+ else{ x4 = x4 - delta; }\r
+ }\r
+ else{\r
+ rad = Math.atan((y4 - y3) / (x4 - x3));\r
+ if(x3 < x4){ v = 1; } else{ v = -1; }\r
+ x4 = x4 + delta * Math.cos(rad) * v;\r
+ y4 = y4 + delta * Math.sin(rad) * v;\r
+ }\r
+ \r
+ poly = new Polygon();\r
+ poly2 = new Polygon();\r
+ for(tt = 0; tt <= 1000; tt = tt + kage.kRate){\r
+ t = (tt) / 1000;\r
+ \r
+ //calculate a dot\r
+ 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
+ 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
+ //KATAMUKI of vector by BIBUN\r
+ ix = t * t * (-3 * x1 + 9 * x2 + -9 * x3 + 3 * x4) + t * (6 * x1 + -12 * x2 + 6 * x3) + -3 * x1 + 3 * x2;\r
+ iy = t * t * (-3 * y1 + 9 * y2 + -9 * y3 + 3 * y4) + t * (6 * y1 + -12 * y2 + 6 * y3) + -3 * y1 + 3 * y2;\r
+ \r
+ //line SUICHOKU by vector\r
+ if(ix != 0 && iy != 0){\r
+ ir = Math.atan(iy / ix * -1);\r
+ ia = Math.sin(ir) * (kage.kMinWidthT);\r
+ ib = Math.cos(ir) * (kage.kMinWidthT);\r
+ }\r
+ else if(ix == 0){\r
+ ia = kage.kMinWidthT;\r
+ ib = 0;\r
+ }\r
+ else{\r
+ ia = 0;\r
+ ib = kage.kMinWidthT;\r
+ }\r
+ \r
+ if(a1 == 7){ deltad = Math.sqrt(t); }\r
+ else if(a2 == 7){ deltad = Math.sqrt(1.0 - t); }\r
+ else{ deltad = 1; }\r
+ ia = ia * deltad;\r
+ ib = ib * deltad;\r
+ \r
+ //reverse if vector is going 2nd/3rd quadrants\r
+ if(ix <= 0){\r
+ ia = ia * -1;\r
+ ib = ib * -1;\r
+ }\r
+ \r
+ //copy to polygon structuer\r
+ poly.push(x - ia, y - ib);\r
+ poly2.push(x + ia, y + ib);\r
+ }\r
+ poly2.reverse();\r
+ poly.concat(poly2);\r
+ polygons.push(poly);\r
+ \r
+ //process for head of stroke\r
+ rad = Math.atan((y2 - y1) / (x2 - x1));\r
+ if(x1 < x2){ v = 1; } else{ v = -1; }\r
+ XX = Math.sin(rad) * v;\r
+ XY = Math.cos(rad) * v * -1;\r
+ YX = Math.cos(rad) * v;\r
+ YY = Math.sin(rad) * v;\r
+ \r
+ if(a1 == 12){\r
+ if(x1 == x2){\r
+ poly = new Polygon();\r
+ poly.push(x1 - kage.kMinWidthT, y1);\r
+ poly.push(x1 + kage.kMinWidthT, y1);\r
+ poly.push(x1 - kage.kMinWidthT, y1 - kage.kMinWidthT);\r
+ polygons.push(poly);\r
+ }\r
+ else{\r
+ poly = new Polygon();\r
+ poly.push(x1 - kage.kMinWidthT * XX, y1 - kage.kMinWidthT * XY);\r
+ poly.push(x1 + kage.kMinWidthT * XX, y1 + kage.kMinWidthT * XY);\r
+ poly.push(x1 - kage.kMinWidthT * XX - kage.kMinWidthT * YX, y1 - kage.kMinWidthT * XY - kage.kMinWidthT * YY);\r
+ polygons.push(poly);\r
+ }\r
+ }\r
+ \r
+ if(a1 == 0){\r
+ if(y1 <= y4){ //from up to bottom\r
+ if(x1 == x2){\r
+ poly = new Polygon();\r
+ poly.push(x1 - kage.kMinWidthT, y1);\r
+ poly.push(x1 + kage.kMinWidthT, y1);\r
+ poly.push(x1 - kage.kMinWidthT, y1 - kage.kMinWidthY);\r
+ polygons.push(poly);\r
+ }\r
+ else{\r
+ poly = new Polygon();\r
+ poly.push(x1 - kage.kMinWidthT * XX, y1 - kage.kMinWidthT * XY);\r
+ poly.push(x1 + kage.kMinWidthT * XX, y1 + kage.kMinWidthT * XY);\r
+ poly.push(x1 - kage.kMinWidthT * XX - kage.kMinWidthY * YX, y1 - kage.kMinWidthT * XY - kage.kMinWidthY * YY);\r
+ polygons.push(poly);\r
+ }\r
+ }\r
+ else{ //bottom to up\r
+ if(x1 == x2){ //is it right?\r
+ poly = new Polygon();\r
+ poly.push(x1 - kage.kMinWidthT, y1);\r
+ poly.push(x1 + kage.kMinWidthT, y1);\r
+ poly.push(x1 - kage.kMinWidthT, y1 + kage.kMinWidthY);\r
+ polygons.push(poly);\r
+ }\r
+ else{\r
+ poly = new Polygon();\r
+ poly.push(x1 - kage.kMinWidthT * XX, y1 - kage.kMinWidthT * XY);\r
+ poly.push(x1 + kage.kMinWidthT * XX, y1 + kage.kMinWidthT * XY);\r
+ poly.push(x1 + kage.kMinWidthT * XX - kage.kMinWidthY * YX, y1 + kage.kMinWidthT * XY - kage.kMinWidthY * YY);\r
+ polygons.push(poly);\r
+ }\r
+ }\r
+ }\r
+ \r
+ if(a1 == 22){ //box's up-right corner, any time same degree\r
+ poly = new Polygon();\r
+ poly.push(x1 - kage.kMinWidthT, y1 - kage.kMinWidthY);\r
+ poly.push(x1, y1 - kage.kMinWidthY - kage.kWidth);\r
+ poly.push(x1 + kage.kMinWidthT + kage.kWidth, y1 + kage.kMinWidthY);\r
+ poly.push(x1 + kage.kMinWidthT, y1 + kage.kMinWidthT);\r
+ poly.push(x1 - kage.kMinWidthT, y1);\r
+ polygons.push(poly);\r
+ }\r
+ \r
+ if(a1 == 0){ //beginning of the stroke\r
+ if(y1 <= y4){ //from up to bottom\r
+ if(x1 == x2){\r
+ poly = new Polygon();\r
+ poly.push(x1 + kage.kMinWidthT, y1 + kage.kMinWidthY * 0.5);\r
+ poly.push(x1 + kage.kMinWidthT + kage.kMinWidthT * 0.5, y1 + kage.kMinWidthY * 0.5 + kage.kMinWidthY);\r
+ poly.push(x1 + kage.kMinWidthT, y1 + kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2);\r
+ polygons.push(poly);\r
+ }\r
+ else{\r
+ poly = new Polygon();\r
+ poly.push(x1 + kage.kMinWidthT * XX + (kage.kMinWidthY * 0.5) * YX,\r
+ y1 + kage.kMinWidthT * XY + (kage.kMinWidthY * 0.5) * YY);\r
+ poly.push(x1 + (kage.kMinWidthT + kage.kMinWidthT * 0.5) * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY) * YX,\r
+ y1 + (kage.kMinWidthT + kage.kMinWidthT * 0.5) * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY) * YY);\r
+ poly.push(x1 + kage.kMinWidthT * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YX,\r
+ y1 + kage.kMinWidthT * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YY);\r
+ polygons.push(poly);\r
+ }\r
+ }\r
+ else{ //from bottom to up\r
+ if(x1 == x2){ //is it right?\r
+ poly = new Polygon();\r
+ poly.push(x1 + kage.kMinWidthT, y1 - kage.kMinWidthY * 0.5);\r
+ poly.push(x1 + kage.kMinWidthT + kage.kMinWidthT * 0.5, y1 - kage.kMinWidthY * 0.5 - kage.kMinWidthY);\r
+ poly.push(x1 + kage.kMinWidthT, y1 - kage.kMinWidthY * 0.5 - kage.kMinWidthY * 2);\r
+ polygons.push(poly);\r
+ }\r
+ else{ //SETSUGOUMEN GA KAKERUNODE HOKYOU\r
+ poly = new Polygon();\r
+ poly.push(x1 - (kage.kMinWidthT - 1) * XX + (kage.kMinWidthY * 0.5) * YX,\r
+ y1 - (kage.kMinWidthT - 1) * XY + (kage.kMinWidthY * 0.5) * YY);\r
+ poly.push(x1 - (kage.kMinWidthT - 0) * XX + (kage.kMinWidthY * 0.5) * YX,\r
+ y1 - (kage.kMinWidthT - 0) * XY + (kage.kMinWidthY * 0.5) * YY);\r
+ poly.push(x1 - (kage.kMinWidthT + kage.kMinWidthT * 0.5) * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY) * YX,\r
+ y1 - (kage.kMinWidthT + kage.kMinWidthT * 0.5) * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY) * YY);\r
+ poly.push(x1 - (kage.kMinWidthT - 0) * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YX,\r
+ y1 - (kage.kMinWidthT - 0) * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YY);\r
+ poly.push(x1 - (kage.kMinWidthT - 1) * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YX,\r
+ y1 - (kage.kMinWidthT - 1) * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YY);\r
+ polygons.push(poly);\r
+ }\r
+ }\r
+ }\r
+ \r
+ //process for tail\r
+ rad = Math.atan((y4 - y3) / (x4 - x3));\r
+ if(x3 < x4){ v = 1; } else{ v = -1; }\r
+ YX = Math.sin(rad) * v * -1;\r
+ YY = Math.cos(rad) * v;\r
+ XX = Math.cos(rad) * v;\r
+ XY = Math.sin(rad) * v;\r
+ \r
+ if(a2 == 1 || a2 == 8 || a2 == 15){ //the last filled circle\r
+ if(x3 == x4){\r
+ poly = Polygon();\r
+ poly.push(x4 - kage.kMinWidthT, y4);\r
+ poly.push(x4 - kage.kMinWidthT * 0.6, y4 + kage.kMinWidthT * 0.6);\r
+ poly.push(x4, y4 + kage.kMinWidthT);\r
+ poly.push(x4 + kage.kMinWidthT * 0.6, y4 + kage.kMinWidthT * 0.6);\r
+ poly.push(x4 + kage.kMinWidthT, y4);\r
+ polygons.push(poly);\r
+ }\r
+ else if(y3 == y4){\r
+ poly = new Polygon();\r
+ poly.push(x4, y4 - kage.kMinWidthT);\r
+ poly.push(x4 + kage.kMinWidthT * 0.6, y4 - kage.kMinWidthT * 0.6);\r
+ poly.push(x4 + kage.kMinWidthT, y4);\r
+ poly.push(x4 + kage.kMinWidthT * 0.6, y4 + kage.kMinWidthT * 0.6);\r
+ poly.push(x4, y4 + kage.kMinWidthT);\r
+ polygons.push(poly);\r
+ }\r
+ else{\r
+ poly = new Polygon();\r
+ poly.push(x4 + Math.sin(rad) * kage.kMinWidthT * v, y4 - Math.cos(rad) * kage.kMinWidthT * v);\r
+ poly.push(x4 + Math.cos(rad) * kage.kMinWidthT * 0.8 * v + Math.sin(rad) * kage.kMinWidthT * 0.6 * v,\r
+ y4 + Math.sin(rad) * kage.kMinWidthT * 0.8 * v - Math.cos(rad) * kage.kMinWidthT * 0.6 * v);\r
+ poly.push(x4 + Math.cos(rad) * kage.kMinWidthT * v, y4 + Math.sin(rad) * kage.kMinWidthT * v);\r
+ poly.push(x4 + Math.cos(rad) * kage.kMinWidthT * 0.8 * v - Math.sin(rad) * kage.kMinWidthT * 0.6 * v,\r
+ y4 + Math.sin(rad) * kage.kMinWidthT * 0.8 * v + Math.cos(rad) * kage.kMinWidthT * 0.6 * v);\r
+ poly.push(x4 - Math.sin(rad) * kage.kMinWidthT * v, y4 + Math.cos(rad) * kage.kMinWidthT * v);\r
+ polygons.push(poly);\r
+ }\r
+ }\r
+ \r
+ if(a2 == 9 || (a1 == 7 && a2 == 0)){ // Math.sinnyu & L2RD Harai\r
+ if(y3 == y4){\r
+ poly = new Polygon();\r
+ poly.push(x4, y4 + kage.kMinWidthT);\r
+ poly.push(x4, y4 - kage.kMinWidthT);\r
+ poly.push(x4 + kage.kMinWidthT, y4 - kage.kMinWidthT);\r
+ polygons.push(poly);\r
+ }\r
+ else{\r
+ poly = new Polygon();\r
+ poly.push(x4 + kage.kMinWidthT * YX, y4 + kage.kMinWidthT * YY);\r
+ poly.push(x4 - kage.kMinWidthT * YX, y4 - kage.kMinWidthT * YY);\r
+ poly.push(x4 + kage.kMinWidthT * XX - kage.kMinWidthT * YX, y4 + kage.kMinWidthT * XY - kage.kMinWidthT * YY);\r
+ polygons.push(poly);\r
+ }\r
+ }\r
+ \r
+ if(a2 == 15){ //jump up\r
+ if(y3 == y4){\r
+ poly = new Polygon();\r
+ poly.push(x4, y4 - kage.kMinWidthT + 1);\r
+ poly.push(x4 + 2, y4 - kage.kMinWidthT - kage.kWidth * 5);\r
+ poly.push(x4, y4 - kage.kMinWidthT - kage.kWidth * 5);\r
+ poly.push(x4 - kage.kMinWidthT, y4 - kage.kMinWidthT + 1);\r
+ polygons.push(poly);\r
+ }\r
+ else{\r
+ poly = new Polygon();\r
+ poly.push(x4 + (kage.kMinWidthT - 1) * Math.sin(rad) * v, y4 - (kage.kMinWidthT - 1) * Math.cos(rad) * v);\r
+ poly.push(x4 + 2 * Math.cos(rad) * v + (kage.kMinWidthT + kage.kWidth * 5) * Math.sin(rad) * v,\r
+ y4 + 2 * Math.sin(rad) * v - (kage.kMinWidthT + kage.kWidth * 5) * Math.cos(rad) * v);\r
+ poly.push(x4 + (kage.kMinWidthT + kage.kWidth * 5) * Math.sin(rad) * v,\r
+ y4 - (kage.kMinWidthT + kage.kWidth * 5) * Math.cos(rad) * v);\r
+ poly.push(x4 + (kage.kMinWidthT - 1) * Math.sin(rad) * v - kage.kMinWidthT * Math.cos(rad) * v,\r
+ y4 - (kage.kMinWidthT - 1) * Math.cos(rad) * v - kage.kMinWidthT * Math.sin(rad) * v);\r
+ polygons.push(poly);\r
+ }\r
+ }\r
+ \r
+ if(a2 == 14){ //jump to left, allways go left\r
+ poly = new Polygon();\r
+ poly.push(x4, y4);\r
+ poly.push(x4, y4 - kage.kMinWidthT);\r
+ poly.push(x4 - kage.kWidth * 4, y4 - kage.kMinWidthT);\r
+ poly.push(x4 - kage.kWidth * 4, y4 - kage.kMinWidthT * 0.5);\r
+ polygons.push(poly);\r
+ }\r
+ }\r
+ else{ //gothic\r
+ if(a1 % 10 == 2){\r
+ if(x1 == x2){\r
+ if(y1 < y2){ y1 = y1 - kage.kWidth; } else{ y1 = y1 + kage.kWidth; }\r
+ }\r
+ else if(y1 == y2){\r
+ if(x1 < x2){ x1 = x1 - kage.kWidth; } else{ x1 = x1 + kage.kWidth; }\r
+ }\r
+ else{\r
+ rad = Math.atan((y2 - y1) / (x2 - x1));\r
+ if(x1 < x2){ v = 1; } else{ v = -1; }\r
+ x1 = x1 - kage.kWidth * Math.cos(rad) * v;\r
+ y1 = y1 - kage.kWidth * Math.sin(rad) * v;\r
+ }\r
+ }\r
+ \r
+ if(a1 % 10 == 3){\r
+ if(x1 == x2){\r
+ if(y1 < y2){\r
+ y1 = y1 - kage.kWidth * kage.kKakato;\r
+ }\r
+ else{\r
+ y1 = y1 + kage.kWidth * kage.kKakato;\r
+ }\r
+ }\r
+ else if(y1 == y2){\r
+ if(x1 < x2){\r
+ x1 = x1 - kage.kWidth * kage.kKakato;\r
+ }\r
+ else{\r
+ x1 = x1 + kage.kWidth * kage.kKakato;\r
+ }\r
+ }\r
+ else{\r
+ rad = Math.atan((y2 - y1) / (x2 - x1));\r
+ if(x1 < x2){ v = 1; } else{ v = -1; }\r
+ x1 = x1 - kage.kWidth * Math.cos(rad) * v * kage.kKakato;\r
+ y1 = y1 - kage.kWidth * Math.sin(rad) * v * kage.kKakato;\r
+ }\r
+ }\r
+ if(a2 % 10 == 2){\r
+ if(x3 == x4){\r
+ if(y3 < y4){ y4 = y4 + kage.kWidth; } else{ y4 = y4 - kage.kWidth; }\r
+ }\r
+ else if(y3 == y4){\r
+ if(x3 < x4){ x4 = x4 + kage.kWidth; } else{ x4 = x4 - kage.kWidth; }\r
+ }\r
+ else{\r
+ rad = Math.atan((y4 - y3) / (x4 - x3));\r
+ if(x3 < x4){ v = 1; } else{ v = -1; }\r
+ x4 = x4 + kage.kWidth * Math.cos(rad) * v;\r
+ y4 = y4 + kage.kWidth * Math.sin(rad) * v;\r
+ }\r
+ }\r
+ \r
+ if(a2 % 10 == 3){\r
+ if(x3 == x4){\r
+ if(y3 < y4){\r
+ y4 = y4 + kage.kWidth * kage.kKakato;\r
+ }\r
+ else{\r
+ y4 = y4 - kage.kWidth * kage.kKakato;\r
+ }\r
+ }\r
+ else if(y3 == y4){\r
+ if(x3 < x4){\r
+ x4 = x4 + kage.kWidth * kage.kKakato;\r
+ }\r
+ else{\r
+ x4 = x4 - kage.kWidth * kage.kKakato;\r
+ }\r
+ }\r
+ else{\r
+ rad = Math.atan((y4 - y3) / (x4 - x3));\r
+ if(x3 < x4){ v = 1; } else{ v = -1; }\r
+ x4 = x4 + kage.kWidth * Math.cos(rad) * v * kage.kKakato;\r
+ y4 = y4 + kage.kWidth * Math.sin(rad) * v * kage.kKakato;\r
+ }\r
+ }\r
+ \r
+ poly = new Polygon();\r
+ poly2= new Polygon();\r
+ \r
+ for(tt = 0; tt <= 1000; tt = tt + kage.kRate){\r
+ t = tt / 1000;\r
+ \r
+ //calculate a dot\r
+ 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
+ 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
+ //KATAMUKI of vector by BIBUN\r
+ ix = t * t * (-3 * x1 + 9 * x2 + -9 * x3 + 3 * x4) + t * (6 * x1 + -12 * x2 + 6 * x3) + -3 * x1 + 3 * x2;\r
+ iy = t * t * (-3 * y1 + 9 * y2 + -9 * y3 + 3 * y4) + t * (6 * y1 + -12 * y2 + 6 * y3) + -3 * y1 + 3 * y2;\r
+ \r
+ //SESSEN NI SUICHOKU NA CHOKUSEN NO KEISAN\r
+ if(kage.kShotai == kage.kMincho){ //always false ?\r
+ if(ix != 0 && iy != 0){\r
+ ir = Math.atan(iy / ix * -1.0);\r
+ ia = Math.sin(ir) * kage.kMinWidthT;\r
+ ib = Math.cos(ir) * kage.kMinWidthT;\r
+ }\r
+ else if(ix == 0){\r
+ ia = kage.kMinWidthT;\r
+ ib = 0;\r
+ }\r
+ else{\r
+ ia = 0;\r
+ ib = kage.kMinWidthT;\r
+ }\r
+ ia = ia * Math.sqrt(1.0 - t);\r
+ ib = ib * Math.sqrt(1.0 - t);\r
+ }\r
+ else{\r
+ if(ix != 0 && iy != 0){\r
+ ir = Math.atan(iy / ix * -1.0);\r
+ ia = Math.sin(ir) * kage.kWidth;\r
+ ib = Math.cos(ir) * kage.kWidth;\r
+ }\r
+ else if(ix == 0){\r
+ ia = kage.kWidth;\r
+ ib = 0;\r
+ }\r
+ else{\r
+ ia = 0;\r
+ ib = kage.kWidth;\r
+ }\r
+ }\r
+ \r
+ //reverse if vector is going 2nd/3rd quadrants\r
+ if(ix <= 0){\r
+ ia = ia * -1;\r
+ ib = ib * -1;\r
+ }\r
+ \r
+ //save to polygon\r
+ poly.push(x - ia, y - ib);\r
+ poly2.push(x + ia, y + ib);\r
+ }\r
+ \r
+ poly2.reverse();\r
+ poly.concat(poly2);\r
+ polygons.push(poly);\r
+ }\r
+}\r
+\r
+function cdDrawCurve(kage, polygons, x1, y1, x2, y2, x3, y3, a1, a2){\r
+ var rad, t;\r
+ var x, y, v;\r
+ var ix, iy, ia, ib, ir;\r
+ var tt;\r
+ var delta;\r
+ var deltad;\r
+ var XX, XY, YX, YY;\r
+ var poly, poly2;\r
+ \r
+ if(kage.kShotai == kage.kMincho){ // mincho\r
+ switch(a1){\r
+ case 0:\r
+ case 7:\r
+ delta = -1 * kage.kMinWidthY * 0.5;\r
+ break;\r
+ case 1:\r
+ case 2:\r
+ case 6:\r
+ case 22:\r
+ delta = 0;\r
+ break;\r
+ case 12:\r
+ case 32:\r
+ delta = kage.kMinWidthY;\r
+ break;\r
+ default:\r
+ break;\r
+ }\r
+ \r
+ if(x1 == x2){\r
+ if(y1 < y2){ y1 = y1 - delta; }\r
+ else{ y1 = y1 + delta; }\r
+ }\r
+ else if(y1 == y2){\r
+ if(x1 < x2){ x1 = x1 - delta; }\r
+ else{ x1 = x1 + delta; }\r
+ }\r
+ else{\r
+ rad = Math.atan((y2 - y1) / (x2 - x1));\r
+ if(x1 < x2){ v = 1; } else{ v = -1; }\r
+ x1 = x1 - delta * Math.cos(rad) * v;\r
+ y1 = y1 - delta * Math.sin(rad) * v;\r
+ }\r
+ \r
+ switch(a2){\r
+ case 0:\r
+ case 1:\r
+ case 7:\r
+ case 9:\r
+ case 15:\r
+ case 14:\r
+ case 17:\r
+ case 5:\r
+ delta = 0;\r
+ break;\r
+ case 8: // get shorten for tail's circle\r
+ delta = -1 * kage.kMinWidthT * 0.5;\r
+ break;\r
+ default:\r
+ break;\r
+ }\r
+ \r
+ if(x2 == x3){\r
+ if(y2 < y3){ y3 = y3 + delta; }\r
+ else{ y3 = y3 - delta; }\r
+ }\r
+ else if(y2 == y3){\r
+ if(x2 < x3){ x3 = x3 + delta; }\r
+ else{ x3 = x3 - delta; }\r
+ }\r
+ else{\r
+ rad = Math.atan((y3 - y2) / (x3 - x2));\r
+ if(x2 < x3){ v = 1; } else{ v = -1; }\r
+ x3 = x3 + delta * Math.cos(rad) * v;\r
+ y3 = y3 + delta * Math.sin(rad) * v;\r
+ }\r
+ \r
+ poly = new Polygon();\r
+ poly2 = new Polygon();\r
+ \r
+ for(tt = 0; tt <= 1000; tt = tt + kage.kRate){\r
+ t = tt / 1000;\r
+ \r
+ //calculate a dot\r
+ x = ((1.0 - t) * (1.0 - t) * x1 + 2.0 * t * (1.0 - t) * x2 + t * t * x3);\r
+ y = ((1.0 - t) * (1.0 - t) * y1 + 2.0 * t * (1.0 - t) * y2 + t * t * y3);\r
+ \r
+ //KATAMUKI of vector by BIBUN\r
+ ix = (x1 - 2.0 * x2 + x3) * 2.0 * t + (-2.0 * x1 + 2.0 * x2);\r
+ iy = (y1 - 2.0 * y2 + y3) * 2.0 * t + (-2.0 * y1 + 2.0 * y2);\r
+ \r
+ //line SUICHOKU by vector\r
+ if(ix != 0 && iy != 0){\r
+ ir = Math.atan(iy / ix * -1);\r
+ ia = Math.sin(ir) * (kage.kMinWidthT);\r
+ ib = Math.cos(ir) * (kage.kMinWidthT);\r
+ }\r
+ else if(ix == 0){\r
+ ia = kage.kMinWidthT;\r
+ ib = 0;\r
+ }\r
+ else{\r
+ ia = 0;\r
+ ib = kage.kMinWidthT;\r
+ }\r
+ \r
+ if(a1 == 7 && a2 == 0){ deltad = Math.sqrt(t) * kage.kL2RDfatten; } //L2RD: fatten\r
+ else if(a1 == 7){ deltad = Math.sqrt(t); }\r
+ else if(a2 == 7){ deltad = Math.sqrt(1.0 - t); }\r
+ else{ deltad = 1; }\r
+ ia = ia * deltad;\r
+ ib = ib * deltad;\r
+ \r
+ //reverse if vector is going 2nd/3rd quadrants\r
+ if(ix <= 0){\r
+ ia = ia * -1;\r
+ ib = ib * -1;\r
+ }\r
+ \r
+ //copy to polygon structure\r
+ poly.push(x - ia, y - ib);\r
+ poly2.push(x + ia, y + ib);\r
+ }\r
+ \r
+ poly2.reverse();\r
+ poly.concat(poly2);\r
+ polygons.push(poly);\r
+ \r
+ //process for head of stroke\r
+ rad = Math.atan((y2 - y1) / (x2 - x1));\r
+ if(x1 < x2){ v = 1; } else{ v = -1; }\r
+ XX = Math.sin(rad) * v;\r
+ XY = Math.cos(rad) * v * -1;\r
+ YX = Math.cos(rad) * v;\r
+ YY = Math.sin(rad) * v;\r
+ \r
+ if(a1 == 12){\r
+ if(x1 == x2){\r
+ poly= new Polygon();\r
+ poly.push(x1 - kage.kMinWidthT, y1);\r
+ poly.push(x1 + kage.kMinWidthT, y1);\r
+ poly.push(x1 - kage.kMinWidthT, y1 - kage.kMinWidthT);\r
+ polygons.push(poly);\r
+ }\r
+ else{\r
+ poly = new Polygon();\r
+ poly.push(x1 - kage.kMinWidthT * XX, y1 - kage.kMinWidthT * XY);\r
+ poly.push(x1 + kage.kMinWidthT * XX, y1 + kage.kMinWidthT * XY);\r
+ poly.push(x1 - kage.kMinWidthT * XX - kage.kMinWidthT * YX, y1 - kage.kMinWidthT * XY - kage.kMinWidthT * YY);\r
+ polygons.push(poly);\r
+ }\r
+ }\r
+ \r
+ if(a1 == 0){\r
+ if(y1 <= y3){ //from up to bottom\r
+ if(x1 == x2){\r
+ poly = new Polygon();\r
+ poly.push(x1 - kage.kMinWidthT, y1);\r
+ poly.push(x1 + kage.kMinWidthT, y1);\r
+ poly.push(x1 - kage.kMinWidthT, y1 - kage.kMinWidthY);\r
+ polygons.push(poly);\r
+ }\r
+ else{\r
+ poly = new Polygon();\r
+ poly.push(x1 - kage.kMinWidthT * XX, y1 - kage.kMinWidthT * XY);\r
+ poly.push(x1 + kage.kMinWidthT * XX, y1 + kage.kMinWidthT * XY);\r
+ poly.push(x1 - kage.kMinWidthT * XX - kage.kMinWidthY * YX, y1 - kage.kMinWidthT * XY - kage.kMinWidthY * YY);\r
+ polygons.push(poly);\r
+ }\r
+ }\r
+ else{ //bottom to up\r
+ if(x1 == x2){ //is it right?\r
+ poly = new Polygon();\r
+ poly.push(x1 - kage.kMinWidthT, y1);\r
+ poly.push(x1 + kage.kMinWidthT, y1);\r
+ poly.push(x1 - kage.kMinWidthT, y1 + kage.kMinWidthY);\r
+ polygons.push(poly);\r
+ }\r
+ else{\r
+ poly = new Polygon();\r
+ poly.push(x1 - kage.kMinWidthT * XX, y1 - kage.kMinWidthT * XY);\r
+ poly.push(x1 + kage.kMinWidthT * XX, y1 + kage.kMinWidthT * XY);\r
+ poly.push(x1 + kage.kMinWidthT * XX - kage.kMinWidthY * YX, y1 + kage.kMinWidthT * XY - kage.kMinWidthY * YY);\r
+ polygons.push(poly);\r
+ }\r
+ }\r
+ }\r
+ \r
+ if(a1 == 22){ //box's up-right corner, any time same degree\r
+ poly = new Polygon();\r
+ poly.push(x1 - kage.kMinWidthT, y1 - kage.kMinWidthY);\r
+ poly.push(x1, y1 - kage.kMinWidthY - kage.kWidth);\r
+ poly.push(x1 + kage.kMinWidthT + kage.kWidth, y1 + kage.kMinWidthY);\r
+ poly.push(x1 + kage.kMinWidthT, y1 + kage.kMinWidthT);\r
+ poly.push(x1 - kage.kMinWidthT, y1);\r
+ polygons.push(poly);\r
+ }\r
+ \r
+ if(a1 == 0){ //beginning of the stroke\r
+ if(y1 <= y3){ //from up to bottom\r
+ if(x1 == x2){\r
+ poly = new Polygon();\r
+ poly.push(x1 + kage.kMinWidthT, y1 + kage.kMinWidthY * 0.5);\r
+ poly.push(x1 + kage.kMinWidthT + kage.kMinWidthT * 0.5, y1 + kage.kMinWidthY * 0.5 + kage.kMinWidthY);\r
+ poly.push(x1 + kage.kMinWidthT, y1 + kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2);\r
+ polygons.push(poly);\r
+ }\r
+ else{\r
+ poly = new Polygon();\r
+ poly.push(x1 + kage.kMinWidthT * XX + (kage.kMinWidthY * 0.5) * YX,\r
+ y1 + kage.kMinWidthT * XY + (kage.kMinWidthY * 0.5) * YY);\r
+ poly.push(x1 + (kage.kMinWidthT + kage.kMinWidthT * 0.5) * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY) * YX,\r
+ y1 + (kage.kMinWidthT + kage.kMinWidthT * 0.5) * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY) * YY);\r
+ poly.push(x1 + kage.kMinWidthT * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YX,\r
+ y1 + kage.kMinWidthT * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YY);\r
+ polygons.push(poly);\r
+ }\r
+ }\r
+ else{ //from bottom to up\r
+ if(x1 == x2){ //is it right?\r
+ poly = new Polygon();\r
+ poly.push(x1 + kage.kMinWidthT, poly2[0].Y = y1 - kage.kMinWidthY * 0.5);\r
+ poly.push(x1 + kage.kMinWidthT + kage.kMinWidthT * 0.5, y1 - kage.kMinWidthY * 0.5 - kage.kMinWidthY);\r
+ poly.push(x1 + kage.kMinWidthT, y1 - kage.kMinWidthY * 0.5 - kage.kMinWidthY * 2);\r
+ polygons.push(poly);\r
+ }\r
+ else{ //SETSUGOUMEN GA KAKERUNODE HOKYOU\r
+ poly = new Polygon();\r
+ poly.push(x1 - (kage.kMinWidthT - 1) * XX + (kage.kMinWidthY * 0.5) * YX,\r
+ y1 - (kage.kMinWidthT - 1) * XY + (kage.kMinWidthY * 0.5) * YY);\r
+ poly.push(x1 - (kage.kMinWidthT - 0) * XX + (kage.kMinWidthY * 0.5) * YX,\r
+ y1 - (kage.kMinWidthT - 0) * XY + (kage.kMinWidthY * 0.5) * YY);\r
+ poly.push(x1 - (kage.kMinWidthT + kage.kMinWidthT * 0.5) * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY) * YX,\r
+ y1 - (kage.kMinWidthT + kage.kMinWidthT * 0.5) * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY) * YY);\r
+ poly.push(x1 - (kage.kMinWidthT - 0) * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YX,\r
+ y1 - (kage.kMinWidthT - 0) * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YY);\r
+ poly.push(x1 - (kage.kMinWidthT - 1) * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YX,\r
+ y1 - (kage.kMinWidthT - 1) * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YY);\r
+ polygons.push(poly);\r
+ }\r
+ }\r
+ }\r
+ \r
+ //process for tail\r
+ rad = Math.atan((y3 - y2) / (x3 - x2));\r
+ if(x2 < x3){ v = 1; } else{ v = -1; }\r
+ YX = Math.sin(rad) * v * -1;\r
+ YY = Math.cos(rad) * v;\r
+ XX = Math.cos(rad) * v;\r
+ XY = Math.sin(rad) * v;\r
+ \r
+ if(a2 == 1 || a2 == 8 || a2 == 15){ //the last filled circle\r
+ if(x2 == x3){\r
+ poly = new Polygon();\r
+ poly.push(x3 - kage.kMinWidthT, y3);\r
+ poly.push(x3 - kage.kMinWidthT * 0.6, y3 + kage.kMinWidthT * 0.6);\r
+ poly.push(x3, y3 + kage.kMinWidthT);\r
+ poly.push(x3 + kage.kMinWidthT * 0.6, y3 + kage.kMinWidthT * 0.6);\r
+ poly.push(x3 + kage.kMinWidthT, y3);\r
+ polygons.push(poly);\r
+ }\r
+ else if(y2 == y3){\r
+ poly = new Polygon();\r
+ poly.push(x3, y3 - kage.kMinWidthT);\r
+ poly.push(x3 + kage.kMinWidthT * 0.6, y3 - kage.kMinWidthT * 0.6);\r
+ poly.push(x3 + kage.kMinWidthT, y3);\r
+ poly.push(x3 + kage.kMinWidthT * 0.6, y3 + kage.kMinWidthT * 0.6);\r
+ poly.push(x3, y3 + kage.kMinWidthT);\r
+ polygons.push(poly);\r
+ }\r
+ else{\r
+ poly = new Polygon();\r
+ poly.push(x3 + Math.sin(rad) * kage.kMinWidthT * v, y3 - Math.cos(rad) * kage.kMinWidthT * v);\r
+ poly.push(x3 + Math.cos(rad) * kage.kMinWidthT * 0.8 * v + Math.sin(rad) * kage.kMinWidthT * 0.6 * v,\r
+ y3 + Math.sin(rad) * kage.kMinWidthT * 0.8 * v - Math.cos(rad) * kage.kMinWidthT * 0.6 * v);\r
+ poly.push(x3 + Math.cos(rad) * kage.kMinWidthT * v, y3 + Math.sin(rad) * kage.kMinWidthT * v);\r
+ poly.push(x3 + Math.cos(rad) * kage.kMinWidthT * 0.8 * v - Math.sin(rad) * kage.kMinWidthT * 0.6 * v,\r
+ y3 + Math.sin(rad) * kage.kMinWidthT * 0.8 * v + Math.cos(rad) * kage.kMinWidthT * 0.6 * v);\r
+ poly.push(x3 - Math.sin(rad) * kage.kMinWidthT * v, y3 + Math.cos(rad) * kage.kMinWidthT * v);\r
+ polygons.push(poly);\r
+ }\r
+ }\r
+ \r
+ if(a2 == 9 || (a1 == 7 && a2 == 0)){ // Math.sinnyu & L2RD Harai\r
+ if(y2 == y3){\r
+ poly = new Polygon();\r
+ poly.push(x3, y3 + kage.kMinWidthT * kage.kL2RDfatten);\r
+ poly.push(x3, y3 - kage.kMinWidthT * kage.kL2RDfatten);\r
+ poly.push(x3 + kage.kMinWidthT * kage.kL2RDfatten, y3 - kage.kMinWidthT * kage.kL2RDfatten);\r
+ polygons.push(poly);\r
+ }\r
+ else{\r
+ poly = new Polygon();\r
+ poly.push(x3 + kage.kMinWidthT * kage.kL2RDfatten * YX, y3 + kage.kMinWidthT * kage.kL2RDfatten * YY);\r
+ poly.push(x3 - kage.kMinWidthT * kage.kL2RDfatten * YX, y3 - kage.kMinWidthT * kage.kL2RDfatten * YY);\r
+ poly.push(x3 + kage.kMinWidthT * kage.kL2RDfatten * XX - kage.kMinWidthT * kage.kL2RDfatten * YX,\r
+ y3 + kage.kMinWidthT * kage.kL2RDfatten * XY - kage.kMinWidthT * kage.kL2RDfatten * YY);\r
+ polygons.push(poly);\r
+ }\r
+ }\r
+ \r
+ if(a2 == 15){ //jump up\r
+ if(y2 == y3){\r
+ poly = new Polygon();\r
+ poly.push(x3, y3 - kage.kMinWidthT + 1);\r
+ poly.push(x3 + 2, y3 - kage.kMinWidthT - kage.kWidth * 5);\r
+ poly.push(x3, y3 - kage.kMinWidthT - kage.kWidth * 5);\r
+ poly.push(x3 - kage.kMinWidthT, y3 - kage.kMinWidthT + 1);\r
+ polygons.push(poly);\r
+ }\r
+ else{\r
+ poly = new Polygon();\r
+ poly.push(x3 + (kage.kMinWidthT - 1) * Math.sin(rad) * v, y3 - (kage.kMinWidthT - 1) * Math.cos(rad) * v);\r
+ poly.push(x3 + 2 * Math.cos(rad) * v + (kage.kMinWidthT + kage.kWidth * 5) * Math.sin(rad) * v,\r
+ y3 + 2 * Math.sin(rad) * v - (kage.kMinWidthT + kage.kWidth * 5) * Math.cos(rad) * v);\r
+ poly.push(x3 + (kage.kMinWidthT + kage.kWidth * 5) * Math.sin(rad) * v,\r
+ y3 - (kage.kMinWidthT + kage.kWidth * 5) * Math.cos(rad) * v);\r
+ poly.push(x3 + (kage.kMinWidthT - 1) * Math.sin(rad) * v - kage.kMinWidthT * Math.cos(rad) * v,\r
+ y3 - (kage.kMinWidthT - 1) * Math.cos(rad) * v - kage.kMinWidthT * Math.sin(rad) * v);\r
+ polygons.push(poly);\r
+ }\r
+ }\r
+ \r
+ if(a2 == 14){ //jump to left, allways go left\r
+ poly = new Polygon();\r
+ poly.push(x3, y3);\r
+ poly.push(x3, y3 - kage.kMinWidthT);\r
+ poly.push(x3 - kage.kWidth * 4, y3 - kage.kMinWidthT);\r
+ poly.push(x3 - kage.kWidth * 4, y3 - kage.kMinWidthT * 0.5);\r
+ polygons.push(poly);\r
+ }\r
+ }\r
+ else{ //gothic\r
+ if(a1 % 10 == 2){\r
+ if(x1 == x2){\r
+ if(y1 < y2){ y1 = y1 - kage.kWidth; } else{ y1 = y1 + kage.kWidth; }\r
+ }\r
+ else if(y1 == y2){\r
+ if(x1 < x2){ x1 = x1 - kage.kWidth; } else{ x1 = x1 + kage.kWidth; }\r
+ }\r
+ else{\r
+ rad = Math.atan((y2 - y1) / (x2 - x1));\r
+ if(x1 < x2){ v = 1; } else{ v = -1; }\r
+ x1 = x1 - kage.kWidth * Math.cos(rad) * v;\r
+ y1 = y1 - kage.kWidth * Math.sin(rad) * v;\r
+ }\r
+ }\r
+ \r
+ if(a1 % 10 == 3){\r
+ if(x1 == x2){\r
+ if(y1 < y2){\r
+ y1 = y1 - kage.kWidth * kage.kKakato;\r
+ }\r
+ else{\r
+ y1 = y1 + kage.kWidth * kage.kKakato;\r
+ }\r
+ }\r
+ else if(y1 == y2){\r
+ if(x1 < x2){\r
+ x1 = x1 - kage.kWidth * kage.kKakato;\r
+ }\r
+ else{\r
+ x1 = x1 + kage.kWidth * kage.kKakato;\r
+ }\r
+ }\r
+ else{\r
+ rad = Math.atan((y2 - y1) / (x2 - x1));\r
+ if(x1 < x2){ v = 1; } else{ v = -1; }\r
+ x1 = x1 - kage.kWidth * Math.cos(rad) * v * kage.kKakato;\r
+ y1 = y1 - kage.kWidth * Math.sin(rad) * v * kage.kKakato;\r
+ }\r
+ }\r
+ if(a2 % 10 == 2){\r
+ if(x2 == x3){\r
+ if(y2 < y3){ y3 = y3 + kage.kWidth; } else{ y3 = y3 - kage.kWidth; }\r
+ }\r
+ else if(y2 == y3){\r
+ if(x2 < x3){ x3 = x3 + kage.kWidth; } else{ x3 = x3 - kage.kWidth; }\r
+ }\r
+ else{\r
+ rad = Math.atan((y3 - y2) / (x3 - x2));\r
+ if(x2 < x3){ v = 1; } else{ v = -1; }\r
+ x3 = x3 + kage.kWidth * Math.cos(rad) * v;\r
+ y3 = y3 + kage.kWidth * Math.sin(rad) * v;\r
+ }\r
+ }\r
+ \r
+ if(a2 % 10 == 3){\r
+ if(x2 == x3){\r
+ if(y2 < y3){\r
+ y3 = y3 + kage.kWidth * kage.kKakato;\r
+ }\r
+ else{\r
+ y3 = y3 - kage.kWidth * kage.kKakato;\r
+ }\r
+ }\r
+ else if(y2 == y3){\r
+ if(x2 < x3){\r
+ x3 = x3 + kage.kWidth * kage.kKakato;\r
+ }\r
+ else{\r
+ x3 = x3 - kage.kWidth * kage.kKakato;\r
+ }\r
+ }\r
+ else{\r
+ rad = Math.atan((y3 - y2) / (x3 - x2));\r
+ if(x2 < x3){ v = 1; } else{ v = -1; }\r
+ x3 = x3 + kage.kWidth * Math.cos(rad) * v * kage.kKakato;\r
+ y3 = y3 + kage.kWidth * Math.sin(rad) * v * kage.kKakato;\r
+ }\r
+ }\r
+ \r
+ poly = new Polygon();\r
+ poly2 = new Polygon();\r
+ \r
+ for(tt = 0; tt <= 1000; tt = tt + kage.kRate){\r
+ t = tt / 1000;\r
+ \r
+ //calculating each point\r
+ x = ((1.0 - t) * (1.0 - t) * x1 + 2.0 * t * (1.0 - t) * x2 + t * t * x3);\r
+ y = ((1.0 - t) * (1.0 - t) * y1 + 2.0 * t * (1.0 - t) * y2 + t * t * y3);\r
+ \r
+ //SESSEN NO KATAMUKI NO KEISAN(BIBUN)\r
+ ix = (x1 - 2.0 * x2 + x3) * 2.0 * t + (-2.0 * x1 + 2.0 * x2);\r
+ iy = (y1 - 2.0 * y2 + y3) * 2.0 * t + (-2.0 * y1 + 2.0 * y2);\r
+ \r
+ //SESSEN NI SUICHOKU NA CHOKUSEN NO KEISAN\r
+ if(kage.kShotai == kage.kMincho){ //always false ?\r
+ if(ix != 0 && iy != 0){\r
+ ir = Math.atan(iy / ix * -1.0);\r
+ ia = Math.sin(ir) * kage.kMinWidthT;\r
+ ib = Math.cos(ir) * kage.kMinWidthT;\r
+ }\r
+ else if(ix == 0){\r
+ ia = kage.kMinWidthT;\r
+ ib = 0;\r
+ }\r
+ else{\r
+ ia = 0;\r
+ ib = kage.kMinWidthT;\r
+ }\r
+ ia = ia * Math.sqrt(1.0 - t);\r
+ ib = ib * Math.sqrt(1.0 - t);\r
+ }\r
+ else{\r
+ if(ix != 0 && iy != 0){\r
+ ir = Math.atan(iy / ix * -1.0);\r
+ ia = Math.sin(ir) * kage.kWidth;\r
+ ib = Math.cos(ir) * kage.kWidth;\r
+ }\r
+ else if(ix == 0){\r
+ ia = kage.kWidth;\r
+ ib = 0;\r
+ }\r
+ else{\r
+ ia = 0;\r
+ ib = kage.kWidth;\r
+ }\r
+ }\r
+ \r
+ //reverse if vector is going 2nd/3rd quadrants\r
+ if(ix <= 0){\r
+ ia = ia * -1;\r
+ ib = ib * -1;\r
+ }\r
+ \r
+ //save to polygon\r
+ poly.push(x - ia, y - ib);\r
+ poly2.push(x + ia, y + ib);\r
+ }\r
+ \r
+ poly2.reverse();\r
+ poly.concat(poly2);\r
+ polygons.push(poly);\r
+ }\r
+}\r
+\r
+function cdDrawLine(kage, polygons, tx1, ty1, tx2, ty2, ta1, ta2){\r
+ var rad;\r
+ var v, x1, y1, x2, y2;\r
+ var a1, a2;\r
+ var XX, XY, YX, YY;\r
+ var poly;\r
+ \r
+ if(kage.kShotai == kage.kMincho){ //mincho\r
+ x1 = tx1;\r
+ y1 = ty1;\r
+ x2 = tx2;\r
+ y2 = ty2;\r
+ a1 = ta1;\r
+ a2 = ta2;\r
+ \r
+ if(x1 == x2){ //if TATE stroke, use y-axis\r
+ poly = new Polygon(4);\r
+ switch(a1){\r
+ case 0:\r
+ poly.set(3, x1 - kage.kMinWidthT, y1 - kage.kMinWidthY / 2);\r
+ poly.set(0, x1 + kage.kMinWidthT, y1 + kage.kMinWidthY / 2);\r
+ break;\r
+ case 1:\r
+ case 6:\r
+ case 22:\r
+ poly.set(3, x1 - kage.kMinWidthT, y1);\r
+ poly.set(0, x1 + kage.kMinWidthT, y1);\r
+ break;\r
+ case 12:\r
+ poly.set(3, x1 - kage.kMinWidthT, y1 - kage.kMinWidthY - kage.kMinWidthT);\r
+ poly.set(0, x1 + kage.kMinWidthT, y1 - kage.kMinWidthY);\r
+ break;\r
+ case 32:\r
+ poly.set(3, x1 - kage.kMinWidthT, y1 - kage.kMinWidthY);\r
+ poly.set(0, x1 + kage.kMinWidthT, y1 - kage.kMinWidthY);\r
+ break;\r
+ }\r
+ \r
+ switch(a2){\r
+ case 0:\r
+ if(a1 == 6){ //KAGI's tail\r
+ poly.set(2, x2 - kage.kMinWidthT, y2);\r
+ poly.set(1, x2 + kage.kMinWidthT, y2);\r
+ }\r
+ else{\r
+ poly.set(2, x2 - kage.kMinWidthT, y2 + kage.kMinWidthT / 2);\r
+ poly.set(1, x2 + kage.kMinWidthT, y2 - kage.kMinWidthT / 2);\r
+ }\r
+ break;\r
+ case 1:\r
+ poly.set(2, x2 - kage.kMinWidthT, y2);\r
+ poly.set(1, x2 + kage.kMinWidthT, y2);\r
+ break;\r
+ case 13:\r
+ poly.set(2, x2 - kage.kMinWidthT, y2 + kage.kWidth * kage.kKakato + kage.kMinWidthT);\r
+ poly.set(1, x2 + kage.kMinWidthT, y2 + kage.kWidth * kage.kKakato);\r
+ break;\r
+ case 23:\r
+ poly.set(2, x2 - kage.kMinWidthT, y2 + kage.kWidth * kage.kKakato * 0.5 + kage.kMinWidthT);\r
+ poly.set(1, x2 + kage.kMinWidthT, y2 + kage.kWidth * kage.kKakato * 0.5);\r
+ break;\r
+ case 32:\r
+ poly.set(2, x2 - kage.kMinWidthT, y2 + kage.kMinWidthY);\r
+ poly.set(1, x2 + kage.kMinWidthT, y2 + kage.kMinWidthY);\r
+ break;\r
+ }\r
+ \r
+ polygons.push(poly);\r
+ \r
+ if(a1 == 22){ //box's right top corner\r
+ poly = new Polygon();\r
+ poly.push(x1 - kage.kMinWidthT, y1 - kage.kMinWidthY);\r
+ poly.push(x1, y1 - kage.kMinWidthY - kage.kWidth);\r
+ poly.push(x1 + kage.kMinWidthT + kage.kWidth, y1 + kage.kMinWidthY);\r
+ poly.push(x1 + kage.kMinWidthT, y1 + kage.kMinWidthT);\r
+ poly.push(x1 - kage.kMinWidthT, y1);\r
+ polygons.push(poly);\r
+ }\r
+ \r
+ if(a1 == 0){ //beginning of the stroke\r
+ poly = new Polygon();\r
+ poly.push(x1 + kage.kMinWidthT, y1 + kage.kMinWidthY * 0.5);\r
+ poly.push(x1 + kage.kMinWidthT + kage.kMinWidthT * 0.5, y1 + kage.kMinWidthY * 0.5 + kage.kMinWidthY);\r
+ poly.push(x1 + kage.kMinWidthT, y1 + kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2);\r
+ polygons.push(poly);\r
+ }\r
+ \r
+ if((a1 == 6 && a2 == 0) || a2 == 1){ //KAGI NO YOKO BOU NO SAIGO NO MARU\r
+ poly = new Polygon();\r
+ poly.push(x2 - kage.kMinWidthT, y2);\r
+ poly.push(x2 - kage.kMinWidthT * 0.6, y2 + kage.kMinWidthT * 0.6);\r
+ poly.push(x2, y2 + kage.kMinWidthT);\r
+ poly.push(x2 + kage.kMinWidthT * 0.6, y2 + kage.kMinWidthT * 0.6);\r
+ poly.push(x2 + kage.kMinWidthT, y2);\r
+ poly.reverse(); // for fill-rule\r
+ polygons.push(poly);\r
+ }\r
+ }\r
+ else if(y1 == y2){ //if it is YOKO stroke, use x-axis\r
+ if(a1 == 6){ //if it is KAGI's YOKO stroke, get bold\r
+ poly = new Polygon();\r
+ poly.push(x1, y1 - kage.kMinWidthT);\r
+ poly.push(x2, y2 - kage.kMinWidthT);\r
+ poly.push(x2, y2 + kage.kMinWidthT);\r
+ poly.push(x1, y1 + kage.kMinWidthT);\r
+ polygons.push(poly);\r
+ \r
+ if(a2 == 1 || a2 == 0 || a2 == 5){\r
+ //KAGI NO YOKO BOU NO SAIGO NO MARU\r
+ poly = new Polygon();\r
+ poly.push(x2, y2 - kage.kMinWidthT);\r
+ poly.push(x2 + kage.kMinWidthT * 0.6, y2 - kage.kMinWidthT * 0.6);\r
+ poly.push(x2 + kage.kMinWidthT, y2);\r
+ poly.push(x2 + kage.kMinWidthT * 0.6, y2 + kage.kMinWidthT * 0.6);\r
+ poly.push(x2, y2 + kage.kMinWidthT);\r
+ polygons.push(poly);\r
+ }\r
+ \r
+ if(a2 == 5){\r
+ //KAGI NO YOKO BOU NO HANE\r
+ poly = new Polygon();\r
+ poly.push(x2, y2 - kage.kMinWidthT + 1);\r
+ poly.push(x2 + 2, y2 - kage.kMinWidthT - kage.kWidth * 5);\r
+ poly.push(x2, y2 - kage.kMinWidthT - kage.kWidth * 5);\r
+ poly.push(x2 - kage.kMinWidthT, y2 - kage.kMinWidthT + 1);\r
+ poly.reverse(); // for fill-rule\r
+ polygons.push(poly);\r
+ }\r
+ }\r
+ else{\r
+ poly = new Polygon(4);\r
+ switch(a1){\r
+ case 0:\r
+ poly.set(0, x1, y1 - kage.kMinWidthY);\r
+ poly.set(3, x1, y1 + kage.kMinWidthY);\r
+ break;\r
+ case 2:\r
+ poly.set(0, x1 - kage.kMinWidthT, y1 - kage.kMinWidthY);\r
+ poly.set(3, x1 - kage.kMinWidthT, y1 + kage.kMinWidthY);\r
+ break;\r
+ }\r
+ \r
+ switch(a2){\r
+ case 0:\r
+ poly.set(1, x2, y2 - kage.kMinWidthY);\r
+ poly.set(2, x2, y2 + kage.kMinWidthY);\r
+ break;\r
+ case 2:\r
+ poly.set(1, x2 + kage.kMinWidthT, y2 - kage.kMinWidthY);\r
+ poly.set(2, x2 + kage.kMinWidthT, y2 + kage.kMinWidthY);\r
+ }\r
+ \r
+ polygons.push(poly);\r
+ \r
+ //UROKO\r
+ if(a2 == 0){\r
+ poly = new Polygon();\r
+ poly.push(x2, y2 - kage.kMinWidthY);\r
+ poly.push(x2 - 24, y2);\r
+ poly.push(x2 - 12, y2 - 12);\r
+ polygons.push(poly);\r
+ }\r
+ }\r
+ }\r
+ else{ //for others, use x-axis\r
+ rad = Math.atan((y2 - y1) / (x2 - x1));\r
+ if((Math.abs(y2 - y1) < Math.abs(x2 - x1)) && (a1 != 6) && (a2 != 6)){ //ASAI KAUDO\r
+ poly = new Polygon(4);\r
+ switch(a1){ //must be 0 or 2\r
+ case 0:\r
+ poly.set(0, x1 + Math.sin(rad) * kage.kMinWidthY, y1 - Math.cos(rad) * kage.kMinWidthY);\r
+ poly.set(3, x1 - Math.sin(rad) * kage.kMinWidthY, y1 + Math.cos(rad) * kage.kMinWidthY);\r
+ break;\r
+ case 2:\r
+ poly.set(0, x1 + Math.sin(rad) * kage.kMinWidthY - kage.kMinWidthT * Math.cos(rad),\r
+ y1 - Math.cos(rad) * kage.kMinWidthY - kage.kMinWidthT * Math.sin(rad));\r
+ poly.set(3, x1 - Math.sin(rad) * kage.kMinWidthY - kage.kMinWidthT * Math.cos(rad),\r
+ y1 + Math.cos(rad) * kage.kMinWidthY - kage.kMinWidthT * Math.sin(rad));\r
+ break;\r
+ }\r
+ \r
+ switch(a2){ //must be 0 or 2\r
+ case 0:\r
+ poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthY, y2 - Math.cos(rad) * kage.kMinWidthY);\r
+ poly.set(2, x2 - Math.sin(rad) * kage.kMinWidthY, y2 + Math.cos(rad) * kage.kMinWidthY);\r
+ break;\r
+ case 2:\r
+ poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthY + kage.kMinWidthT * Math.cos(rad),\r
+ y2 - Math.cos(rad) * kage.kMinWidthY + kage.kMinWidthT * Math.sin(rad));\r
+ poly.set(2, x2 - Math.sin(rad) * kage.kMinWidthY + kage.kMinWidthT * Math.cos(rad),\r
+ y2 + Math.cos(rad) * kage.kMinWidthY + kage.kMinWidthT * Math.sin(rad));\r
+ }\r
+ \r
+ polygons.push(poly);\r
+ \r
+ //UROKO\r
+ if(a2 == 0){\r
+ poly = new Polygon();\r
+ poly.push(x2 + Math.sin(rad) * kage.kMinWidthY, y2 - Math.cos(rad) * kage.kMinWidthY);\r
+ poly.push(x2 - Math.cos(rad) * 24, y2 - Math.sin(rad) * 24);\r
+ poly.push(x2 - Math.cos(rad) * 12 + Math.sin(rad) * 12, y2 - Math.sin(rad) * 12 - Math.cos(rad) * 12);\r
+ polygons.push(poly);\r
+ }\r
+ }\r
+ \r
+ else{ //KAKUDO GA FUKAI or KAGI NO YOKO BOU\r
+ if(x1 > x2){ v = -1; } else{ v = 1; }\r
+ poly = new Polygon(4);\r
+ switch(a1){\r
+ case 0:\r
+ poly.set(0, x1 + Math.sin(rad) * kage.kMinWidthT * v + kage.kMinWidthY * Math.cos(rad) * 0.5 * v,\r
+ y1 - Math.cos(rad) * kage.kMinWidthT * v + kage.kMinWidthY * Math.sin(rad) * 0.5 * v);\r
+ poly.set(3, x1 - Math.sin(rad) * kage.kMinWidthT * v - kage.kMinWidthY * Math.cos(rad) * 0.5 * v,\r
+ y1 + Math.cos(rad) * kage.kMinWidthT * v - kage.kMinWidthY * Math.sin(rad) * 0.5 * v);\r
+ break;\r
+ case 1:\r
+ case 6:\r
+ case 22:\r
+ poly.set(0, x1 + Math.sin(rad) * kage.kMinWidthT * v, y1 - Math.cos(rad) * kage.kMinWidthT * v);\r
+ poly.set(3, x1 - Math.sin(rad) * kage.kMinWidthT * v, y1 + Math.cos(rad) * kage.kMinWidthT * v);\r
+ break;\r
+ case 12:\r
+ poly.set(0, x1 + Math.sin(rad) * kage.kMinWidthT * v - kage.kMinWidthY * Math.cos(rad) * v,\r
+ y1 - Math.cos(rad) * kage.kMinWidthT * v - kage.kMinWidthY * Math.sin(rad) * v);\r
+ poly.set(3, x1 - Math.sin(rad) * kage.kMinWidthT * v - (kage.kMinWidthT + kage.kMinWidthY) * Math.cos(rad) * v,\r
+ y1 + Math.cos(rad) * kage.kMinWidthT * v - (kage.kMinWidthT + kage.kMinWidthY) * Math.sin(rad) * v);\r
+ break;\r
+ case 32:\r
+ poly.set(0, x1 + Math.sin(rad) * kage.kMinWidthT * v - kage.kMinWidthY * Math.cos(rad) * v,\r
+ y1 - Math.cos(rad) * kage.kMinWidthT * v - kage.kMinWidthY * Math.sin(rad) * v);\r
+ poly.set(3, x1 - Math.sin(rad) * kage.kMinWidthT * v - kage.kMinWidthY * Math.cos(rad) * v,\r
+ y1 + Math.cos(rad) * kage.kMinWidthT * v - kage.kMinWidthY * Math.sin(rad) * v);\r
+ break;\r
+ }\r
+ \r
+ switch(a2){\r
+ case 0:\r
+ if(a1 == 6){\r
+ poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthT * v, y2 - Math.cos(rad) * kage.kMinWidthT * v);\r
+ poly.set(2, x2 - Math.sin(rad) * kage.kMinWidthT * v, y2 + Math.cos(rad) * kage.kMinWidthT * v);\r
+ }\r
+ else{\r
+ poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthT * v - kage.kMinWidthT * 0.5 * Math.cos(rad) * v,\r
+ y2 - Math.cos(rad) * kage.kMinWidthT * v - kage.kMinWidthT * 0.5 * Math.sin(rad) * v);\r
+ poly.set(2, x2 - Math.sin(rad) * kage.kMinWidthT * v + kage.kMinWidthT * 0.5 * Math.cos(rad) * v,\r
+ y2 + Math.cos(rad) * kage.kMinWidthT * v + kage.kMinWidthT * 0.5 * Math.sin(rad) * v);\r
+ }\r
+ break;\r
+ case 1:\r
+ case 5:\r
+ poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthT * v, y2 - Math.cos(rad) * kage.kMinWidthT * v);\r
+ poly.set(2, x2 - Math.sin(rad) * kage.kMinWidthT * v, y2 + Math.cos(rad) * kage.kMinWidthT * v);\r
+ break;\r
+ case 13:\r
+ poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthT * v + kage.kWidth * kage.kKakato * Math.cos(rad) * v,\r
+ y2 - Math.cos(rad) * kage.kMinWidthT * v + kage.kWidth * kage.kKakato * Math.sin(rad) * v);\r
+ poly.set(2, x2 - Math.sin(rad) * kage.kMinWidthT * v + (kage.kWidth * kage.kKakato + kage.kMinWidthT) * Math.cos(rad) * v,\r
+ y2 + Math.cos(rad) * kage.kMinWidthT * v + (kage.kWidth * kage.kKakato + kage.kMinWidthT) * Math.sin(rad) * v);\r
+ break;\r
+ case 23:\r
+ poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthT * v + kage.kWidth * kage.kKakato * 0.5 * Math.cos(rad) * v,\r
+ y2 - Math.cos(rad) * kage.kMinWidthT * v + kage.kWidth * kage.kKakato * 0.5 * Math.sin(rad) * v);\r
+ poly.set(2,\r
+ x2 - Math.sin(rad) * kage.kMinWidthT * v + (kage.kWidth * kage.kKakato * 0.5 + kage.kMinWidthT) * Math.cos(rad) * v,\r
+ y2 + Math.cos(rad) * kage.kMinWidthT * v + (kage.kWidth * kage.kKakato * 0.5 + kage.kMinWidthT) * Math.sin(rad) * v);\r
+ break;\r
+ case 32:\r
+ poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthT * v + kage.kMinWidthY * Math.cos(rad) * v,\r
+ y2 - Math.cos(rad) * kage.kMinWidthT * v + kage.kMinWidthY * Math.sin(rad) * v);\r
+ poly.set(2, x2 - Math.sin(rad) * kage.kMinWidthT * v + kage.kMinWidthY * Math.cos(rad) * v,\r
+ y2 + Math.cos(rad) * kage.kMinWidthT * v + kage.kMinWidthY * Math.sin(rad) * v);\r
+ break;\r
+ }\r
+ \r
+ polygons.push(poly);\r
+ \r
+ if((a1 == 6) && (a2 == 0 || a2 == 5)){ //KAGI NO YOKO BOU NO SAIGO NO MARU\r
+ poly = new Polygon();\r
+ poly.push(x2 + Math.sin(rad) * kage.kMinWidthT * v, y2 - Math.cos(rad) * kage.kMinWidthT * v);\r
+ poly.push(x2 + Math.cos(rad) * kage.kMinWidthT * 0.8 * v + Math.sin(rad) * kage.kMinWidthT * 0.6 * v,\r
+ y2 + Math.sin(rad) * kage.kMinWidthT * 0.8 * v - Math.cos(rad) * kage.kMinWidthT * 0.6 * v);\r
+ poly.push(x2 + Math.cos(rad) * kage.kMinWidthT * v, y2 + Math.sin(rad) * kage.kMinWidthT * v);\r
+ poly.push(x2 + Math.cos(rad) * kage.kMinWidthT * 0.8 * v - Math.sin(rad) * kage.kMinWidthT * 0.6 * v,\r
+ y2 + Math.sin(rad) * kage.kMinWidthT * 0.8 * v + Math.cos(rad) * kage.kMinWidthT * 0.6 * v);\r
+ poly.push(x2 - Math.sin(rad) * kage.kMinWidthT * v, y2 + Math.cos(rad) * kage.kMinWidthT * v);\r
+ polygons.push(poly);\r
+ }\r
+ \r
+ if(a1 == 6 && a2 == 5){\r
+ //KAGI NO YOKO BOU NO HANE\r
+ poly = new Polygon();\r
+ poly.push(x2 + (kage.kMinWidthT - 1) * Math.sin(rad) * v, y2 - (kage.kMinWidthT - 1) * Math.cos(rad) * v);\r
+ poly.push(x2 + 2 * Math.cos(rad) * v + (kage.kMinWidthT + kage.kWidth * 5) * Math.sin(rad) * v,\r
+ y2 + 2 * Math.sin(rad) * v - (kage.kMinWidthT + kage.kWidth * 5) * Math.cos(rad) * v);\r
+ poly.push(x2 + (kage.kMinWidthT + kage.kWidth * 5) * Math.sin(rad) * v,\r
+ y2 - (kage.kMinWidthT + kage.kWidth * 5) * Math.cos(rad) * v);\r
+ poly.push(x2 + (kage.kMinWidthT - 1) * Math.sin(rad) * v - kage.kMinWidthT * Math.cos(rad) * v,\r
+ y2 - (kage.kMinWidthT - 1) * Math.cos(rad) * v - kage.kMinWidthT * Math.sin(rad) * v);\r
+ polygons.push(poly);\r
+ }\r
+ \r
+ if(a1 == 22){ //SHIKAKU MIGIUE UROKO NANAME DEMO MASSUGU MUKI\r
+ poly = new Polygon();\r
+ poly.push(x1 - kage.kMinWidthT, y1 - kage.kMinWidthY);\r
+ poly.push(x1, y1 - kage.kMinWidthY - kage.kWidth);\r
+ poly.push(x1 + kage.kMinWidthT + kage.kWidth, y1 + kage.kMinWidthY);\r
+ poly.push(x1 + kage.kMinWidthT, y1 + kage.kMinWidthT);\r
+ poly.push(x1 - kage.kMinWidthT, y1);\r
+ polygons.push(poly);\r
+ }\r
+ \r
+ XX = Math.sin(rad) * v;\r
+ XY = Math.cos(rad) * v * -1;\r
+ YX = Math.cos(rad) * v;\r
+ YY = Math.sin(rad) * v;\r
+ \r
+ if(a1 == 0){ //beginning of the storke\r
+ poly = new Polygon();\r
+ poly.push(x1 + kage.kMinWidthT * XX + (kage.kMinWidthY * 0.5) * YX,\r
+ y1 + kage.kMinWidthT * XY + (kage.kMinWidthY * 0.5) * YY);\r
+ poly.push(x1 + (kage.kMinWidthT + kage.kMinWidthT * 0.5) * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY) * YX,\r
+ y1 + (kage.kMinWidthT + kage.kMinWidthT * 0.5) * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY) * YY);\r
+ poly.push(x1 + kage.kMinWidthT * XX + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YX,\r
+ y1 + kage.kMinWidthT * XY + (kage.kMinWidthY * 0.5 + kage.kMinWidthY * 2) * YY);\r
+ polygons.push(poly);\r
+ }\r
+ }\r
+ }\r
+ }\r
+ else{ //gothic\r
+ if(tx1 == tx2){ //if TATE stroke, use y-axis\r
+ if(ty1 > ty2){\r
+ x1 = tx2;\r
+ y1 = ty2;\r
+ x2 = tx1;\r
+ y2 = ty1;\r
+ a1 = ta2;\r
+ a2 = ta1;\r
+ }\r
+ else{\r
+ x1 = tx1;\r
+ y1 = ty1;\r
+ x2 = tx2;\r
+ y2 = ty2;\r
+ a1 = ta1;\r
+ a2 = ta2;\r
+ }\r
+ \r
+ if(a1 % 10 == 2){ y1 = y1 - kage.kWidth; }\r
+ if(a2 % 10 == 2){ y2 = y2 + kage.kWidth; }\r
+ if(a1 % 10 == 3){ y1 = y1 - kage.kWidth * kage.kKakato; }\r
+ if(a2 % 10 == 3){ y2 = y2 + kage.kWidth * kage.kKakato; }\r
+ \r
+ poly = new Polygon();\r
+ poly.push(x1 - kage.kWidth, y1);\r
+ poly.push(x2 - kage.kWidth, y2);\r
+ poly.push(x2 + kage.kWidth, y2);\r
+ poly.push(x1 + kage.kWidth, y1);\r
+ poly.reverse(); // for fill-rule\r
+ \r
+ polygons.push(poly);\r
+ }\r
+ else if(ty1 == ty2){ //if YOKO stroke, use x-axis\r
+ if(tx1 > tx2){\r
+ x1 = tx2;\r
+ y1 = ty2;\r
+ x2 = tx1;\r
+ y2 = ty1;\r
+ a1 = ta2;\r
+ a2 = ta1;\r
+ }\r
+ else{\r
+ x1 = tx1;\r
+ y1 = ty1;\r
+ x2 = tx2;\r
+ y2 = ty2;\r
+ a1 = ta1;\r
+ a2 = ta2;\r
+ }\r
+ if(a1 % 10 == 2){ x1 = x1 - kage.kWidth; }\r
+ if(a2 % 10 == 2){ x2 = x2 + kage.kWidth; }\r
+ if(a1 % 10 == 3){ x1 = x1 - kage.kWidth * kage.kKakato; }\r
+ if(a2 % 10 == 3){ x2 = x2 + kage.kWidth * kage.kKakato; }\r
+ \r
+ poly = new Polygon();\r
+ poly.push(x1, y1 - kage.kWidth);\r
+ poly.push(x2, y2 - kage.kWidth);\r
+ poly.push(x2, y2 + kage.kWidth);\r
+ poly.push(x1, y1 + kage.kWidth);\r
+ \r
+ polygons.push(poly);\r
+ }\r
+ else{ //for others, use x-axis\r
+ if(tx1 > tx2){\r
+ x1 = tx2;\r
+ y1 = ty2;\r
+ x2 = tx1;\r
+ y2 = ty1;\r
+ a1 = ta2;\r
+ a2 = ta1;\r
+ }\r
+ else{\r
+ x1 = tx1;\r
+ y1 = ty1;\r
+ x2 = tx2;\r
+ y2 = ty2;\r
+ a1 = ta1;\r
+ a2 = ta2;\r
+ }\r
+ rad = Math.atan((y2 - y1) / (x2 - x1));\r
+ if(a1 % 10 == 2){\r
+ x1 = x1 - kage.kWidth * Math.cos(rad);\r
+ y1 = y1 - kage.kWidth * Math.sin(rad);\r
+ }\r
+ if(a2 % 10 == 2){\r
+ x2 = x2 + kage.kWidth * Math.cos(rad);\r
+ y2 = y2 + kage.kWidth * Math.sin(rad);\r
+ }\r
+ if(a1 % 10 == 3){\r
+ x1 = x1 - kage.kWidth * Math.cos(rad) * kage.kKakato;\r
+ y1 = y1 - kage.kWidth * Math.sin(rad) * kage.kKakato;\r
+ }\r
+ if(a2 % 10 == 3){\r
+ x2 = x2 + kage.kWidth * Math.cos(rad) * kage.kKakato;\r
+ y2 = y2 + kage.kWidth * Math.sin(rad) * kage.kKakato;\r
+ }\r
+ \r
+ //SUICHOKU NO ICHI ZURASHI HA Math.sin TO Math.cos NO IREKAE + x-axis MAINASU KA\r
+ poly = new Polygon();\r
+ poly.push(x1 + Math.sin(rad) * kage.kWidth, y1 - Math.cos(rad) * kage.kWidth);\r
+ poly.push(x2 + Math.sin(rad) * kage.kWidth, y2 - Math.cos(rad) * kage.kWidth);\r
+ poly.push(x2 - Math.sin(rad) * kage.kWidth, y2 + Math.cos(rad) * kage.kWidth);\r
+ poly.push(x1 - Math.sin(rad) * kage.kWidth, y1 + Math.cos(rad) * kage.kWidth);\r
+ \r
+ polygons.push(poly);\r
+ }\r
+ }\r
+}\r
--- /dev/null
+function dfDrawFont(kage, polygons, a1, a2, a3, x1, y1, x2, y2, x3, y3, x4, y4){\r
+ var tx1, tx2, tx3, tx4, ty1, ty2, ty3, ty4, v;\r
+ var rad;\r
+ \r
+ if(kage.kShotai == kage.kMincho){\r
+ switch(a1 % 100){\r
+ case 0:\r
+ break;\r
+ case 1:\r
+ if(a3 == 4){\r
+ if(x1 == x2){\r
+ if(y1 < y2){ v = 1; } else{ v = -1; }\r
+ tx1 = x2;\r
+ ty1 = y2 - kage.kMage * v;\r
+ }\r
+ else if(y1 == y2){\r
+ if(x1 < x2){ v = 1; } else{ v = -1; }\r
+ tx1 = x2 - kage.kMage * v;\r
+ ty1 = y2;\r
+ }\r
+ else{\r
+ rad = Math.atan((y2 - y1) / (x2 - x1));\r
+ if(x1 < x2){ v = 1; } else{v = -1; }\r
+ tx1 = x2 - kage.kMage * Math.cos(rad) * v;\r
+ ty1 = y2 - kage.kMage * Math.sin(rad) * v;\r
+ }\r
+ cdDrawLine(kage, polygons, x1, y1, tx1, ty1, a2, 1);\r
+ cdDrawCurve(kage, polygons, tx1, ty1, x2, y2, x2 - kage.kMage, y2, 1, 14);\r
+ }\r
+ else{\r
+ cdDrawLine(kage, polygons, x1, y1, x2, y2, a2, a3);\r
+ }\r
+ break;\r
+ case 2:\r
+ case 12:\r
+ if(a3 == 4){\r
+ if(x2 == x3){\r
+ tx1 = x3;\r
+ ty1 = y3 - kage.kMage;\r
+ }\r
+ else if(y2 == y3){\r
+ tx1 = x3 - kage.kMage;\r
+ ty1 = y3;\r
+ }\r
+ else{\r
+ rad = Math.atan((y3 - y2) / (x3 - x2));\r
+ if(x2 < x3){ v = 1; } else{ v = -1; }\r
+ tx1 = x3 - kage.kMage * Math.cos(rad) * v;\r
+ ty1 = y3 - kage.kMage * Math.sin(rad) * v;\r
+ }\r
+ cdDrawCurve(kage, polygons, x1, y1, x2, y2, tx1, ty1, a2, 1);\r
+ cdDrawCurve(kage, polygons, tx1, ty1, x3, y3, x3 - kage.kMage, y3, 1, 14);\r
+ }\r
+ else if(a3 == 5){\r
+ cdDrawCurve(kage, polygons, x1, y1, x2, y2, x3, y3, a2, 15);\r
+ }\r
+ else{\r
+ cdDrawCurve(kage, polygons, x1, y1, x2, y2, x3, y3, a2, a3);\r
+ }\r
+ break;\r
+ case 3:\r
+ if(a3 == 5){\r
+ if(x1 == x2){\r
+ if(y1 < y2){ v = 1; } else{ v = -1; }\r
+ tx1 = x2;\r
+ ty1 = y2 - kage.kMage * v;\r
+ }\r
+ else if(y1 == y2){\r
+ if(x1 < x2){ v = 1; } else{ v = -1; }\r
+ tx1 = x2 - kage.kMage * v;\r
+ ty1 = y2;\r
+ }\r
+ else{\r
+ rad = Math.atan((y2 - y1) / (x2 - x1));\r
+ if(x1 < x2){ v = 1; } else{ v = -1; }\r
+ tx1 = x2 - kage.kMage * Math.cos(rad) * v;\r
+ ty1 = y2 - kage.kMage * Math.sin(rad) * v;\r
+ }\r
+ if(x2 == x3){\r
+ if(y2 < y3){ v = 1; } else{ v = -1; }\r
+ tx2 = x2;\r
+ ty2 = y2 + kage.kMage * v;\r
+ }\r
+ else if(y2 == y3){\r
+ if(x2 < x3){ v = 1; } else { v = -1; }\r
+ tx2 = x2 + kage.kMage * v;\r
+ ty2 = y2;\r
+ }\r
+ else{\r
+ rad = Math.atan((y3 - y2) / (x3 - x2));\r
+ if(x2 < x3){ v = 1; } else{ v = -1; }\r
+ tx2 = x2 + kage.kMage * Math.cos(rad) * v;\r
+ ty2 = y2 + kage.kMage * Math.sin(rad) * v;\r
+ }\r
+ tx3 = x3 - kage.kMage;\r
+ ty3 = y3;\r
+ tx4 = x3 + kage.kMage * 0.5;\r
+ ty4 = y3 - kage.kMage * 2;\r
+ \r
+ cdDrawLine(kage, polygons, x1, y1, tx1, ty1, a2, 1);\r
+ cdDrawCurve(kage, polygons, tx1, ty1, x2, y2, tx2, ty2, 1, 1);\r
+ cdDrawLine(kage, polygons, tx2, ty2, tx3, ty3, 6, 5); // bolder by force\r
+ }\r
+ else{\r
+ if(x1 == x2){\r
+ if(y1 < y2){ v = 1; } else { v = -1; }\r
+ tx1 = x2;\r
+ ty1 = y2 - kage.kMage * v;\r
+ }\r
+ else if(y1 == y2){\r
+ if(x1 < x2){ v = 1; } else{ v = -1; }\r
+ tx1 = x2 - kage.kMage * v;\r
+ ty1 = y2;\r
+ }\r
+ else{\r
+ rad = Math.atan((y2 - y1) / (x2 - x1));\r
+ if(x1 < x2){ v = 1; } else{ v = -1; }\r
+ tx1 = x2 - kage.kMage * Math.cos(rad) * v;\r
+ ty1 = y2 - kage.kMage * Math.sin(rad) * v;\r
+ }\r
+ if(x2 == x3){\r
+ if(y2 < y3){ v = 1; } else{ v = -1; }\r
+ tx2 = x2;\r
+ ty2 = y2 + kage.kMage * v;\r
+ }\r
+ else if(y2 == y3){\r
+ if(x2 < x3){ v = 1; } else{ v = -1; }\r
+ tx2 = x2 + kage.kMage * v;\r
+ ty2 = y2;\r
+ }\r
+ else{\r
+ rad = Math.atan((y3 - y2) / (x3 - x2));\r
+ if(x2 < x3){ v = 1; } else{ v = -1; }\r
+ tx2 = x2 + kage.kMage * Math.cos(rad) * v;\r
+ ty2 = y2 + kage.kMage * Math.sin(rad) * v;\r
+ }\r
+ cdDrawLine(kage, polygons, x1, y1, tx1, ty1, a2, 1);\r
+ cdDrawCurve(kage, polygons, tx1, ty1, x2, y2, tx2, ty2, 1, 1);\r
+ cdDrawLine(kage, polygons, tx2, ty2, x3, y3, 6, a3); // bolder by force\r
+ }\r
+ break;\r
+ case 6:\r
+ if(a3 == 5){\r
+ /* only implimented for gothic\r
+ tx1 = x4 - kage.kMage;\r
+ ty1 = y4;\r
+ tx2 = x4 + kage.kMage * 0.5;\r
+ ty2 = y4 - kage.kMage * 2;\r
+ */\r
+ cdDrawBezier(kage, polygons, x1, y1, x2, y2, x3, y3, x4, y4, a2, 15);\r
+ /*\r
+ if(a2 == 7 || a3 == 7){\r
+ cdDrawCurve(x1, y1, x2, y2, (x2 + x3) / 2, (y2 + y3) / 2, a2, 17);\r
+ cdDrawCurve((x2 + x3) / 2, (y2 + y3) / 2, x3, y3, x4, y4, 17, 15);\r
+ }\r
+ else{\r
+ cdDrawCurve(x1, y1, x2, y2, (x2 + x3) / 2, (y2 + y3) / 2, a2, 8);\r
+ cdDrawCurve((x2 + x3) / 2, (y2 + y3) / 2, x3, y3, x4, y4, 1, 15);\r
+ }\r
+ */\r
+ }\r
+ else{\r
+ cdDrawBezier(kage, polygons, x1, y1, x2, y2, x3, y3, x4, y4, a2, a3);\r
+ /*\r
+ if(a2 == 7 || a3 == 7){\r
+ cdDrawCurve(x1, y1, x2, y2, (x2 + x3) / 2, (y2 + y3) / 2, a2, 17);\r
+ cdDrawCurve((x2 + x3) / 2, (y2 + y3) / 2, x3, y3, x4, y4, 17, a3);\r
+ }\r
+ else{\r
+ cdDrawCurve(x1, y1, x2, y2, (x2 + x3) / 2, (y2 + y3) / 2, a2, 8);\r
+ cdDrawCurve((x2 + x3) / 2, (y2 + y3) / 2, x3, y3, x4, y4, 1, a3);\r
+ }\r
+ */\r
+ }\r
+ break;\r
+ case 7:\r
+ cdDrawLine(kage, polygons, x1, y1, x2, y2, a2, 1);\r
+ cdDrawCurve(kage, polygons, x2, y2, x3, y3, x4, y4, 1, 7);\r
+ break;\r
+ case 9: // may not be exist\r
+ //kageCanvas[y1][x1] = 0;\r
+ //kageCanvas[y2][x2] = 0;\r
+ break;\r
+ default:\r
+ break;\r
+ }\r
+ }\r
+ \r
+ else{ // gothic\r
+ switch(a1 % 100){\r
+ case 0:\r
+ break;\r
+ case 1:\r
+ if(a3 == 4){\r
+ if(x1 == x2){\r
+ if(y1 < y2){ v = 1; } else{ v = -1; }\r
+ tx1 = x2;\r
+ ty1 = y2 - kage.kMage * v;\r
+ }\r
+ else if(y1 == y2){\r
+ if(x1 < x2){ v = 1; } else{ v = -1; }\r
+ tx1 = x2 - kage.kMage * v;\r
+ ty1 = y2;\r
+ }\r
+ else{\r
+ rad = Math.atan((y2 - y1) / (x2 - x1));\r
+ if(x1 < x2){ v = 1; } else{ v = -1; }\r
+ tx1 = x2 - kage.kMage * Math.cos(rad) * v;\r
+ ty1 = y2 - kage.kMage * Math.sin(rad) * v;\r
+ }\r
+ cdDrawLine(kage, polygons, x1, y1, tx1, ty1, a2, 1);\r
+ cdDrawCurve(kage, polygons, tx1, ty1, x2, y2, x2 - kage.kMage * 2, y2 - kage.kMage * 0.5, 1, 0);\r
+ }\r
+ else{\r
+ cdDrawLine(kage, polygons, x1, y1, x2, y2, a2, a3);\r
+ }\r
+ break;\r
+ case 2:\r
+ case 12:\r
+ if(a3 == 4){\r
+ if(x2 == x3){\r
+ tx1 = x3;\r
+ ty1 = y3 - kage.kMage;\r
+ }\r
+ else if(y2 == y3){\r
+ tx1 = x3 - kage.kMage;\r
+ ty1 = y3;\r
+ }\r
+ else{\r
+ rad = Math.atan((y3 - y2) / (x3 - x2));\r
+ if(x2 < x3){ v = 1; } else{ v = -1; }\r
+ tx1 = x3 - kage.kMage * Math.cos(rad) * v;\r
+ ty1 = y3 - kage.kMage * Math.sin(rad) * v;\r
+ }\r
+ cdDrawCurve(kage, polygons, x1, y1, x2, y2, tx1, ty1, a2, 1);\r
+ cdDrawCurve(kage, polygons, tx1, ty1, x3, y3, x3 - kage.kMage * 2, y3 - kage.kMage * 0.5, 1, 0);\r
+ }\r
+ else if(a3 == 5){\r
+ tx1 = x3 + kage.kMage;\r
+ ty1 = y3;\r
+ tx2 = tx1 + kage.kMage * 0.5;\r
+ ty2 = y3 - kage.kMage * 2;\r
+ cdDrawCurve(kage, polygons, x1, y1, x2, y2, x3, y3, a2, 1);\r
+ cdDrawCurve(kage, polygons, x3, y3, tx1, ty1, tx2, ty2, 1, 0);\r
+ }\r
+ else{\r
+ cdDrawCurve(kage, polygons, x1, y1, x2, y2, x3, y3, a2, a3);\r
+ }\r
+ break;\r
+ case 3:\r
+ if(a3 == 5){\r
+ if(x1 == x2){\r
+ if(y1 < y2){ v = 1; } else{ v = -1; }\r
+ tx1 = x2;\r
+ ty1 = y2 - kage.kMage * v;\r
+ }\r
+ else if(y1 == y2){\r
+ if(x1 < x2){ v = 1; } else{ v = -1; }\r
+ tx1 = x2 - kage.kMage * v;\r
+ ty1 = y2;\r
+ }\r
+ else{\r
+ rad = Math.atan((y2 - y1) / (x2 - x1));\r
+ if(x1 < x2){ v = 1; } else{ v = -1; }\r
+ tx1 = x2 - kage.kMage * Math.cos(rad) * v;\r
+ ty1 = y2 - kage.kMage * Math.sin(rad) * v;\r
+ }\r
+ if(x2 == x3){\r
+ if(y2 < y3){ v = 1; } else{ v = -1; }\r
+ tx2 = x2;\r
+ ty2 = y2 + kage.kMage * v;\r
+ }\r
+ else if(y2 == y3){\r
+ if(x2 < x3){ v = 1; } else{ v = -1; }\r
+ tx2 = x2 + kage.kMage * v;\r
+ ty2 = y2;\r
+ }\r
+ else{\r
+ rad = Math.atan((y3 - y2) / (x3 - x2));\r
+ if(x2 < x3){ v = 1; } else{ v = -1; }\r
+ tx2 = x2 + kage.kMage * Math.cos(rad) * v;\r
+ ty2 = y2 + kage.kMage * Math.sin(rad) * v;\r
+ }\r
+ tx3 = x3 - kage.kMage;\r
+ ty3 = y3;\r
+ tx4 = x3 + kage.kMage * 0.5;\r
+ ty4 = y3 - kage.kMage * 2;\r
+ \r
+ cdDrawLine(kage, polygons, x1, y1, tx1, ty1, a2, 1);\r
+ cdDrawCurve(kage, polygons, tx1, ty1, x2, y2, tx2, ty2, 1, 1);\r
+ cdDrawLine(kage, polygons, tx2, ty2, tx3, ty3, 1, 1);\r
+ cdDrawCurve(kage, polygons, tx3, ty3, x3, y3, tx4, ty4, 1, 0);\r
+ }\r
+ else{\r
+ if(x1 == x2){\r
+ if(y1 < y2){ v = 1; } else{ v = -1; }\r
+ tx1 = x2;\r
+ ty1 = y2 - kage.kMage * v;\r
+ }\r
+ else if(y1 == y2){\r
+ if(x1 < x2){ v = 1; } else{ v = -1; }\r
+ tx1 = x2 - kage.kMage * v;\r
+ ty1 = y2;\r
+ }\r
+ else{\r
+ rad = Math.atan((y2 - y1) / (x2 - x1));\r
+ if(x1 < x2){ v = 1; } else{ v = -1; }\r
+ tx1 = x2 - kage.kMage * Math.cos(rad) * v;\r
+ ty1 = y2 - kage.kMage * Math.sin(rad) * v;\r
+ }\r
+ if(x2 == x3){\r
+ if(y2 < y3){ v = 1; } else{ v = -1; }\r
+ tx2 = x2;\r
+ ty2 = y2 + kage.kMage * v;\r
+ }\r
+ else if(y2 == y3){\r
+ if(x2 < x3){ v = 1; } else{ v = -1; }\r
+ tx2 = x2 + kage.kMage * v;\r
+ ty2 = y2;\r
+ }\r
+ else{\r
+ rad = Math.atan((y3 - y2) / (x3 - x2));\r
+ if(x2 < x3){ v = 1; } else{ v = -1; }\r
+ tx2 = x2 + kage.kMage * Math.cos(rad) * v;\r
+ ty2 = y2 + kage.kMage * Math.sin(rad) * v;\r
+ }\r
+ \r
+ cdDrawLine(kage, polygons, x1, y1, tx1, ty1, a2, 1);\r
+ cdDrawCurve(kage, polygons, tx1, ty1, x2, y2, tx2, ty2, 1, 1);\r
+ cdDrawLine(kage, polygons, tx2, ty2, x3, y3, 1, a3);\r
+ }\r
+ break;\r
+ case 6:\r
+ if(a3 == 5){\r
+ tx1 = x4 - kage.kMage;\r
+ ty1 = y4;\r
+ tx2 = x4 + kage.kMage * 0.5;\r
+ ty2 = y4 - kage.kMage * 2;\r
+ /*\r
+ cdDrawCurve(x1, y1, x2, y2, (x2 + x3) / 2, (y2 + y3) / 2, a2, 1);\r
+ cdDrawCurve((x2 + x3) / 2, (y2 + y3) / 2, x3, y3, tx1, ty1, 1, 1);\r
+ */\r
+ cdDrawBezier(kage, polygons, x1, y1, x2, y2, x3, y3, tx1, ty1, a2, 1);\r
+ cdDrawCurve(kage, polygons, tx1, ty1, x4, y4, tx2, ty2, 1, 0);\r
+ }\r
+ else{\r
+ /*\r
+ cdDrawCurve(x1, y1, x2, y2, (x2 + x3) / 2, (y2 + y3) / 2, a2, 1);\r
+ cdDrawCurve((x2 + x3) / 2, (y2 + y3) / 2, x3, y3, x4, y4, 1, a3);\r
+ */\r
+ cdDrawBezier(kage, polygons, x1, y1, x2, y2, x3, y3, x4, y4, a2, a3);\r
+ }\r
+ break;\r
+ case 7:\r
+ cdDrawLine(kage, polygons, x1, y1, x2, y2, a2, 1);\r
+ cdDrawCurve(kage, polygons, x2, y2, x3, y3, x4, y4, 1, a3);\r
+ break;\r
+ case 9: // may not be exist\r
+ //kageCanvas[y1][x1] = 0;\r
+ //kageCanvas[y2][x2] = 0;\r
+ break;\r
+ default:\r
+ break;\r
+ }\r
+ }\r
+}\r