//\r
#include "kage.h"\r
\r
+void cdDrawBezier(double x1, double y1,\r
+ double x2, double y2,\r
+ double x3, double y3,\r
+ double x4, double y4,\r
+ int a1, int a2){\r
+\r
+ double rad, t;\r
+ double x, y, v;\r
+ double ix, iy, ia, ib, ir;\r
+ int count, tt;\r
+ double delta;\r
+ double deltad;\r
+ double XX, XY, YX, YY;\r
+ \r
+ if(kShotai == kMincho){ // mincho\r
+ switch(a1){\r
+ case 0:\r
+ case 7:\r
+ delta = -1 * 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 = 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 = atan((double)(y2 - y1) / (double)(x2 - x1));\r
+ if(x1 < x2){ v = 1; } else{ v = -1; }\r
+ x1 = x1 - delta * cos(rad) * v;\r
+ y1 = y1 - delta * 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 = atan((double)(y4 - y3) / (double)(x4 - x3));\r
+ if(x3 < x4){ v = 1; } else{ v = -1; }\r
+ x4 = x4 + delta * cos(rad) * v;\r
+ y4 = y4 + delta * sin(rad) * v;\r
+ }\r
+ \r
+ count = 0;\r
+ \r
+ for(tt = 0; tt <= 1000; tt = tt + kRate){\r
+ t = (double)(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 = atan(iy / ix * -1);\r
+ ia = sin(ir) * (double)(kMinWidthT);\r
+ ib = cos(ir) * (double)(kMinWidthT);\r
+ }\r
+ else if(ix == 0){\r
+ ia = kMinWidthT;\r
+ ib = 0;\r
+ }\r
+ else{\r
+ ia = 0;\r
+ ib = kMinWidthT;\r
+ }\r
+ \r
+ /*\r
+ if(a1 == 7 && a2 != 17){ deltad = sqrt(t); }\r
+ else if(a2 == 7 && a1 != 17){ deltad = sqrt(1.0 - t); }\r
+ else if(a1 == 7 && a2 == 17){ deltad = sqrt(t / 2); }\r
+ else if(a1 == 17 && a2 != 7){ deltad = sqrt(t / 2 + 0.5); }\r
+ else if(a1 != 7 && a2 == 17){ deltad = sqrt(1.0 - t / 2); }\r
+ else if(a1 == 17 && a2 == 7){ deltad = sqrt(0.5 - t / 2); }\r
+ else{ deltad = 1; }\r
+ */\r
+ if(a1 == 7){ deltad = sqrt(t); }\r
+ else if(a2 == 7){ deltad = 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[count].X = x - ia;\r
+ poly[count].Y = y - ib;\r
+ poly[(1000 / kRate + 1) * 2 - 1 - count].X = x + ia;\r
+ poly[(1000 / kRate + 1) * 2 - 1 - count].Y = y + ib;\r
+ count += 1;\r
+ }\r
+ \r
+ icPolygon(poly, (1000 / kRate + 1) * 2);\r
+ \r
+ //process for head of stroke\r
+ rad = atan((double)(y2 - y1) / (double)(x2 - x1));\r
+ if(x1 < x2){ v = 1; } else{ v = -1; }\r
+ XX = sin(rad) * v;\r
+ XY = cos(rad) * v * -1;\r
+ YX = cos(rad) * v;\r
+ YY = sin(rad) * v;\r
+ \r
+ if(a1 == 12){\r
+ if(x1 == x2){\r
+ poly2[0].X = x1 - kMinWidthT;\r
+ poly2[0].Y = y1;\r
+ poly2[1].X = x1 + kMinWidthT;\r
+ poly2[1].Y = y1;\r
+ poly2[2].X = x1 - kMinWidthT;\r
+ poly2[2].Y = y1 - kMinWidthT;\r
+ icPolygon(poly2, 3);\r
+ }\r
+ else{\r
+ poly2[0].X = x1 - kMinWidthT * XX;\r
+ poly2[0].Y = y1 - kMinWidthT * XY;\r
+ poly2[1].X = x1 + kMinWidthT * XX;\r
+ poly2[1].Y = y1 + kMinWidthT * XY;\r
+ poly2[2].X = x1 - kMinWidthT * XX - kMinWidthT * YX;\r
+ poly2[2].Y = y1 - kMinWidthT * XY - kMinWidthT * YY;\r
+ icPolygon(poly2, 3);\r
+ }\r
+ }\r
+ \r
+ if(a1 == 0){\r
+ if(y1 <= y4){ //from up to bottom\r
+ if(x1 == x2){\r
+ poly2[0].X = x1 - kMinWidthT;\r
+ poly2[0].Y = y1;\r
+ poly2[1].X = x1 + kMinWidthT;\r
+ poly2[1].Y = y1;\r
+ poly2[2].X = x1 - kMinWidthT;\r
+ poly2[2].Y = y1 - kMinWidthY;\r
+ icPolygon(poly2, 3);\r
+ }\r
+ else{\r
+ poly2[0].X = x1 - kMinWidthT * XX;\r
+ poly2[0].Y = y1 - kMinWidthT * XY;\r
+ poly2[1].X = x1 + kMinWidthT * XX;\r
+ poly2[1].Y = y1 + kMinWidthT * XY;\r
+ poly2[2].X = x1 - kMinWidthT * XX - kMinWidthY * YX;\r
+ poly2[2].Y = y1 - kMinWidthT * XY - kMinWidthY * YY;\r
+ icPolygon(poly2, 3);\r
+ }\r
+ }\r
+ else{ //bottom to up\r
+ if(x1 == x2){ //is it right?\r
+ poly2[0].X = x1 - kMinWidthT;\r
+ poly2[0].Y = y1;\r
+ poly2[1].X = x1 + kMinWidthT;\r
+ poly2[1].Y = y1;\r
+ poly2[2].X = x1 - kMinWidthT;\r
+ poly2[2].Y = y1 + kMinWidthY;\r
+ icPolygon(poly2, 3);\r
+ }\r
+ else{\r
+ poly2[0].X = x1 - kMinWidthT * XX;\r
+ poly2[0].Y = y1 - kMinWidthT * XY;\r
+ poly2[1].X = x1 + kMinWidthT * XX;\r
+ poly2[1].Y = y1 + kMinWidthT * XY;\r
+ poly2[2].X = x1 + kMinWidthT * XX - kMinWidthY * YX;\r
+ poly2[2].Y = y1 + kMinWidthT * XY - kMinWidthY * YY;\r
+ icPolygon(poly2, 3);\r
+ }\r
+ }\r
+ }\r
+ \r
+ if(a1 == 22){ //box's up-right corner, any time same degree\r
+ poly3[0].X = x1 - kMinWidthT;\r
+ poly3[0].Y = y1 - kMinWidthY;\r
+ poly3[1].X = x1;\r
+ poly3[1].Y = y1 - kMinWidthY - kWidth;\r
+ poly3[2].X = x1 + kMinWidthT + kWidth;\r
+ poly3[2].Y = y1 + kMinWidthY;\r
+ poly3[3].X = x1 + kMinWidthT;\r
+ poly3[3].Y = y1 + kMinWidthT;\r
+ poly3[4].X = x1 - kMinWidthT;\r
+ poly3[4].Y = y1;\r
+ icPolygon(poly3, 5);\r
+ }\r
+ \r
+ if(a1 == 0){ //beginning of the stroke\r
+ if(y1 <= y4){ //from up to bottom\r
+ if(x1 == x2){\r
+ poly2[0].X = x1 + kMinWidthT;\r
+ poly2[0].Y = y1 + kMinWidthY * 0.5;\r
+ poly2[1].X = x1 + kMinWidthT + kMinWidthT * 0.5;\r
+ poly2[1].Y = y1 + kMinWidthY * 0.5 + kMinWidthY;\r
+ poly2[2].X = x1 + kMinWidthT;\r
+ poly2[2].Y = y1 + kMinWidthY * 0.5 + kMinWidthY * 2;\r
+ icPolygon(poly2, 3);\r
+ }\r
+ else{\r
+ poly2[0].X = x1 + kMinWidthT * XX + (kMinWidthY * 0.5) * YX;\r
+ poly2[0].Y = y1 + kMinWidthT * XY + (kMinWidthY * 0.5) * YY;\r
+ poly2[1].X = x1 + (kMinWidthT + kMinWidthT * 0.5) * XX + (kMinWidthY * 0.5 + kMinWidthY) * YX;\r
+ poly2[1].Y = y1 + (kMinWidthT + kMinWidthT * 0.5) * XY + (kMinWidthY * 0.5 + kMinWidthY) * YY;\r
+ poly2[2].X = x1 + kMinWidthT * XX + (kMinWidthY * 0.5 + kMinWidthY * 2) * YX;\r
+ poly2[2].Y = y1 + kMinWidthT * XY + (kMinWidthY * 0.5 + kMinWidthY * 2) * YY;\r
+ icPolygon(poly2, 3);\r
+ }\r
+ }\r
+ else{ //from bottom to up\r
+ if(x1 == x2){ //is it right?\r
+ poly2[0].X = x1 + kMinWidthT;\r
+ poly2[0].Y = y1 - kMinWidthY * 0.5;\r
+ poly2[1].X = x1 + kMinWidthT + kMinWidthT * 0.5;\r
+ poly2[1].Y = y1 - kMinWidthY * 0.5 - kMinWidthY;\r
+ poly2[2].X = x1 + kMinWidthT;\r
+ poly2[2].Y = y1 - kMinWidthY * 0.5 - kMinWidthY * 2;\r
+ icPolygon(poly2, 3);\r
+ }\r
+ else //SETSUGOUMEN GA KAKERUNODE HOKYOU\r
+ poly3[0].X = x1 - (kMinWidthT - 1) * XX + (kMinWidthY * 0.5) * YX;\r
+ poly3[0].Y = y1 - (kMinWidthT - 1) * XY + (kMinWidthY * 0.5) * YY;\r
+ poly3[1].X = x1 - (kMinWidthT - 0) * XX + (kMinWidthY * 0.5) * YX;\r
+ poly3[1].Y = y1 - (kMinWidthT - 0) * XY + (kMinWidthY * 0.5) * YY;\r
+ poly3[2].X = x1 - (kMinWidthT + kMinWidthT * 0.5) * XX + (kMinWidthY * 0.5 + kMinWidthY) * YX;\r
+ poly3[2].Y = y1 - (kMinWidthT + kMinWidthT * 0.5) * XY + (kMinWidthY * 0.5 + kMinWidthY) * YY;\r
+ poly3[3].X = x1 - (kMinWidthT - 0) * XX + (kMinWidthY * 0.5 + kMinWidthY * 2) * YX;\r
+ poly3[3].Y = y1 - (kMinWidthT - 0) * XY + (kMinWidthY * 0.5 + kMinWidthY * 2) * YY;\r
+ poly3[4].X = x1 - (kMinWidthT - 1) * XX + (kMinWidthY * 0.5 + kMinWidthY * 2) * YX;\r
+ poly3[4].Y = y1 - (kMinWidthT - 1) * XY + (kMinWidthY * 0.5 + kMinWidthY * 2) * YY;\r
+ icPolygon(poly3, 5);\r
+ }\r
+ }\r
+ \r
+ //process for tail\r
+ rad = atan((double)(y4 - y3) / (double)(x4 - x3));\r
+ if(x3 < x4){ v = 1; } else{ v = -1; }\r
+ YX = sin(rad) * v * -1;\r
+ YY = cos(rad) * v;\r
+ XX = cos(rad) * v;\r
+ XY = sin(rad) * v;\r
+ \r
+ if(a2 == 1 || a2 == 8 || a2 == 15){ //the last filled circle\r
+ if(x3 == x4){\r
+ poly3[0].X = x4 - kMinWidthT;\r
+ poly3[0].Y = y4;\r
+ poly3[1].X = x4 - kMinWidthT * 0.6;\r
+ poly3[1].Y = y4 + kMinWidthT * 0.6;\r
+ poly3[2].X = x4;\r
+ poly3[2].Y = y4 + kMinWidthT;\r
+ poly3[3].X = x4 + kMinWidthT * 0.6;\r
+ poly3[3].Y = y4 + kMinWidthT * 0.6;\r
+ poly3[4].X = x4 + kMinWidthT;\r
+ poly3[4].Y = y4;\r
+ icPolygon(poly3, 5);\r
+ }\r
+ else if(y3 == y4){\r
+ poly3[0].X = x4;\r
+ poly3[0].Y = y4 - kMinWidthT;\r
+ poly3[1].X = x4 + kMinWidthT * 0.6;\r
+ poly3[1].Y = y4 - kMinWidthT * 0.6;\r
+ poly3[2].X = x4 + kMinWidthT;\r
+ poly3[2].Y = y4;\r
+ poly3[3].X = x4 + kMinWidthT * 0.6;\r
+ poly3[3].Y = y4 + kMinWidthT * 0.6;\r
+ poly3[4].X = x4;\r
+ poly3[4].Y = y4 + kMinWidthT;\r
+ icPolygon(poly3, 5);\r
+ }\r
+ else{\r
+ poly3[0].X = x4 + sin(rad) * kMinWidthT * v;\r
+ poly3[0].Y = y4 - cos(rad) * kMinWidthT * v;\r
+ poly3[1].X = x4 + cos(rad) * kMinWidthT * 0.8 * v + sin(rad) * kMinWidthT * 0.6 * v;\r
+ poly3[1].Y = y4 + sin(rad) * kMinWidthT * 0.8 * v - cos(rad) * kMinWidthT * 0.6 * v;\r
+ poly3[2].X = x4 + cos(rad) * kMinWidthT * v;\r
+ poly3[2].Y = y4 + sin(rad) * kMinWidthT * v;\r
+ poly3[3].X = x4 + cos(rad) * kMinWidthT * 0.8 * v - sin(rad) * kMinWidthT * 0.6 * v;\r
+ poly3[3].Y = y4 + sin(rad) * kMinWidthT * 0.8 * v + cos(rad) * kMinWidthT * 0.6 * v;\r
+ poly3[4].X = x4 - sin(rad) * kMinWidthT * v;\r
+ poly3[4].Y = y4 + cos(rad) * kMinWidthT * v;\r
+ icPolygon(poly3, 5);\r
+ }\r
+ }\r
+ \r
+ /*\r
+ if(a2 == 17){ //the last filled half circle\r
+ if(x2 == x3){\r
+ poly3[0].X = x3 - kMinWidthT * 0.5;\r
+ poly3[0].Y = y3;\r
+ poly3[1].X = x3 - kMinWidthT * 0.6 * 0.5;\r
+ poly3[1].Y = y3 + kMinWidthT * 0.6 * 0.5;\r
+ poly3[2].X = x3;\r
+ poly3[2].Y = y3 + kMinWidthT * 0.5;\r
+ poly3[3].X = x3 + kMinWidthT * 0.6 * 0.5;\r
+ poly3[3].Y = y3 + kMinWidthT * 0.6 * 0.5;\r
+ poly3[4].X = x3 + kMinWidthT * 0.5;\r
+ poly3[4].Y = y3;\r
+ icPolygon(poly3, 5);\r
+ }\r
+ else if(y2 == y3){\r
+ poly3[0].X = x3;\r
+ poly3[0].Y = y3 - kMinWidthT * 0.5;\r
+ poly3[1].X = x3 + kMinWidthT * 0.6 * 0.5;\r
+ poly3[1].Y = y3 - kMinWidthT * 0.6 * 0.5;\r
+ poly3[2].X = x3 + kMinWidthT * 0.5;\r
+ poly3[2].Y = y3;\r
+ poly3[3].X = x3 + kMinWidthT * 0.6 * 0.5;\r
+ poly3[3].Y = y3 + kMinWidthT * 0.6 * 0.5;\r
+ poly3[4].X = x3;\r
+ poly3[4].Y = y3 + kMinWidthT * 0.5;\r
+ icPolygon(poly3, 5);\r
+ }\r
+ else{\r
+ poly3[0].X = x3 + sin(rad) * kMinWidthT * 0.5 * v;\r
+ poly3[0].Y = y3 - cos(rad) * kMinWidthT * 0.5 * v;\r
+ poly3[1].X = x3 + cos(rad) * kMinWidthT * 0.8 * 0.5 * v + sin(rad) * kMinWidthT * 0.6 * 0.5 * v;\r
+ poly3[1].Y = y3 + sin(rad) * kMinWidthT * 0.8 * 0.5 * v - cos(rad) * kMinWidthT * 0.6 * 0.5 * v;\r
+ poly3[2].X = x3 + cos(rad) * kMinWidthT * 0.5 * v;\r
+ poly3[2].Y = y3 + sin(rad) * kMinWidthT * 0.5 * v;\r
+ poly3[3].X = x3 + cos(rad) * kMinWidthT * 0.5 * 0.8 * v - sin(rad) * kMinWidthT * 0.6 * 0.5 * v;\r
+ poly3[3].Y = y3 + sin(rad) * kMinWidthT * 0.5 * 0.8 * v + cos(rad) * kMinWidthT * 0.6 * 0.5 * v;\r
+ poly3[4].X = x3 - sin(rad) * kMinWidthT * 0.5 * v;\r
+ poly3[4].Y = y3 + cos(rad) * kMinWidthT * 0.5 * v;\r
+ icPolygon(poly3, 5);\r
+ }\r
+ }\r
+ */\r
+ \r
+ if(a2 == 9 || (a1 == 7 && a2 == 0)){ // Sinnyu & L2RD Harai\r
+ if(y3 == y4){\r
+ poly2[0].X = x4;\r
+ poly2[0].Y = y4 + kMinWidthT;\r
+ poly2[1].X = x4;\r
+ poly2[1].Y = y4 - kMinWidthT;\r
+ poly2[2].X = x4 + kMinWidthT;\r
+ poly2[2].Y = y4 - kMinWidthT;\r
+ icPolygon(poly2, 3);\r
+ }\r
+ else{\r
+ poly2[0].X = x4 + kMinWidthT * YX;\r
+ poly2[0].Y = y4 + kMinWidthT * YY;\r
+ poly2[1].X = x4 - kMinWidthT * YX;\r
+ poly2[1].Y = y4 - kMinWidthT * YY;\r
+ poly2[2].X = x4 + kMinWidthT * XX - kMinWidthT * YX;\r
+ poly2[2].Y = y4 + kMinWidthT * XY - kMinWidthT * YY;\r
+ icPolygon(poly2, 3);\r
+ }\r
+ }\r
+ \r
+ if(a2 == 15){ //jump up\r
+ if(y3 == y4){\r
+ poly4[0].X = x4;\r
+ poly4[0].Y = y4 - kMinWidthT + 1;\r
+ poly4[1].X = x4 + 2;\r
+ poly4[1].Y = y4 - kMinWidthT - kWidth * 5;\r
+ poly4[2].X = x4;\r
+ poly4[2].Y = y4 - kMinWidthT - kWidth * 5;\r
+ poly4[3].X = x4 - kMinWidthT;\r
+ poly4[3].Y = y4 - kMinWidthT + 1;\r
+ icPolygon(poly4, 4);\r
+ }\r
+ else{\r
+ poly4[0].X = x4 + (kMinWidthT - 1) * sin(rad) * v;\r
+ poly4[0].Y = y4 - (kMinWidthT - 1) * cos(rad) * v;\r
+ poly4[1].X = x4 + 2 * cos(rad) * v + (kMinWidthT + kWidth * 5) * sin(rad) * v;\r
+ poly4[1].Y = y4 + 2 * sin(rad) * v - (kMinWidthT + kWidth * 5) * cos(rad) * v;\r
+ poly4[2].X = x4 + (kMinWidthT + kWidth * 5) * sin(rad) * v;\r
+ poly4[2].Y = y4 - (kMinWidthT + kWidth * 5) * cos(rad) * v;\r
+ poly4[3].X = x4 + (kMinWidthT - 1) * sin(rad) * v - kMinWidthT * cos(rad) * v;\r
+ poly4[3].Y = y4 - (kMinWidthT - 1) * cos(rad) * v - kMinWidthT * sin(rad) * v;\r
+ icPolygon(poly4, 4);\r
+ }\r
+ }\r
+ \r
+ if(a2 == 14){ //jump to left, allways go left\r
+ poly4[0].X = x4;\r
+ poly4[0].Y = y4;\r
+ poly4[1].X = x4;\r
+ poly4[1].Y = y4 - kMinWidthT;\r
+ poly4[2].X = x4 - kWidth * 4;\r
+ poly4[2].Y = y4 - kMinWidthT;\r
+ poly4[3].X = x4 - kWidth * 4;\r
+ poly4[3].Y = y4 - kMinWidthT * 0.5;\r
+ icPolygon(poly4, 4);\r
+ }\r
+ }\r
+ else{ //gothic\r
+ if(a1 % 10 == 2){\r
+ if(x1 == x2){\r
+ if(y1 < y2){ y1 = y1 - kWidth; } else{ y1 = y1 + kWidth; }\r
+ }\r
+ else if(y1 == y2){\r
+ if(x1 < x2){ x1 = x1 - kWidth; } else{ x1 = x1 + kWidth; }\r
+ }\r
+ else{\r
+ rad = atan((double)(y2 - y1) / (double)(x2 - x1));\r
+ if(x1 < x2){ v = 1; } else{ v = -1; }\r
+ x1 = x1 - kWidth * cos(rad) * v;\r
+ y1 = y1 - kWidth * sin(rad) * v;\r
+ }\r
+ }\r
+ \r
+ if(a1 % 10 == 3){\r
+ if(x1 == x2){\r
+ if(y1 < y2){\r
+ y1 = y1 - kWidth * kKakato;\r
+ }\r
+ else{\r
+ y1 = y1 + kWidth * kKakato;\r
+ }\r
+ }\r
+ else if(y1 == y2){\r
+ if(x1 < x2){\r
+ x1 = x1 - kWidth * kKakato;\r
+ }\r
+ else{\r
+ x1 = x1 + kWidth * kKakato;\r
+ }\r
+ }\r
+ else{\r
+ rad = atan((double)(y2 - y1) / (double)(x2 - x1));\r
+ if(x1 < x2){ v = 1; } else{ v = -1; }\r
+ x1 = x1 - kWidth * cos(rad) * v * kKakato;\r
+ y1 = y1 - kWidth * sin(rad) * v * kKakato;\r
+ }\r
+ }\r
+ if(a2 % 10 == 2){\r
+ if(x3 == x4){\r
+ if(y3 < y4){ y4 = y4 + kWidth; } else{ y4 = y4 - kWidth; }\r
+ }\r
+ else if(y3 == y4){\r
+ if(x3 < x4){ x4 = x4 + kWidth; } else{ x4 = x4 - kWidth; }\r
+ }\r
+ else{\r
+ rad = atan((double)(y4 - y3) / (double)(x4 - x3));\r
+ if(x3 < x4){ v = 1; } else{ v = -1; }\r
+ x4 = x4 + kWidth * cos(rad) * v;\r
+ y4 = y4 + kWidth * sin(rad) * v;\r
+ }\r
+ }\r
+ \r
+ if(a2 % 10 == 3){\r
+ if(x3 == x4){\r
+ if(y3 < y4){\r
+ y4 = y4 + kWidth * kKakato;\r
+ }\r
+ else{\r
+ y4 = y4 - kWidth * kKakato;\r
+ }\r
+ }\r
+ else if(y3 == y4){\r
+ if(x3 < x4){\r
+ x4 = x4 + kWidth * kKakato;\r
+ }\r
+ else{\r
+ x4 = x4 - kWidth * kKakato;\r
+ }\r
+ }\r
+ else{\r
+ rad = atan((double)(y4 - y3) / (double)(x4 - x3));\r
+ if(x3 < x4){ v = 1; } else{ v = -1; }\r
+ x4 = x4 + kWidth * cos(rad) * v * kKakato;\r
+ y4 = y4 + kWidth * sin(rad) * v * kKakato;\r
+ }\r
+ }\r
+ \r
+ count = 0;\r
+ \r
+ for(tt = 0; tt <= 1000; tt = tt + kRate){\r
+ t = (double)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(kShotai == kMincho){ //always false ?\r
+ if(ix != 0 && iy != 0){\r
+ ir = atan(iy / ix * -1.0);\r
+ ia = sin(ir) * (double)kMinWidthT;\r
+ ib = cos(ir) * (double)kMinWidthT;\r
+ }\r
+ else if(ix == 0){\r
+ ia = kMinWidthT;\r
+ ib = 0;\r
+ }\r
+ else{\r
+ ia = 0;\r
+ ib = kMinWidthT;\r
+ }\r
+ ia = ia * sqrt(1.0 - t);\r
+ ib = ib * sqrt(1.0 - t);\r
+ }\r
+ else{\r
+ if(ix != 0 && iy != 0){\r
+ ir = atan(iy / ix * -1.0);\r
+ ia = sin(ir) * (double)kWidth;\r
+ ib = cos(ir) * (double)kWidth;\r
+ }\r
+ else if(ix == 0){\r
+ ia = kWidth;\r
+ ib = 0;\r
+ }\r
+ else{\r
+ ia = 0;\r
+ ib = 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[count].X = x - ia;\r
+ poly[count].Y = y - ib;\r
+ poly[(1000 / kRate + 1) * 2 - 1 - count].X = x + ia;\r
+ poly[(1000 / kRate + 1) * 2 - 1 - count].Y = y + ib;\r
+ count += 1;\r
+ }\r
+ \r
+ icPolygon(poly, (1000 / kRate + 1) * 2);\r
+ }\r
+}\r
+\r
void cdDrawCurve(double x1, double y1,\r
double x2, double y2,\r
double x3, double y3,\r
break;\r
case 6:\r
if(a3 == 5){\r
+ /* only implimented for gothic\r
tx1 = x4 - kMage;\r
ty1 = y4;\r
tx2 = x4 + kMage * 0.5;\r
ty2 = y4 - kMage * 2;\r
+ */\r
+ cdDrawBezier(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
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(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
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
ty1 = y4;\r
tx2 = x4 + kMage * 0.5;\r
ty2 = y4 - 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(x1, y1, x2, y2, x3, y3, tx1, ty1, a2, 1);\r
cdDrawCurve(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(x1, y1, x2, y2, x3, y3, x4, y4, a2, a3);\r
}\r
break;\r
case 7:\r