From: Koichi KAMICHI Date: Thu, 12 Aug 2010 09:06:48 +0000 (+0000) Subject: Supports width adjustment of MAGE's tail. X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=37700e64310e47334ff6c77556ae2f83ec23fbb2;p=chise%2Fkage.git Supports width adjustment of MAGE's tail. --- diff --git a/engine/curve.js b/engine/curve.js index d7be0b6..7acb013 100644 --- a/engine/curve.js +++ b/engine/curve.js @@ -125,7 +125,7 @@ function find_offcurve(kage, curve, sx, sy, result){ } // ------------------------------------------------------------------ -function get_candidate(kage, curve, a1, a2, x1, y1, sx1, sy1, x2, y2, opt3){ +function get_candidate(kage, curve, a1, a2, x1, y1, sx1, sy1, x2, y2, opt3, opt4){ var x, y, ix, iy, ir, ia, ib, tt, t, deltad; var hosomi = 0.5; @@ -167,7 +167,7 @@ function get_candidate(kage, curve, a1, a2, x1, y1, sx1, sy1, x2, y2, opt3){ deltad = Math.pow(1.0 - t, hosomi); } else if(opt3 > 0){ - deltad = ((kage.kMinWidthT - opt3 / 2) / kage.kMinWidthT) + opt3 / 2 / kage.kMinWidthT * t; + deltad = (((kage.kMinWidthT - opt4 / 2) - opt3 / 2) / (kage.kMinWidthT - opt4 / 2)) + opt3 / 2 / (kage.kMinWidthT - opt4) * t; } else{ deltad = 1; } diff --git a/engine/kage.js b/engine/kage.js index 743186e..2d6d2ad 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.adjustUroko(this.adjustKakato(this.adjustTate(this.getEachStrokes(glyphData)))))); + this.drawStrokesArray(polygons, this.adjustKirikuchi(this.adjustUroko(this.adjustKakato(this.adjustTate(this.adjustMage(this.getEachStrokes(glyphData))))))); } } Kage.prototype.makeGlyph = makeGlyph; @@ -98,8 +98,8 @@ function Kage(size){ for(var j = 0; j < strokesArray.length; j++){ if(i != j && (strokesArray[j][0] == 1 || strokesArray[j][0] == 3 || strokesArray[j][0] == 7) && strokesArray[j][3] == strokesArray[j][5] && !(strokesArray[i][4] + 1 > strokesArray[j][6] || strokesArray[i][6] - 1 < strokesArray[j][4]) && - Math.abs(strokesArray[i][3] - strokesArray[j][3]) < this.kMinWidthT * 4){ - strokesArray[i][1] += (4 - Math.floor(Math.abs(strokesArray[i][3] - strokesArray[j][3]) / this.kMinWidthT)) * 1000; + Math.abs(strokesArray[i][3] - strokesArray[j][3]) < this.kMinWidthT * this.kAdjustTateStep){ + strokesArray[i][1] += (this.kAdjustTateStep - Math.floor(Math.abs(strokesArray[i][3] - strokesArray[j][3]) / this.kMinWidthT)) * 1000; if(strokesArray[i][1] > this.kAdjustTateStep * 1000){ strokesArray[i][1] = strokesArray[i][1] % 1000 + this.kAdjustTateStep * 1000; } @@ -111,6 +111,30 @@ function Kage(size){ } Kage.prototype.adjustTate = adjustTate; + function adjustMage(strokesArray){ // strokesArray + for(var i = 0; i < strokesArray.length; i++){ + if((strokesArray[i][0] == 3) && strokesArray[i][6] == strokesArray[i][8]){ + for(var j = 0; j < strokesArray.length; j++){ + if(i != j && ( + (strokesArray[j][0] == 1 && strokesArray[j][4] == strokesArray[j][6] && + !(strokesArray[i][5] + 1 > strokesArray[j][5] || strokesArray[i][7] - 1 < strokesArray[j][3]) && + Math.abs(strokesArray[i][6] - strokesArray[j][4]) < this.kMinWidthT * this.kAdjustMageStep) || + (strokesArray[j][0] == 3 && strokesArray[j][6] == strokesArray[j][8] && + !(strokesArray[i][5] + 1 > strokesArray[j][7] || strokesArray[i][7] - 1 < strokesArray[j][5]) && + Math.abs(strokesArray[i][6] - strokesArray[j][6]) < this.kMinWidthT * this.kAdjustMageStep) + )){ + strokesArray[i][2] += (this.kAdjustMageStep - Math.floor(Math.abs(strokesArray[i][6] - strokesArray[j][6]) / this.kMinWidthT)) * 1000; + if(strokesArray[i][2] > this.kAdjustMageStep * 1000){ + strokesArray[i][2] = strokesArray[i][2] % 1000 + this.kAdjustMageStep * 1000; + } + } + } + } + } + return strokesArray; + } + Kage.prototype.adjustMage = adjustMage; + function adjustKirikuchi(strokesArray){ // strokesArray for(var i = 0; i < strokesArray.length; i++){ if(strokesArray[i][0] == 2 && strokesArray[i][1] == 32 && @@ -279,6 +303,8 @@ function Kage(size){ this.kAdjustUrokoLine = ([22, 26, 30]); // check for crossing. corresponds to length this.kAdjustTateStep = 4; + + this.kAdjustMageStep = 5; } this.kBuhin = new Buhin(); diff --git a/engine/kagecd.js b/engine/kagecd.js index e73e83c..a7dedb5 100755 --- a/engine/kagecd.js +++ b/engine/kagecd.js @@ -9,17 +9,18 @@ function cdDrawCurveU(kage, polygons, x1, y1, sx1, sy1, sx2, sy2, x2, y2, ta1, t var poly, poly2; var hosomi; var kMinWidthT, kMinWidthT2; - var a1, a2, opt1, opt2, opt3; + var a1, a2, opt1, opt2, opt3, opt4; if(kage.kShotai == kage.kMincho){ // mincho a1 = ta1 % 1000; a2 = ta2 % 100; opt1 = Math.floor((ta1 % 10000) / 1000); - opt2 = Math.floor(ta2 / 100); + opt2 = Math.floor((ta2 % 1000) / 100); opt3 = Math.floor(ta1 / 10000); + opt4 = Math.floor(ta2 / 1000); kMinWidthT = kage.kMinWidthT - opt1 / 2; - kMinWidthT2 = kage.kMinWidthT - opt3 / 2; + kMinWidthT2 = kage.kMinWidthT - opt4 / 2; switch(a1 % 100){ case 0: @@ -110,7 +111,7 @@ function cdDrawCurveU(kage, polygons, x1, y1, sx1, sy1, sx2, sy2, x2, y2, ta1, t kage2.kRate = 10; var curve = new Array(2); // L and R - get_candidate(kage2, curve, a1, a2, x1, y1, sx1, sy1, x2, y2, opt3); + get_candidate(kage2, curve, a1, a2, x1, y1, sx1, sy1, x2, y2, opt3, opt4); var dcl12_34 = new Array(2); var dcr12_34 = new Array(2); @@ -176,8 +177,8 @@ function cdDrawCurveU(kage, polygons, x1, y1, sx1, sy1, sx2, sy2, x2, y2, ta1, t else if(a2 == 7){ deltad = Math.pow(1.0 - t, hosomi); } - else if(opt3 > 0){ - deltad = ((kage.kMinWidthT - opt3 / 2) / kage.kMinWidthT) + opt3 / 2 / kage.kMinWidthT * t; + else if(opt3 > 0 || opt4 > 0){ + deltad = ((kage.kMinWidthT - opt3 / 2) - (opt4 - opt3) / 2 * t) / kage.kMinWidthT; } else{ deltad = 1; } @@ -492,18 +493,18 @@ function cdDrawCurveU(kage, polygons, x1, y1, sx1, sy1, sx2, sy2, x2, y2, ta1, t poly = new Polygon(); if(kage.kUseCurve){ // by curve path - poly.push(x2 - kMinWidthT, y2); - poly.push(x2 - kMinWidthT * 0.9, y2 + kMinWidthT * 0.9, 1); - poly.push(x2, y2 + kMinWidthT); - poly.push(x2 + kMinWidthT * 0.9, y2 + kMinWidthT * 0.9, 1); - poly.push(x2 + kMinWidthT, y2); + poly.push(x2 - kMinWidthT2, y2); + poly.push(x2 - kMinWidthT2 * 0.9, y2 + kMinWidthT2 * 0.9, 1); + poly.push(x2, y2 + kMinWidthT2); + poly.push(x2 + kMinWidthT2 * 0.9, y2 + kMinWidthT2 * 0.9, 1); + poly.push(x2 + kMinWidthT2, y2); } else { // by polygon - poly.push(x2 - kMinWidthT, y2); - poly.push(x2 - kMinWidthT * 0.7, y2 + kMinWidthT * 0.7); - poly.push(x2, y2 + kMinWidthT); - poly.push(x2 + kMinWidthT * 0.7, y2 + kMinWidthT * 0.7); - poly.push(x2 + kMinWidthT, y2); + poly.push(x2 - kMinWidthT2, y2); + poly.push(x2 - kMinWidthT2 * 0.7, y2 + kMinWidthT2 * 0.7); + poly.push(x2, y2 + kMinWidthT2); + poly.push(x2 + kMinWidthT2 * 0.7, y2 + kMinWidthT2 * 0.7); + poly.push(x2 + kMinWidthT2, y2); } polygons.push(poly); } @@ -511,39 +512,39 @@ function cdDrawCurveU(kage, polygons, x1, y1, sx1, sy1, sx2, sy2, x2, y2, ta1, t poly = new Polygon(); if(kage.kUseCurve){ // by curve path - poly.push(x2, y2 - kMinWidthT); - poly.push(x2 + kMinWidthT * 0.9, y2 - kMinWidthT * 0.9, 1); - poly.push(x2 + kMinWidthT, y2); - poly.push(x2 + kMinWidthT * 0.9, y2 + kMinWidthT * 0.9, 1); - poly.push(x2, y2 + kMinWidthT); + poly.push(x2, y2 - kMinWidthT2); + poly.push(x2 + kMinWidthT2 * 0.9, y2 - kMinWidthT2 * 0.9, 1); + poly.push(x2 + kMinWidthT2, y2); + poly.push(x2 + kMinWidthT2 * 0.9, y2 + kMinWidthT2 * 0.9, 1); + poly.push(x2, y2 + kMinWidthT2); } else { // by polygon - poly.push(x2, y2 - kMinWidthT); - poly.push(x2 + kMinWidthT * 0.7, y2 - kMinWidthT * 0.7); - poly.push(x2 + kMinWidthT, y2); - poly.push(x2 + kMinWidthT * 0.7, y2 + kMinWidthT * 0.7); - poly.push(x2, y2 + kMinWidthT); + poly.push(x2, y2 - kMinWidthT2); + poly.push(x2 + kMinWidthT2 * 0.7, y2 - kMinWidthT2 * 0.7); + poly.push(x2 + kMinWidthT2, y2); + poly.push(x2 + kMinWidthT2 * 0.7, y2 + kMinWidthT2 * 0.7); + poly.push(x2, y2 + kMinWidthT2); } polygons.push(poly); } else{ poly = new Polygon(); if(kage.kUseCurve){ - poly.push(x2 + Math.sin(rad) * kMinWidthT * v, y2 - Math.cos(rad) * kMinWidthT * v); - poly.push(x2 + Math.cos(rad) * kMinWidthT * 0.9 * v + Math.sin(rad) * kMinWidthT * 0.9 * v, - y2 + Math.sin(rad) * kMinWidthT * 0.9 * v - Math.cos(rad) * kMinWidthT * 0.9 * v, 1); - poly.push(x2 + Math.cos(rad) * kMinWidthT * v, y2 + Math.sin(rad) * kMinWidthT * v); - poly.push(x2 + Math.cos(rad) * kMinWidthT * 0.9 * v - Math.sin(rad) * kMinWidthT * 0.9 * v, - y2 + Math.sin(rad) * kMinWidthT * 0.9 * v + Math.cos(rad) * kMinWidthT * 0.9 * v, 1); - poly.push(x2 - Math.sin(rad) * kMinWidthT * v, y2 + Math.cos(rad) * kMinWidthT * v); + poly.push(x2 + Math.sin(rad) * kMinWidthT2 * v, y2 - Math.cos(rad) * kMinWidthT2 * v); + poly.push(x2 + Math.cos(rad) * kMinWidthT2 * 0.9 * v + Math.sin(rad) * kMinWidthT2 * 0.9 * v, + y2 + Math.sin(rad) * kMinWidthT2 * 0.9 * v - Math.cos(rad) * kMinWidthT2 * 0.9 * v, 1); + poly.push(x2 + Math.cos(rad) * kMinWidthT2 * v, y2 + Math.sin(rad) * kMinWidthT2 * v); + poly.push(x2 + Math.cos(rad) * kMinWidthT2 * 0.9 * v - Math.sin(rad) * kMinWidthT2 * 0.9 * v, + y2 + Math.sin(rad) * kMinWidthT2 * 0.9 * v + Math.cos(rad) * kMinWidthT2 * 0.9 * v, 1); + poly.push(x2 - Math.sin(rad) * kMinWidthT2 * v, y2 + Math.cos(rad) * kMinWidthT2 * v); } else { - poly.push(x2 + Math.sin(rad) * kMinWidthT * v, y2 - Math.cos(rad) * kMinWidthT * v); - poly.push(x2 + Math.cos(rad) * kMinWidthT * 0.7 * v + Math.sin(rad) * kMinWidthT * 0.7 * v, - y2 + Math.sin(rad) * kMinWidthT * 0.7 * v - Math.cos(rad) * kMinWidthT * 0.7 * v); - poly.push(x2 + Math.cos(rad) * kMinWidthT * v, y2 + Math.sin(rad) * kMinWidthT * v); - poly.push(x2 + Math.cos(rad) * kMinWidthT * 0.7 * v - Math.sin(rad) * kMinWidthT * 0.7 * v, - y2 + Math.sin(rad) * kMinWidthT * 0.7 * v + Math.cos(rad) * kMinWidthT * 0.7 * v); - poly.push(x2 - Math.sin(rad) * kMinWidthT * v, y2 + Math.cos(rad) * kMinWidthT * v); + poly.push(x2 + Math.sin(rad) * kMinWidthT2 * v, y2 - Math.cos(rad) * kMinWidthT2 * v); + poly.push(x2 + Math.cos(rad) * kMinWidthT2 * 0.7 * v + Math.sin(rad) * kMinWidthT2 * 0.7 * v, + y2 + Math.sin(rad) * kMinWidthT2 * 0.7 * v - Math.cos(rad) * kMinWidthT2 * 0.7 * v); + poly.push(x2 + Math.cos(rad) * kMinWidthT2 * v, y2 + Math.sin(rad) * kMinWidthT2 * v); + poly.push(x2 + Math.cos(rad) * kMinWidthT2 * 0.7 * v - Math.sin(rad) * kMinWidthT2 * 0.7 * v, + y2 + Math.sin(rad) * kMinWidthT2 * 0.7 * v + Math.cos(rad) * kMinWidthT2 * 0.7 * v); + poly.push(x2 - Math.sin(rad) * kMinWidthT2 * v, y2 + Math.cos(rad) * kMinWidthT2 * v); } polygons.push(poly); } @@ -913,13 +914,13 @@ function cdDrawLine(kage, polygons, tx1, ty1, tx2, ty2, ta1, ta2){ poly = new Polygon(); if(x1 < x2){ poly.push(x2, y2 - kMinWidthT + 1); - poly.push(x2 + 2, y2 - kMinWidthT - kage.kWidth * 5); - poly.push(x2, y2 - kMinWidthT - kage.kWidth * 5); + poly.push(x2 + 2, y2 - kMinWidthT - kage.kWidth * (4 * (1 - opt1 / kage.kAdjustMageStep) + 1)); + poly.push(x2, y2 - kMinWidthT - kage.kWidth * (4 * (1 - opt1 / kage.kAdjustMageStep) + 1)); poly.push(x2 - kMinWidthT, y2 - kMinWidthT + 1); } else { poly.push(x2, y2 - kMinWidthT + 1); - poly.push(x2 - 2, y2 - kMinWidthT - kage.kWidth * 5); - poly.push(x2, y2 - kMinWidthT - kage.kWidth * 5); + poly.push(x2 - 2, y2 - kMinWidthT - kage.kWidth * (4 * (1 - opt1 / kage.kAdjustMageStep) + 1)); + poly.push(x2, y2 - kMinWidthT - kage.kWidth * (4 * (1 - opt1 / kage.kAdjustMageStep) + 1)); poly.push(x2 + kMinWidthT, y2 - kMinWidthT + 1); } poly.reverse(); // for fill-rule diff --git a/engine/kagedf.js b/engine/kagedf.js index a6c4838..3acbe29 100755 --- a/engine/kagedf.js +++ b/engine/kagedf.js @@ -59,7 +59,7 @@ function dfDrawFont(kage, polygons, a1, a2, a3, x1, y1, x2, y2, x3, y3, x4, y4){ } break; case 3: - if(a3 == 5){ + if(a3 % 1000 == 5){ if(x1 == x2){ if(y1 < y2){ v = 1; } else{ v = -1; } tx1 = x2; @@ -96,9 +96,9 @@ function dfDrawFont(kage, polygons, a1, a2, a3, x1, y1, x2, y2, x3, y3, x4, y4){ ty3 = y3; cdDrawLine(kage, polygons, x1, y1, tx1, ty1, a2, 1); - cdDrawCurve(kage, polygons, tx1, ty1, x2, y2, tx2, ty2, 1 + (a2 - a2 % 1000) * 10, 1); + cdDrawCurve(kage, polygons, tx1, ty1, x2, y2, tx2, ty2, 1 + (a2 - a2 % 1000) * 10, 1 + (a3 - a3 % 1000)); if((x2 < x3 && tx3 - tx2 > 0) || (x2 > x3 && tx2 - tx3 > 0)){ // for closer position - cdDrawLine(kage, polygons, tx2, ty2, tx3, ty3, 6, 5); // bolder by force + cdDrawLine(kage, polygons, tx2, ty2, tx3, ty3, 6 + (a3 - a3 % 1000), 5); // bolder by force } } else{ @@ -135,8 +135,8 @@ function dfDrawFont(kage, polygons, a1, a2, a3, x1, y1, x2, y2, x3, y3, x4, y4){ ty2 = y2 + kage.kMage * Math.sin(rad) * v; } cdDrawLine(kage, polygons, x1, y1, tx1, ty1, a2, 1); - cdDrawCurve(kage, polygons, tx1, ty1, x2, y2, tx2, ty2, 1 + (a2 - a2 % 1000) * 10, 1); - cdDrawLine(kage, polygons, tx2, ty2, x3, y3, 6, a3); // bolder by force + cdDrawCurve(kage, polygons, tx1, ty1, x2, y2, tx2, ty2, 1 + (a2 - a2 % 1000) * 10, 1 + (a3 - a3 % 1000)); + cdDrawLine(kage, polygons, tx2, ty2, x3, y3, 6 + (a3 - a3 % 1000), a3); // bolder by force } break; case 12: