From: kamichi Date: Wed, 2 Jan 2013 11:13:54 +0000 (+0900) Subject: support HANE adjustment function X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f3ff5fe9ffbc03e03a570dc7230fe3c729a9b98;p=chise%2Fkage.git support HANE adjustment function --- diff --git a/engine/kage.js b/engine/kage.js index 69fbee5..e6dda8c 100755 --- a/engine/kage.js +++ b/engine/kage.js @@ -3,7 +3,7 @@ function Kage(size){ function makeGlyph(polygons, buhin){ // void var glyphData = this.kBuhin.search(buhin); if(glyphData != ""){ - this.drawStrokesArray(polygons, this.adjustKirikuchi(this.adjustUroko2(this.adjustUroko(this.adjustKakato(this.adjustTate(this.adjustMage(this.getEachStrokes(glyphData)))))))); + this.drawStrokesArray(polygons, this.adjustKirikuchi(this.adjustUroko2(this.adjustUroko(this.adjustKakato(this.adjustTate(this.adjustMage(this.adjustHane(this.getEachStrokes(glyphData))))))))); } } Kage.prototype.makeGlyph = makeGlyph; @@ -63,6 +63,38 @@ function Kage(size){ } Kage.prototype.getEachStrokesOfBuhin = getEachStrokesOfBuhin; + function adjustHane(sa){ // strokesArray + for(var i = 0; i < sa.length; i++){ + if((sa[i][0] == 1 || sa[i][0] == 2) && sa[i][2] == 4){ + var lpx; // lastPointX + var lpy; // lastPointY + if(sa[i][0] == 1){ + lpx = sa[i][5]; + lpy = sa[i][6]; + } else { + lpx = sa[i][7]; + lpy = sa[i][8]; + } + var mn = Infinity; // mostNear + if(lpx + 18 < 100){ + mn = lpx + 18; + } + for(var j = 0; j < sa.length; j++){ + if(i != j && sa[j][0] == 1 && sa[j][3] == sa[j][5] && sa[j][4] <= lpy && sa[j][6] >= lpy){ + if(lpx - sa[j][3] < 900){ + mn = Math.min(mn, lpx - sa[j][3]); + } + } + } + if(mn != Infinity){ + sa[i][2] += Math.min(400, 400 - Math.floor(mn / 20) * 100); // 0-8 -> 0-400 + } + } + } + return sa; + } + Kage.prototype.adjustHane = adjustHane; + function adjustUroko(strokesArray){ // strokesArray for(var i = 0; i < strokesArray.length; i++){ if(strokesArray[i][0] == 1 && strokesArray[i][2] == 0){ // no operation for TATE diff --git a/engine/kagecd.js b/engine/kagecd.js index a6e4bbf..914cdbb 100755 --- a/engine/kagecd.js +++ b/engine/kagecd.js @@ -616,8 +616,8 @@ function cdDrawCurveU(kage, polygons, x1, y1, sx1, sy1, sx2, sy2, x2, y2, ta1, t poly = new Polygon(); poly.push(x2, y2); poly.push(x2, y2 - kMinWidthT); - poly.push(x2 - kage.kWidth * 4 * Math.pow(kMinWidthT / kage.kMinWidthT, 3), y2 - kMinWidthT); - poly.push(x2 - kage.kWidth * 4 * Math.pow(kMinWidthT / kage.kMinWidthT, 3), y2 - kMinWidthT * 0.5); + poly.push(x2 - kage.kWidth * 4 * Math.min(1 - opt2 / 10, Math.pow(kMinWidthT / kage.kMinWidthT, 3)), y2 - kMinWidthT); + poly.push(x2 - kage.kWidth * 4 * Math.min(1 - opt2 / 10, Math.pow(kMinWidthT / kage.kMinWidthT, 3)), y2 - kMinWidthT * 0.5); //poly.reverse(); polygons.push(poly); } diff --git a/engine/kagedf.js b/engine/kagedf.js index 3acbe29..c420387 100755 --- a/engine/kagedf.js +++ b/engine/kagedf.js @@ -7,7 +7,7 @@ function dfDrawFont(kage, polygons, a1, a2, a3, x1, y1, x2, y2, x3, y3, x4, y4){ case 0: break; case 1: - if(a3 == 4){ + if(a3 % 100 == 4){ if(x1 == x2){ if(y1 < y2){ v = 1; } else{ v = -1; } tx1 = x2; @@ -25,7 +25,7 @@ function dfDrawFont(kage, polygons, a1, a2, a3, x1, y1, x2, y2, x3, y3, x4, y4){ ty1 = y2 - kage.kMage * Math.sin(rad) * v; } cdDrawLine(kage, polygons, x1, y1, tx1, ty1, a2, 1); - cdDrawCurve(kage, polygons, tx1, ty1, x2, y2, x2 - kage.kMage * (((kage.kAdjustTateStep + 4) - Math.floor(a2 / 1000)) / (kage.kAdjustTateStep + 4)), y2, 1 + (a2 - a2 % 1000), 14); + cdDrawCurve(kage, polygons, tx1, ty1, x2, y2, x2 - kage.kMage * (((kage.kAdjustTateStep + 4) - Math.floor(a2 / 1000)) / (kage.kAdjustTateStep + 4)), y2, 1 + (a2 - a2 % 1000), a3 + 10); } else{ cdDrawLine(kage, polygons, x1, y1, x2, y2, a2, a3); @@ -33,7 +33,7 @@ function dfDrawFont(kage, polygons, a1, a2, a3, x1, y1, x2, y2, x3, y3, x4, y4){ break; case 2: //case 12: // ... no need - if(a3 == 4){ + if(a3 % 100 == 4){ if(x2 == x3){ tx1 = x3; ty1 = y3 - kage.kMage; @@ -49,7 +49,7 @@ function dfDrawFont(kage, polygons, a1, a2, a3, x1, y1, x2, y2, x3, y3, x4, y4){ ty1 = y3 - kage.kMage * Math.sin(rad) * v; } cdDrawCurve(kage, polygons, x1, y1, x2, y2, tx1, ty1, a2, 1); - cdDrawCurve(kage, polygons, tx1, ty1, x3, y3, x3 - kage.kMage, y3, 1, 14); + cdDrawCurve(kage, polygons, tx1, ty1, x3, y3, x3 - kage.kMage, y3, 1, a3 + 10); } else if(a3 == 5){ cdDrawCurve(kage, polygons, x1, y1, x2, y2, x3, y3, a2, 15);