From e234fa8ffc3ae5a99194759bf9ff1c25cdcff2f6 Mon Sep 17 00:00:00 2001 From: Koichi KAMICHI Date: Thu, 27 Nov 2008 04:58:47 +0000 Subject: [PATCH] update to the latest files --- engine/kage.js | 21 ++++++++++++++++++++- engine/kagecd.js | 42 +++++++++++++++++++++++++++++++++--------- engine/polygon.js | 15 ++++++++++++++- 3 files changed, 67 insertions(+), 11 deletions(-) diff --git a/engine/kage.js b/engine/kage.js index 0d3f933..cc233c3 100755 --- a/engine/kage.js +++ b/engine/kage.js @@ -3,7 +3,7 @@ function Kage(){ function makeGlyph(polygons, buhin){ // void var glyphData = this.kBuhin.search(buhin); if(glyphData != ""){ - this.drawStrokesArray(polygons, this.adjustUroko(this.adjustKakato(this.getEachStrokes(glyphData)))); + this.drawStrokesArray(polygons, this.adjustKirikuchi(this.adjustUroko(this.adjustKakato(this.getEachStrokes(glyphData))))); } } Kage.prototype.makeGlyph = makeGlyph; @@ -92,6 +92,25 @@ function Kage(){ } Kage.prototype.adjustUroko = adjustUroko; + function adjustKirikuchi(strokesArray){ // strokesArray + for(var i = 0; i < strokesArray.length; i++){ + if(strokesArray[i][0] == 2 && strokesArray[i][1] == 32 && + strokesArray[i][3] > strokesArray[i][5] && + strokesArray[i][4] < strokesArray[i][6]){ + for(var j = 0; j < strokesArray.length; j++){ // no need to skip when i == j + if(strokesArray[j][0] == 1 && + strokesArray[j][3] < strokesArray[i][3] && strokesArray[j][5] > strokesArray[i][3] && + strokesArray[j][4] == strokesArray[i][4] && strokesArray[j][4] == strokesArray[j][6]){ + strokesArray[i][1] = 132; + j = strokesArray.length; + } + } + } + } + return strokesArray; + } + Kage.prototype.adjustKirikuchi = adjustKirikuchi; + function adjustKakato(strokesArray){ // strokesArray for(var i = 0; i < strokesArray.length; i++){ if(strokesArray[i][0] == 1 && diff --git a/engine/kagecd.js b/engine/kagecd.js index a28be90..a3adf0f 100755 --- a/engine/kagecd.js +++ b/engine/kagecd.js @@ -492,7 +492,7 @@ function cdDrawCurve(kage, polygons, x1, y1, x2, y2, x3, y3, a1, a2){ var hosomi; if(kage.kShotai == kage.kMincho){ // mincho - switch(a1){ + switch(a1 % 100){ case 0: case 7: delta = -1 * kage.kMinWidthY * 0.5; @@ -501,10 +501,11 @@ function cdDrawCurve(kage, polygons, x1, y1, x2, y2, x3, y3, a1, a2){ case 2: // ... must be 32 case 6: case 22: + case 32: // changed delta = 0; break; case 12: - case 32: + //case 32: delta = kage.kMinWidthY; break; default: @@ -526,7 +527,7 @@ function cdDrawCurve(kage, polygons, x1, y1, x2, y2, x3, y3, a1, a2){ y1 = y1 - delta * Math.sin(rad) * v; } - switch(a2){ + switch(a2 % 100){ case 0: case 1: case 7: @@ -558,11 +559,11 @@ function cdDrawCurve(kage, polygons, x1, y1, x2, y2, x3, y3, a1, a2){ x3 = x3 + delta * Math.cos(rad) * v; y3 = y3 + delta * Math.sin(rad) * v; } - - hosomi = 0.5; - if(Math.sqrt((x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1)) < 50){ - hosomi += 0.4 * (1 - Math.sqrt((x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1)) / 50); - } + + hosomi = 0.5; + if(Math.sqrt((x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1)) < 50){ + hosomi += 0.4 * (1 - Math.sqrt((x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1)) / 50); + } poly = new Polygon(); poly2 = new Polygon(); @@ -594,7 +595,7 @@ function cdDrawCurve(kage, polygons, x1, y1, x2, y2, x3, y3, a1, a2){ } if(a1 == 7 && a2 == 0){ // L2RD: fatten - deltad = Math.pow(t, hosomi) * kage.kL2RDfatten; + deltad = Math.pow(t, hosomi) * kage.kL2RDfatten; } else if(a1 == 7){ deltad = Math.pow(t, hosomi); @@ -621,6 +622,29 @@ function cdDrawCurve(kage, polygons, x1, y1, x2, y2, x3, y3, a1, a2){ poly2.push(x + ia, y + ib); } + // suiheisen ni setsuzoku + if(a1 == 132){ + var index = 0; + while(true){ + if(poly2.array[index].y <= y1 && y1 <= poly2.array[index + 1].y){ + break; + } + index++; + } + newx1 = poly2.array[index + 1].x + (poly2.array[index].x - poly2.array[index + 1].x) * + (poly2.array[index + 1].y - y1) / (poly2.array[index + 1].y - poly2.array[index].y); + newy1 = y1; + newx2 = poly.array[0].x + (poly.array[0].x - poly.array[1].x) * (poly.array[0].y - y1) / + (poly.array[1].y - poly.array[0].y); + newy2 = y1; + + for(var i = 0; i < index; i++){ + poly2.shift(); + } + poly2.set(0, newx1, newy1); + poly.unshift(newx2, newy2); + } + poly2.reverse(); poly.concat(poly2); polygons.push(poly); diff --git a/engine/polygon.js b/engine/polygon.js index e89ea72..c232460 100755 --- a/engine/polygon.js +++ b/engine/polygon.js @@ -25,7 +25,20 @@ function Polygon(number){ this.array = this.array.concat(poly.array); } Polygon.prototype.concat = concat; - + + function shift(){ // void + this.array.shift(); + } + Polygon.prototype.shift = shift; + + function unshift(x, y){ // void + var temp = new Object(); + temp.x = Math.floor(x*10)/10; + temp.y = Math.floor(y*10)/10; + this.array.unshift(temp); + } + Polygon.prototype.unshift = unshift; + // property this.array = new Array(); -- 1.7.10.4