From: Koichi KAMICHI Date: Thu, 12 Aug 2010 14:11:13 +0000 (+0000) Subject: Added Uroko adjustment function for the pressure between horizontal X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=29b3984040346605db5e694fb4551f2f9a6b2fba;p=chise%2Fkage.git Added Uroko adjustment function for the pressure between horizontal strokes. --- diff --git a/engine/kage.js b/engine/kage.js index 2d6d2ad..69fbee5 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.adjustMage(this.getEachStrokes(glyphData))))))); + this.drawStrokesArray(polygons, this.adjustKirikuchi(this.adjustUroko2(this.adjustUroko(this.adjustKakato(this.adjustTate(this.adjustMage(this.getEachStrokes(glyphData)))))))); } } Kage.prototype.makeGlyph = makeGlyph; @@ -92,6 +92,32 @@ function Kage(size){ } Kage.prototype.adjustUroko = adjustUroko; + function adjustUroko2(strokesArray){ // strokesArray + for(var i = 0; i < strokesArray.length; i++){ + if(strokesArray[i][0] == 1 && strokesArray[i][2] == 0 && strokesArray[i][4] == strokesArray[i][6]){ + var pressure = 0; + for(var j = 0; j < strokesArray.length; j++){ + if(i != j && ( + (strokesArray[j][0] == 1 && strokesArray[j][4] == strokesArray[j][6] && + !(strokesArray[i][3] + 1 > strokesArray[j][5] || strokesArray[i][5] - 1 < strokesArray[j][3]) && + Math.abs(strokesArray[i][4] - strokesArray[j][4]) < this.kAdjustUroko2Length) || + (strokesArray[j][0] == 3 && strokesArray[j][6] == strokesArray[j][8] && + !(strokesArray[i][3] + 1 > strokesArray[j][7] || strokesArray[i][5] - 1 < strokesArray[j][5]) && + Math.abs(strokesArray[i][4] - strokesArray[j][6]) < this.kAdjustUroko2Length) + )){ + pressure += Math.pow(this.kAdjustUroko2Length - Math.abs(strokesArray[i][4] - strokesArray[j][6]), 1.1); + } + } + var result = Math.min(Math.floor(pressure / this.kAdjustUroko2Length), this.kAdjustUroko2Step) * 100; + if(strokesArray[i][2] < result){ + strokesArray[i][2] = strokesArray[i][2] % 100 + Math.min(Math.floor(pressure / this.kAdjustUroko2Length), this.kAdjustUroko2Step) * 100; + } + } + } + return strokesArray; + } + Kage.prototype.adjustUroko2 = adjustUroko2; + function adjustTate(strokesArray){ // strokesArray for(var i = 0; i < strokesArray.length; i++){ if((strokesArray[i][0] == 1 || strokesArray[i][0] == 3 || strokesArray[i][0] == 7) && strokesArray[i][3] == strokesArray[i][5]){ @@ -302,6 +328,9 @@ function Kage(size){ this.kAdjustUrokoLengthStep = 3; // number of steps this.kAdjustUrokoLine = ([22, 26, 30]); // check for crossing. corresponds to length + this.kAdjustUroko2Step = 3; + this.kAdjustUroko2Length = 40; + this.kAdjustTateStep = 4; this.kAdjustMageStep = 5;