+// may be it can join 3curve and 4curve. the difference is may be only calculating x,y,ix,iy\r
+\r
function cdDrawBezier(kage, polygons, x1, y1, x2, y2, x3, y3, x4, y4, a1, a2){\r
var rad, t;\r
var x, y, v;\r
delta = -1 * kage.kMinWidthY * 0.5;\r
break;\r
case 1:\r
- case 2:\r
+ case 2: // must be 32\r
case 6:\r
case 22:\r
delta = 0;\r
case 8:\r
case 7:\r
case 9:\r
- case 15:\r
- case 14:\r
- case 17:\r
+ case 15: // it can change to 15->5\r
+ case 14: // it can change to 14->4\r
+ case 17: // no need\r
case 5:\r
delta = 0;\r
break;\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(a2 == 1 || a2 == 8 || a2 == 15){ //the last filled circle ... it can change to 15->5\r
if(x3 == x4){\r
poly = Polygon();\r
poly.push(x4 - kage.kMinWidthT, y4);\r
}\r
}\r
\r
- if(a2 == 15){ //jump up\r
+ if(a2 == 15){ //jump up ... it can change to 15->5\r
if(y3 == y4){\r
poly = new Polygon();\r
poly.push(x4, y4 - kage.kMinWidthT + 1);\r
}\r
}\r
\r
- if(a2 == 14){ //jump to left, allways go left\r
+ if(a2 == 14){ //jump to left, allways go left ... it can change to 14->4\r
poly = new Polygon();\r
poly.push(x4, y4);\r
poly.push(x4, y4 - kage.kMinWidthT);\r
delta = -1 * kage.kMinWidthY * 0.5;\r
break;\r
case 1:\r
- case 2:\r
+ case 2: // ... must be 32\r
case 6:\r
case 22:\r
delta = 0;\r
case 1:\r
case 7:\r
case 9:\r
- case 15:\r
- case 14:\r
- case 17:\r
+ case 15: // it can change to 15->5\r
+ case 14: // it can change to 14->4\r
+ case 17: // no need\r
case 5:\r
delta = 0;\r
break;\r
}\r
}\r
else{ //bottom to up\r
- if(x1 == x2){ //is it right?\r
+ if(x1 == x2){ //is it right? ... no need\r
poly = new Polygon();\r
poly.push(x1 - kage.kMinWidthT, y1);\r
poly.push(x1 + kage.kMinWidthT, y1);\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(a2 == 1 || a2 == 8 || a2 == 15){ //the last filled circle ... it can change 15->5\r
if(x2 == x3){\r
poly = new Polygon();\r
poly.push(x3 - kage.kMinWidthT, y3);\r
}\r
}\r
\r
- if(a2 == 9 || (a1 == 7 && a2 == 0)){ // Math.sinnyu & L2RD Harai\r
+ if(a2 == 9 || (a1 == 7 && a2 == 0)){ // Math.sinnyu & L2RD Harai ... no need for a2=9\r
if(y2 == y3){\r
poly = new Polygon();\r
poly.push(x3, y3 + kage.kMinWidthT * kage.kL2RDfatten);\r
}\r
}\r
\r
- if(a2 == 15){ //jump up\r
+ if(a2 == 15){ //jump up ... it can change 15->5\r
if(y2 == y3){\r
poly = new Polygon();\r
poly.push(x3, y3 - kage.kMinWidthT + 1);\r
}\r
}\r
\r
- if(a2 == 14){ //jump to left, allways go left\r
+ if(a2 == 14){ //jump to left, allways go left ... it can change 14->4\r
poly = new Polygon();\r
poly.push(x3, y3);\r
poly.push(x3, y3 - kage.kMinWidthT);\r
poly.set(0, x1 + kage.kMinWidthT, y1 + kage.kMinWidthY / 2);\r
break;\r
case 1:\r
- case 6:\r
+ case 6: //... no need\r
case 22:\r
poly.set(3, x1 - kage.kMinWidthT, y1);\r
poly.set(0, x1 + kage.kMinWidthT, y1);\r
\r
switch(a2){\r
case 0:\r
- if(a1 == 6){ //KAGI's tail\r
+ if(a1 == 6){ //KAGI's tail ... no need\r
poly.set(2, x2 - kage.kMinWidthT, y2);\r
poly.set(1, x2 + kage.kMinWidthT, y2);\r
}\r
polygons.push(poly);\r
}\r
\r
- if((a1 == 6 && a2 == 0) || a2 == 1){ //KAGI NO YOKO BOU NO SAIGO NO MARU\r
+ if((a1 == 6 && a2 == 0) || a2 == 1){ //KAGI NO YOKO BOU NO SAIGO NO MARU ... no need only used at 1st=yoko\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(x1, y1 + kage.kMinWidthT);\r
polygons.push(poly);\r
\r
- if(a2 == 1 || a2 == 0 || a2 == 5){\r
+ if(a2 == 1 || a2 == 0 || a2 == 5){ // no need a2=1\r
//KAGI NO YOKO BOU NO SAIGO NO MARU\r
poly = new Polygon();\r
poly.push(x2, y2 - kage.kMinWidthT);\r
y2 + Math.cos(rad) * kage.kMinWidthT * v + kage.kMinWidthT * 0.5 * Math.sin(rad) * v);\r
}\r
break;\r
- case 1:\r
+ case 1: // is needed?\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
var rad;\r
\r
if(kage.kShotai == kage.kMincho){\r
- switch(a1 % 100){\r
+ switch(a1 % 100){ // ... no need to divide\r
case 0:\r
break;\r
case 1:\r
tx1 = x2;\r
ty1 = y2 - kage.kMage * v;\r
}\r
- else if(y1 == y2){\r
+ else if(y1 == y2){ // ... no need\r
if(x1 < x2){ v = 1; } else{ v = -1; }\r
tx1 = x2 - kage.kMage * v;\r
ty1 = y2;\r
}\r
break;\r
case 2:\r
- case 12:\r
+ //case 12: // ... no need\r
if(a3 == 4){\r
if(x2 == x3){\r
tx1 = x3;\r
}\r
tx3 = x3 - kage.kMage;\r
ty3 = y3;\r
- tx4 = x3 + kage.kMage * 0.5;\r
- ty4 = y3 - kage.kMage * 2;\r
+ tx4 = x3 + kage.kMage * 0.5; // ... not used\r
+ ty4 = y3 - kage.kMage * 2; // ... not used\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 12:\r
+ cdDrawCurve(kage, polygons, x1, y1, x2, y2, x3, y3, a2, 1);\r
+ cdDrawLine(kage, polygons, x3, y3, x4, y4, 6, a3);\r
+ break;\r
+ case 13:\r
+rate = 6;\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 * rate;\r
+ }\r
+ else if(y1 == y2){\r
+ if(x1 < x2){ v = 1; } else{ v = -1; }\r
+ tx1 = x2 - kage.kMage * v * rate;\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 * rate;\r
+ ty1 = y2 - kage.kMage * Math.sin(rad) * v * rate;\r
+ }\r
+ if(x2 == x3){\r
+ if(y2 < y3){ v = 1; } else{ v = -1; }\r
+ tx2 = x2;\r
+ ty2 = y2 + kage.kMage * v * rate;\r
+ }\r
+ else if(y2 == y3){\r
+ if(x2 < x3){ v = 1; } else { v = -1; }\r
+ tx2 = x2 + kage.kMage * v * rate;\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 * rate;\r
+ ty2 = y2 + kage.kMage * Math.sin(rad) * v * rate;\r
+ }\r
+ tx3 = x3 - kage.kMage;\r
+ ty3 = y3;\r
+ tx4 = x3 + kage.kMage * 0.5; // ... not used\r
+ ty4 = y3 - kage.kMage * 2; // ... not used\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 * rate;\r
+ }\r
+ else if(y1 == y2){\r
+ if(x1 < x2){ v = 1; } else{ v = -1; }\r
+ tx1 = x2 - kage.kMage * v * rate;\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 * rate;\r
+ ty1 = y2 - kage.kMage * Math.sin(rad) * v * rate;\r
+ }\r
+ if(x2 == x3){\r
+ if(y2 < y3){ v = 1; } else{ v = -1; }\r
+ tx2 = x2;\r
+ ty2 = y2 + kage.kMage * v * rate;\r
+ }\r
+ else if(y2 == y3){\r
+ if(x2 < x3){ v = 1; } else{ v = -1; }\r
+ tx2 = x2 + kage.kMage * v * rate;\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 * rate;\r
+ ty2 = y2 + kage.kMage * Math.sin(rad) * v * rate;\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
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
+ cdDrawCurve(kage, polygons, x2, y2, x3, y3, x4, y4, 1, a3);\r
break;\r
- case 9: // may not be exist\r
+ case 9: // may not be exist ... no need\r
//kageCanvas[y1][x1] = 0;\r
//kageCanvas[y2][x2] = 0;\r
break;\r