X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=engine%2Fkage.js;h=2d6d2adbbaf7941af1009a4b5a504426ac2da784;hb=37700e64310e47334ff6c77556ae2f83ec23fbb2;hp=0f7bb6630c32722683ee34d25df9522e0c85411c;hpb=2d7401a0e6d13ee467d9dd0b5cabc16f5b365795;p=chise%2Fkage.git diff --git a/engine/kage.js b/engine/kage.js index 0f7bb66..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; @@ -94,14 +94,14 @@ function Kage(size){ function adjustTate(strokesArray){ // strokesArray for(var i = 0; i < strokesArray.length; i++){ - if((strokesArray[i][0] == 1 || strokesArray[i][3] || strokesArray[i][7]) && strokesArray[i][3] == strokesArray[i][5]){ + if((strokesArray[i][0] == 1 || strokesArray[i][0] == 3 || strokesArray[i][0] == 7) && strokesArray[i][3] == strokesArray[i][5]){ for(var j = 0; j < strokesArray.length; j++){ - if(i != j && (strokesArray[j][0] == 1 || strokesArray[j][3] || strokesArray[j][7]) && strokesArray[j][3] == strokesArray[j][5] && + 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)) * 100; - if(strokesArray[i][1] > this.kAdjustTateStep * 100){ - strokesArray[i][1] = strokesArray[i][1] % 100 + this.kAdjustTateStep * 100; + 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();