X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=engine%2Fkage.js;h=c58fda5b0d7f3cea07de0a8269462304f4c9bdd3;hb=45dfe74aad98a359dd6e8a0ad46adcb7b3dcfa66;hp=cc981362583f12050369196e4f22701eca27d28a;hpb=86f379019f3b96c555a60d621fae4263209f4006;p=chise%2Fkage.git diff --git a/engine/kage.js b/engine/kage.js old mode 100755 new mode 100644 index cc98136..c58fda5 --- a/engine/kage.js +++ b/engine/kage.js @@ -2,19 +2,56 @@ function Kage(size){ // method 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.adjustHane(this.getEachStrokes(glyphData))))))))); - } + this.makeGlyph2(polygons, glyphData); } Kage.prototype.makeGlyph = makeGlyph; function makeGlyph2(polygons, data){ // void - if(data != ""){ - this.drawStrokesArray(polygons, this.adjustKirikuchi(this.adjustUroko2(this.adjustUroko(this.adjustKakato(this.adjustTate(this.adjustMage(this.adjustHane(this.getEachStrokes(data))))))))); - } + if(data != ""){ + var strokesArray = this.adjustKirikuchi(this.adjustUroko2(this.adjustUroko(this.adjustKakato(this.adjustTate(this.adjustMage(this.adjustHane(this.getEachStrokes(data)))))))); + for(var i = 0; i < strokesArray.length; i++){ + dfDrawFont(this, polygons, + strokesArray[i][0], + strokesArray[i][1], + strokesArray[i][2], + strokesArray[i][3], + strokesArray[i][4], + strokesArray[i][5], + strokesArray[i][6], + strokesArray[i][7], + strokesArray[i][8], + strokesArray[i][9], + strokesArray[i][10]); + } + } } Kage.prototype.makeGlyph2 = makeGlyph2; + function makeGlyph3(data){ // void + var result = new Array(); + if(data != ""){ + var strokesArray = this.adjustKirikuchi(this.adjustUroko2(this.adjustUroko(this.adjustKakato(this.adjustTate(this.adjustMage(this.adjustHane(this.getEachStrokes(data)))))))); + for(var i = 0; i < strokesArray.length; i++){ + var polygons = new Polygons(); + dfDrawFont(this, polygons, + strokesArray[i][0], + strokesArray[i][1], + strokesArray[i][2], + strokesArray[i][3], + strokesArray[i][4], + strokesArray[i][5], + strokesArray[i][6], + strokesArray[i][7], + strokesArray[i][8], + strokesArray[i][9], + strokesArray[i][10]); + result.push(polygons); + } + } + return result; + } + Kage.prototype.makeGlyph3 = makeGlyph3; + function getEachStrokes(glyphData){ // strokes array var strokesArray = new Array(); var strokes = glyphData.split("$"); @@ -43,7 +80,9 @@ function Kage(size){ Math.floor(columns[5]), Math.floor(columns[6]), Math.floor(columns[1]), - Math.floor(columns[2])) + Math.floor(columns[2]), + Math.floor(columns[9]), + Math.floor(columns[10])) ); } } @@ -52,27 +91,31 @@ function Kage(size){ } Kage.prototype.getEachStrokes = getEachStrokes; - function getEachStrokesOfBuhin(buhin, x1, y1, x2, y2, a1, a2){ + function getEachStrokesOfBuhin(buhin, x1, y1, x2, y2, sx, sy, sx2, sy2){ var temp = this.getEachStrokes(buhin); var result = new Array(); - var box = getBox(buhin); + var box = this.getBox(buhin); + if(sx != 0 || sy != 0){ + if(sx > 100){ + sx -= 200; // Ǥ°ÕÅÀ¥â¡¼¥É + } else { + sx2 = 0; // Ãæ¿´ÅÀ¥â¡¼¥É + sy2 = 0; + } + } for(var i = 0; i < temp.length; i++){ - - var sx = a1; - var sy = a2; if(sx != 0 || sy != 0){ - temp[i][3] = stretch(sx, temp[i][3], box.minX, box.maxX); - temp[i][4] = stretch(sy, temp[i][4], box.minY, box.maxY); - temp[i][5] = stretch(sx, temp[i][5], box.minX, box.maxX); - temp[i][6] = stretch(sy, temp[i][6], box.minY, box.maxY); + temp[i][3] = stretch(sx, sx2, temp[i][3], box.minX, box.maxX); + temp[i][4] = stretch(sy, sy2, temp[i][4], box.minY, box.maxY); + temp[i][5] = stretch(sx, sx2, temp[i][5], box.minX, box.maxX); + temp[i][6] = stretch(sy, sy2,temp[i][6], box.minY, box.maxY); if(temp[i][0] != 99){ - temp[i][7] = stretch(sx, temp[i][7], box.minX, box.maxX); - temp[i][8] = stretch(sy, temp[i][8], box.minY, box.maxY); + temp[i][7] = stretch(sx, sx2, temp[i][7], box.minX, box.maxX); + temp[i][8] = stretch(sy, sy2, temp[i][8], box.minY, box.maxY); + temp[i][9] = stretch(sx, sx2, temp[i][9], box.minX, box.maxX); + temp[i][10] = stretch(sy, sy2, temp[i][10], box.minY, box.maxY); } - temp[i][9] = stretch(sx, temp[i][9], box.minX, box.maxX); - temp[i][10] = stretch(sy, temp[i][10], box.minY, box.maxY); } - result.push([temp[i][0], temp[i][1], temp[i][2], @@ -264,54 +307,6 @@ function Kage(size){ } Kage.prototype.adjustKakato = adjustKakato; - function drawStrokesArray(polygons, strokesArray){ - for(var i = 0; i < strokesArray.length; i++){ - dfDrawFont(this, polygons, - strokesArray[i][0], - strokesArray[i][1], - strokesArray[i][2], - strokesArray[i][3], - strokesArray[i][4], - strokesArray[i][5], - strokesArray[i][6], - strokesArray[i][7], - strokesArray[i][8], - strokesArray[i][9], - strokesArray[i][10]); - } - } - Kage.prototype.drawStrokesArray = drawStrokesArray; - - function drawGlyph(polygons, glyph){ // void - // [glyph] : [stroke]$[stroke]$..... - // [stroke] : [column]:[column]:..... - var strokes = glyph.split("$"); - for(var i = 0; i < strokes.length; i++){ - var columns = strokes[i].split(":"); - if(Math.floor(columns[0]) != 99){ - dfDrawFont(this, polygons, - Math.floor(columns[0]), - Math.floor(columns[1]), Math.floor(columns[2]), - Math.floor(columns[3]), Math.floor(columns[4]), - Math.floor(columns[5]), Math.floor(columns[6]), - Math.floor(columns[7]), Math.floor(columns[8]), - Math.floor(columns[9]), Math.floor(columns[10])); - } else { - var buhin = this.kBuhin.search(columns[7]); - if(buhin != ""){ - this.drawBuhin(polygons, buhin, - Math.floor(columns[3]), - Math.floor(columns[4]), - Math.floor(columns[5]), - Math.floor(columns[6]), - Math.floor(columns[1]), - Math.floor(columns[2])); - } - } - } - } - Kage.prototype.drawGlyph = drawGlyph; - function getBox(glyph){ // minX, minY, maxX, maxY var a = new Object(); a.minX = 200; @@ -319,7 +314,7 @@ function Kage(size){ a.maxX = 0; a.maxY = 0; - var strokes = getEachStrokes(glyph); + var strokes = this.getEachStrokes(glyph); for(var i = 0; i < strokes.length; i++){ if(strokes[i][0] == 0){ continue; } a.minX = Math.min(a.minX, strokes[i][3]); @@ -338,6 +333,7 @@ function Kage(size){ a.maxY = Math.max(a.maxY, strokes[i][8]); if(strokes[i][0] == 2){ continue; } if(strokes[i][0] == 3){ continue; } + if(strokes[i][0] == 4){ continue; } a.minX = Math.min(a.minX, strokes[i][9]); a.maxX = Math.max(a.maxX, strokes[i][9]); a.minY = Math.min(a.minY, strokes[i][10]); @@ -347,71 +343,23 @@ function Kage(size){ } Kage.prototype.getBox = getBox; - function stretch(dp, sp, min, max){ // interger + function stretch(dp, sp, p, min, max){ // interger var p1, p2, p3, p4; - if(sp < 100){ + if(p < sp + 100){ p1 = min; p3 = min; - p2 = 100; - p4 = 100 + dp; + p2 = sp + 100; + p4 = dp + 100; } else { - p1 = 100; - p3 = 100 + dp; + p1 = sp + 100; + p3 = dp + 100; p2 = max; p4 = max; } - return Math.floor(((sp - p1) / (p2 - p1)) * (p4 - p3) + p3); + return Math.floor(((p - p1) / (p2 - p1)) * (p4 - p3) + p3); } Kage.prototype.stretch = stretch; - function drawBuhin(polygons, glyph, x1, y1, x2, y2, sx, sy){ // void - var strokes = glyph.split("$"); - var box = getBox(glyph); - for(var i = 0; i < strokes.length; i++){ - var columns = strokes[i].split(":"); - - if(sx != 0 || sy != 0){ - columns[3] = stretch(sx, columns[3], box.minX, box.maxX); - columns[4] = stretch(sy, columns[4], box.minY, box.maxY); - columns[5] = stretch(sx, columns[5], box.minX, box.maxX); - columns[6] = stretch(sy, columns[6], box.minY, box.maxY); - if(columns[0] != 99){ - columns[7] = stretch(sx, columns[7], box.minX, box.maxX); - columns[8] = stretch(sy, columns[8], box.minY, box.maxY); - } - columns[9] = stretch(sx, columns[9], box.minX, box.maxX); - columns[10] = stretch(sy, columns[10], box.minY, box.maxY); - } - - if(Math.floor(columns[0]) != 99){ - dfDrawFont(this, polygons, - Math.floor(columns[0]), - Math.floor(columns[1]), - Math.floor(columns[2]), - x1 + Math.floor(columns[3]) * (x2 - x1) / 200, - y1 + Math.floor(columns[4]) * (y2 - y1) / 200, - x1 + Math.floor(columns[5]) * (x2 - x1) / 200, - y1 + Math.floor(columns[6]) * (y2 - y1) / 200, - x1 + Math.floor(columns[7]) * (x2 - x1) / 200, - y1 + Math.floor(columns[8]) * (y2 - y1) / 200, - x1 + Math.floor(columns[9]) * (x2 - x1) / 200, - y1 + Math.floor(columns[10]) * (y2 - y1) / 200); - } else { - var buhin = this.kBuhin.search(columns[7]); - if(buhin != ""){ - this.drawBuhin(polygons, buhin, - x1 + Math.floor(columns[3]) * (x2 - x1) / 200, - y1 + Math.floor(columns[4]) * (y2 - y1) / 200, - x1 + Math.floor(columns[5]) * (x2 - x1) / 200, - y1 + Math.floor(columns[6]) * (y2 - y1) / 200, - Math.floor(columns[1]), - Math.floor(columns[2])); - } - } - } - } - Kage.prototype.drawBuhin = drawBuhin; - //properties Kage.prototype.kMincho = 0; Kage.prototype.kGothic = 1;