From: Koichi KAMICHI Date: Sat, 30 Jun 2007 02:31:15 +0000 (+0000) Subject: Added some comments. X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=80a7582df6567e87fe2ba555eef9b671e3efc108;p=chise%2Fkage.git Added some comments. --- diff --git a/engine/kagecd.js b/engine/kagecd.js index 9d69aed..a30ac26 100755 --- a/engine/kagecd.js +++ b/engine/kagecd.js @@ -1,3 +1,5 @@ +// may be it can join 3curve and 4curve. the difference is may be only calculating x,y,ix,iy + function cdDrawBezier(kage, polygons, x1, y1, x2, y2, x3, y3, x4, y4, a1, a2){ var rad, t; var x, y, v; @@ -15,7 +17,7 @@ function cdDrawBezier(kage, polygons, x1, y1, x2, y2, x3, y3, x4, y4, a1, a2){ delta = -1 * kage.kMinWidthY * 0.5; break; case 1: - case 2: + case 2: // must be 32 case 6: case 22: delta = 0; @@ -49,9 +51,9 @@ function cdDrawBezier(kage, polygons, x1, y1, x2, y2, x3, y3, x4, y4, a1, a2){ case 8: case 7: case 9: - case 15: - case 14: - case 17: + case 15: // it can change to 15->5 + case 14: // it can change to 14->4 + case 17: // no need case 5: delta = 0; break; @@ -244,7 +246,7 @@ function cdDrawBezier(kage, polygons, x1, y1, x2, y2, x3, y3, x4, y4, a1, a2){ XX = Math.cos(rad) * v; XY = Math.sin(rad) * v; - if(a2 == 1 || a2 == 8 || a2 == 15){ //the last filled circle + if(a2 == 1 || a2 == 8 || a2 == 15){ //the last filled circle ... it can change to 15->5 if(x3 == x4){ poly = Polygon(); poly.push(x4 - kage.kMinWidthT, y4); @@ -293,7 +295,7 @@ function cdDrawBezier(kage, polygons, x1, y1, x2, y2, x3, y3, x4, y4, a1, a2){ } } - if(a2 == 15){ //jump up + if(a2 == 15){ //jump up ... it can change to 15->5 if(y3 == y4){ poly = new Polygon(); poly.push(x4, y4 - kage.kMinWidthT + 1); @@ -315,7 +317,7 @@ function cdDrawBezier(kage, polygons, x1, y1, x2, y2, x3, y3, x4, y4, a1, a2){ } } - if(a2 == 14){ //jump to left, allways go left + if(a2 == 14){ //jump to left, allways go left ... it can change to 14->4 poly = new Polygon(); poly.push(x4, y4); poly.push(x4, y4 - kage.kMinWidthT); @@ -485,7 +487,7 @@ function cdDrawCurve(kage, polygons, x1, y1, x2, y2, x3, y3, a1, a2){ delta = -1 * kage.kMinWidthY * 0.5; break; case 1: - case 2: + case 2: // ... must be 32 case 6: case 22: delta = 0; @@ -518,9 +520,9 @@ function cdDrawCurve(kage, polygons, x1, y1, x2, y2, x3, y3, a1, a2){ case 1: case 7: case 9: - case 15: - case 14: - case 17: + case 15: // it can change to 15->5 + case 14: // it can change to 14->4 + case 17: // no need case 5: delta = 0; break; @@ -640,7 +642,7 @@ function cdDrawCurve(kage, polygons, x1, y1, x2, y2, x3, y3, a1, a2){ } } else{ //bottom to up - if(x1 == x2){ //is it right? + if(x1 == x2){ //is it right? ... no need poly = new Polygon(); poly.push(x1 - kage.kMinWidthT, y1); poly.push(x1 + kage.kMinWidthT, y1); @@ -720,7 +722,7 @@ function cdDrawCurve(kage, polygons, x1, y1, x2, y2, x3, y3, a1, a2){ XX = Math.cos(rad) * v; XY = Math.sin(rad) * v; - if(a2 == 1 || a2 == 8 || a2 == 15){ //the last filled circle + if(a2 == 1 || a2 == 8 || a2 == 15){ //the last filled circle ... it can change 15->5 if(x2 == x3){ poly = new Polygon(); poly.push(x3 - kage.kMinWidthT, y3); @@ -752,7 +754,7 @@ function cdDrawCurve(kage, polygons, x1, y1, x2, y2, x3, y3, a1, a2){ } } - if(a2 == 9 || (a1 == 7 && a2 == 0)){ // Math.sinnyu & L2RD Harai + if(a2 == 9 || (a1 == 7 && a2 == 0)){ // Math.sinnyu & L2RD Harai ... no need for a2=9 if(y2 == y3){ poly = new Polygon(); poly.push(x3, y3 + kage.kMinWidthT * kage.kL2RDfatten); @@ -770,7 +772,7 @@ function cdDrawCurve(kage, polygons, x1, y1, x2, y2, x3, y3, a1, a2){ } } - if(a2 == 15){ //jump up + if(a2 == 15){ //jump up ... it can change 15->5 if(y2 == y3){ poly = new Polygon(); poly.push(x3, y3 - kage.kMinWidthT + 1); @@ -792,7 +794,7 @@ function cdDrawCurve(kage, polygons, x1, y1, x2, y2, x3, y3, a1, a2){ } } - if(a2 == 14){ //jump to left, allways go left + if(a2 == 14){ //jump to left, allways go left ... it can change 14->4 poly = new Polygon(); poly.push(x3, y3); poly.push(x3, y3 - kage.kMinWidthT); @@ -969,7 +971,7 @@ function cdDrawLine(kage, polygons, tx1, ty1, tx2, ty2, ta1, ta2){ poly.set(0, x1 + kage.kMinWidthT, y1 + kage.kMinWidthY / 2); break; case 1: - case 6: + case 6: //... no need case 22: poly.set(3, x1 - kage.kMinWidthT, y1); poly.set(0, x1 + kage.kMinWidthT, y1); @@ -986,7 +988,7 @@ function cdDrawLine(kage, polygons, tx1, ty1, tx2, ty2, ta1, ta2){ switch(a2){ case 0: - if(a1 == 6){ //KAGI's tail + if(a1 == 6){ //KAGI's tail ... no need poly.set(2, x2 - kage.kMinWidthT, y2); poly.set(1, x2 + kage.kMinWidthT, y2); } @@ -1033,7 +1035,7 @@ function cdDrawLine(kage, polygons, tx1, ty1, tx2, ty2, ta1, ta2){ polygons.push(poly); } - if((a1 == 6 && a2 == 0) || a2 == 1){ //KAGI NO YOKO BOU NO SAIGO NO MARU + if((a1 == 6 && a2 == 0) || a2 == 1){ //KAGI NO YOKO BOU NO SAIGO NO MARU ... no need only used at 1st=yoko poly = new Polygon(); poly.push(x2 - kage.kMinWidthT, y2); poly.push(x2 - kage.kMinWidthT * 0.6, y2 + kage.kMinWidthT * 0.6); @@ -1053,7 +1055,7 @@ function cdDrawLine(kage, polygons, tx1, ty1, tx2, ty2, ta1, ta2){ poly.push(x1, y1 + kage.kMinWidthT); polygons.push(poly); - if(a2 == 1 || a2 == 0 || a2 == 5){ + if(a2 == 1 || a2 == 0 || a2 == 5){ // no need a2=1 //KAGI NO YOKO BOU NO SAIGO NO MARU poly = new Polygon(); poly.push(x2, y2 - kage.kMinWidthT); @@ -1194,7 +1196,7 @@ function cdDrawLine(kage, polygons, tx1, ty1, tx2, ty2, ta1, ta2){ y2 + Math.cos(rad) * kage.kMinWidthT * v + kage.kMinWidthT * 0.5 * Math.sin(rad) * v); } break; - case 1: + case 1: // is needed? case 5: poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthT * v, y2 - Math.cos(rad) * kage.kMinWidthT * v); poly.set(2, x2 - Math.sin(rad) * kage.kMinWidthT * v, y2 + Math.cos(rad) * kage.kMinWidthT * v); diff --git a/engine/kagedf.js b/engine/kagedf.js index 486ac99..8e0232e 100755 --- a/engine/kagedf.js +++ b/engine/kagedf.js @@ -3,7 +3,7 @@ function dfDrawFont(kage, polygons, a1, a2, a3, x1, y1, x2, y2, x3, y3, x4, y4){ var rad; if(kage.kShotai == kage.kMincho){ - switch(a1 % 100){ + switch(a1 % 100){ // ... no need to divide case 0: break; case 1: @@ -13,7 +13,7 @@ function dfDrawFont(kage, polygons, a1, a2, a3, x1, y1, x2, y2, x3, y3, x4, y4){ tx1 = x2; ty1 = y2 - kage.kMage * v; } - else if(y1 == y2){ + else if(y1 == y2){ // ... no need if(x1 < x2){ v = 1; } else{ v = -1; } tx1 = x2 - kage.kMage * v; ty1 = y2; @@ -32,7 +32,7 @@ function dfDrawFont(kage, polygons, a1, a2, a3, x1, y1, x2, y2, x3, y3, x4, y4){ } break; case 2: - case 12: + //case 12: // ... no need if(a3 == 4){ if(x2 == x3){ tx1 = x3; @@ -94,8 +94,8 @@ function dfDrawFont(kage, polygons, a1, a2, a3, x1, y1, x2, y2, x3, y3, x4, y4){ } tx3 = x3 - kage.kMage; ty3 = y3; - tx4 = x3 + kage.kMage * 0.5; - ty4 = y3 - kage.kMage * 2; + tx4 = x3 + kage.kMage * 0.5; // ... not used + ty4 = y3 - kage.kMage * 2; // ... not used cdDrawLine(kage, polygons, x1, y1, tx1, ty1, a2, 1); cdDrawCurve(kage, polygons, tx1, ty1, x2, y2, tx2, ty2, 1, 1); @@ -139,6 +139,92 @@ function dfDrawFont(kage, polygons, a1, a2, a3, x1, y1, x2, y2, x3, y3, x4, y4){ cdDrawLine(kage, polygons, tx2, ty2, x3, y3, 6, a3); // bolder by force } break; + case 12: + cdDrawCurve(kage, polygons, x1, y1, x2, y2, x3, y3, a2, 1); + cdDrawLine(kage, polygons, x3, y3, x4, y4, 6, a3); + break; + case 13: +rate = 6; + if(a3 == 5){ + if(x1 == x2){ + if(y1 < y2){ v = 1; } else{ v = -1; } + tx1 = x2; + ty1 = y2 - kage.kMage * v * rate; + } + else if(y1 == y2){ + if(x1 < x2){ v = 1; } else{ v = -1; } + tx1 = x2 - kage.kMage * v * rate; + ty1 = y2; + } + else{ + rad = Math.atan((y2 - y1) / (x2 - x1)); + if(x1 < x2){ v = 1; } else{ v = -1; } + tx1 = x2 - kage.kMage * Math.cos(rad) * v * rate; + ty1 = y2 - kage.kMage * Math.sin(rad) * v * rate; + } + if(x2 == x3){ + if(y2 < y3){ v = 1; } else{ v = -1; } + tx2 = x2; + ty2 = y2 + kage.kMage * v * rate; + } + else if(y2 == y3){ + if(x2 < x3){ v = 1; } else { v = -1; } + tx2 = x2 + kage.kMage * v * rate; + ty2 = y2; + } + else{ + rad = Math.atan((y3 - y2) / (x3 - x2)); + if(x2 < x3){ v = 1; } else{ v = -1; } + tx2 = x2 + kage.kMage * Math.cos(rad) * v * rate; + ty2 = y2 + kage.kMage * Math.sin(rad) * v * rate; + } + tx3 = x3 - kage.kMage; + ty3 = y3; + tx4 = x3 + kage.kMage * 0.5; // ... not used + ty4 = y3 - kage.kMage * 2; // ... not used + + cdDrawLine(kage, polygons, x1, y1, tx1, ty1, a2, 1); + cdDrawCurve(kage, polygons, tx1, ty1, x2, y2, tx2, ty2, 1, 1); + cdDrawLine(kage, polygons, tx2, ty2, tx3, ty3, 6, 5); // bolder by force + } + else{ + if(x1 == x2){ + if(y1 < y2){ v = 1; } else { v = -1; } + tx1 = x2; + ty1 = y2 - kage.kMage * v * rate; + } + else if(y1 == y2){ + if(x1 < x2){ v = 1; } else{ v = -1; } + tx1 = x2 - kage.kMage * v * rate; + ty1 = y2; + } + else{ + rad = Math.atan((y2 - y1) / (x2 - x1)); + if(x1 < x2){ v = 1; } else{ v = -1; } + tx1 = x2 - kage.kMage * Math.cos(rad) * v * rate; + ty1 = y2 - kage.kMage * Math.sin(rad) * v * rate; + } + if(x2 == x3){ + if(y2 < y3){ v = 1; } else{ v = -1; } + tx2 = x2; + ty2 = y2 + kage.kMage * v * rate; + } + else if(y2 == y3){ + if(x2 < x3){ v = 1; } else{ v = -1; } + tx2 = x2 + kage.kMage * v * rate; + ty2 = y2; + } + else{ + rad = Math.atan((y3 - y2) / (x3 - x2)); + if(x2 < x3){ v = 1; } else{ v = -1; } + tx2 = x2 + kage.kMage * Math.cos(rad) * v * rate; + ty2 = y2 + kage.kMage * Math.sin(rad) * v * rate; + } + cdDrawLine(kage, polygons, x1, y1, tx1, ty1, a2, 1); + cdDrawCurve(kage, polygons, tx1, ty1, x2, y2, tx2, ty2, 1, 1); + cdDrawLine(kage, polygons, tx2, ty2, x3, y3, 6, a3); // bolder by force + } + break; case 6: if(a3 == 5){ /* only implimented for gothic @@ -175,9 +261,9 @@ function dfDrawFont(kage, polygons, a1, a2, a3, x1, y1, x2, y2, x3, y3, x4, y4){ break; case 7: cdDrawLine(kage, polygons, x1, y1, x2, y2, a2, 1); - cdDrawCurve(kage, polygons, x2, y2, x3, y3, x4, y4, 1, 7); + cdDrawCurve(kage, polygons, x2, y2, x3, y3, x4, y4, 1, a3); break; - case 9: // may not be exist + case 9: // may not be exist ... no need //kageCanvas[y1][x1] = 0; //kageCanvas[y2][x2] = 0; break;