From 1e15373ea418009cbf80ab07f4267caee8fee448 Mon Sep 17 00:00:00 2001 From: Koichi KAMICHI Date: Sat, 6 Sep 2008 14:12:00 +0000 Subject: [PATCH] Added UROKO design function(size adjustment). --- engine/kage.js | 536 ++++++++++++++++++++++-------------------------------- engine/kagecd.js | 66 ++----- 2 files changed, 237 insertions(+), 365 deletions(-) diff --git a/engine/kage.js b/engine/kage.js index b2d9710..0d3f933 100755 --- a/engine/kage.js +++ b/engine/kage.js @@ -1,314 +1,222 @@ -function Kage(){ - // method - function makeGlyph(polygons, buhin){ // void - var glyphData = this.kBuhin.search(buhin); - if(glyphData != ""){ - this.drawStrokesArray(polygons, this.adjustKakato(this.getEachStrokes(glyphData))); - } - } - Kage.prototype.makeGlyph = makeGlyph; - - function getEachStrokes(glyphData){ // strokes array - var strokesArray = new Array(); - var strokes = glyphData.split("$"); - for(var i = 0; i < strokes.length; i++){ - var columns = strokes[i].split(":"); - if(Math.floor(columns[0]) != 99){ - strokesArray.push([ - 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 != ""){ - strokesArray = strokesArray.concat(this.getEachStrokesOfBuhin(buhin, - Math.floor(columns[3]), - Math.floor(columns[4]), - Math.floor(columns[5]), - Math.floor(columns[6])) - ); - } - } - } - return strokesArray; - } - Kage.prototype.getEachStrokes = getEachStrokes; - - function getEachStrokesOfBuhin(buhin, x1, y1, x2, y2){ - var temp = this.getEachStrokes(buhin); - var result = new Array(); - for(var i = 0; i < temp.length; i++){ - result.push([temp[i][0], - temp[i][1], - temp[i][2], - x1 + temp[i][3] * (x2 - x1) / 200, - y1 + temp[i][4] * (y2 - y1) / 200, - x1 + temp[i][5] * (x2 - x1) / 200, - y1 + temp[i][6] * (y2 - y1) / 200, - x1 + temp[i][7] * (x2 - x1) / 200, - y1 + temp[i][8] * (y2 - y1) / 200, - x1 + temp[i][9] * (x2 - x1) / 200, - y1 + temp[i][10] * (y2 - y1) / 200]); - } - return result; - } - Kage.prototype.getEachStrokesOfBuhin = getEachStrokesOfBuhin; - - function adjustKakato(strokesArray){ // strokesArray - for(var i = 0; i < strokesArray.length; i++){ - if(strokesArray[i][0] == 1 && - (strokesArray[i][2] == 13 || strokesArray[i][2] == 23)){ - for(var k = 0; k < this.kAdjustKakatoStep; k++){ - var crossing = 0; - for(var j = 0; j < strokesArray.length && !crossing; j++){ - if(i == j){ continue; } - switch(strokesArray[j][0]){ - case 0: - case 8: - case 9: - break; - case 6: - case 7: - if(!crossing && isCross(strokesArray[j][7], - strokesArray[j][8], - strokesArray[j][9], - strokesArray[j][10], - strokesArray[i][5] - this.kAdjustKakatoRangeX / 2, - strokesArray[i][6] + this.kAdjustKakatoRangeY[k], - strokesArray[i][5] + this.kAdjustKakatoRangeX / 2, - strokesArray[i][6] + this.kAdjustKakatoRangeY[k])){ - crossing++; - } - if(!crossing && isCross(strokesArray[j][7], - strokesArray[j][8], - strokesArray[j][9], - strokesArray[j][10], - strokesArray[i][5] - this.kAdjustKakatoRangeX / 2, - strokesArray[i][6] + this.kAdjustKakatoRangeY[k], - strokesArray[i][5] - this.kAdjustKakatoRangeX / 2, - strokesArray[i][6] + this.kAdjustKakatoRangeY[k + 1])){ - crossing++; - } - if(!crossing && isCross(strokesArray[j][7], - strokesArray[j][8], - strokesArray[j][9], - strokesArray[j][10], - strokesArray[i][5] + this.kAdjustKakatoRangeX / 2, - strokesArray[i][6] + this.kAdjustKakatoRangeY[k], - strokesArray[i][5] + this.kAdjustKakatoRangeX / 2, - strokesArray[i][6] + this.kAdjustKakatoRangeY[k + 1])){ - crossing++; - } - if(!crossing && isCross(strokesArray[j][7], - strokesArray[j][8], - strokesArray[j][9], - strokesArray[j][10], - strokesArray[i][5] - this.kAdjustKakatoRangeX / 2, - strokesArray[i][6] + this.kAdjustKakatoRangeY[k + 1], - strokesArray[i][5] + this.kAdjustKakatoRangeX / 2, - strokesArray[i][6] + this.kAdjustKakatoRangeY[k + 1])){ - crossing++; - } - case 2: - case 12: - case 3: - if(!crossing && isCross(strokesArray[j][5], - strokesArray[j][6], - strokesArray[j][7], - strokesArray[j][8], - strokesArray[i][5] - this.kAdjustKakatoRangeX / 2, - strokesArray[i][6] + this.kAdjustKakatoRangeY[k], - strokesArray[i][5] + this.kAdjustKakatoRangeX / 2, - strokesArray[i][6] + this.kAdjustKakatoRangeY[k])){ - crossing++; - } - if(!crossing && isCross(strokesArray[j][5], - strokesArray[j][6], - strokesArray[j][7], - strokesArray[j][8], - strokesArray[i][5] - this.kAdjustKakatoRangeX / 2, - strokesArray[i][6] + this.kAdjustKakatoRangeY[k], - strokesArray[i][5] - this.kAdjustKakatoRangeX / 2, - strokesArray[i][6] + this.kAdjustKakatoRangeY[k + 1])){ - crossing++; - } - if(!crossing && isCross(strokesArray[j][5], - strokesArray[j][6], - strokesArray[j][7], - strokesArray[j][8], - strokesArray[i][5] + this.kAdjustKakatoRangeX / 2, - strokesArray[i][6] + this.kAdjustKakatoRangeY[k], - strokesArray[i][5] + this.kAdjustKakatoRangeX / 2, - strokesArray[i][6] + this.kAdjustKakatoRangeY[k + 1])){ - crossing++; - } - if(!crossing && isCross(strokesArray[j][5], - strokesArray[j][6], - strokesArray[j][7], - strokesArray[j][8], - strokesArray[i][5] - this.kAdjustKakatoRangeX / 2, - strokesArray[i][6] + this.kAdjustKakatoRangeY[k + 1], - strokesArray[i][5] + this.kAdjustKakatoRangeX / 2, - strokesArray[i][6] + this.kAdjustKakatoRangeY[k + 1])){ - crossing++; - } - default: - if(!crossing && isCross(strokesArray[j][3], - strokesArray[j][4], - strokesArray[j][5], - strokesArray[j][6], - strokesArray[i][5] - this.kAdjustKakatoRangeX / 2, - strokesArray[i][6] + this.kAdjustKakatoRangeY[k], - strokesArray[i][5] + this.kAdjustKakatoRangeX / 2, - strokesArray[i][6] + this.kAdjustKakatoRangeY[k])){ - crossing++; - } - if(!crossing && isCross(strokesArray[j][3], - strokesArray[j][4], - strokesArray[j][5], - strokesArray[j][6], - strokesArray[i][5] - this.kAdjustKakatoRangeX / 2, - strokesArray[i][6] + this.kAdjustKakatoRangeY[k], - strokesArray[i][5] - this.kAdjustKakatoRangeX / 2, - strokesArray[i][6] + this.kAdjustKakatoRangeY[k + 1])){ - crossing++; - } - if(!crossing && isCross(strokesArray[j][3], - strokesArray[j][4], - strokesArray[j][5], - strokesArray[j][6], - strokesArray[i][5] + this.kAdjustKakatoRangeX / 2, - strokesArray[i][6] + this.kAdjustKakatoRangeY[k], - strokesArray[i][5] + this.kAdjustKakatoRangeX / 2, - strokesArray[i][6] + this.kAdjustKakatoRangeY[k + 1])){ - crossing++; - } - if(!crossing && isCross(strokesArray[j][3], - strokesArray[j][4], - strokesArray[j][5], - strokesArray[j][6], - strokesArray[i][5] - this.kAdjustKakatoRangeX / 2, - strokesArray[i][6] + this.kAdjustKakatoRangeY[k + 1], - strokesArray[i][5] + this.kAdjustKakatoRangeX / 2, - strokesArray[i][6] + this.kAdjustKakatoRangeY[k + 1])){ - crossing++; - } - } - } - if(crossing){ - strokesArray[i][2] += (3 - k) * 100; - k = Infinity; - } - } - } - } - return strokesArray; - } - 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])); - } - } - } - } - Kage.prototype.drawGlyph = drawGlyph; - - function drawBuhin(polygons, glyph, x1, y1, x2, y2){ // void - 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]), - 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); - } - } - } - } - Kage.prototype.drawBuhin = drawBuhin; - - //properties - Kage.prototype.kMincho = 0; - Kage.prototype.kGothic = 1; - this.kShotai = this.kMincho; - this.kMage = 10; - this.kRate = 100; - this.kMinWidthY = 2; - this.kMinWidthT = 6; - this.kWidth = 5; - this.kAdjustKakatoL = ([14, 9, 5, 2]); // 調整済みカカト用 - this.kAdjustKakatoR = ([8, 6, 4, 2]); // 調整済みカカト用 - this.kAdjustKakatoRangeX = 20; // 影響判定矩形の大きさ - this.kAdjustKakatoRangeY = ([1, 19, 24, 30]); // 影響判定矩形の大きさ - this.kAdjustKakatoStep = 3; // 影響判定矩形の段階 - this.kKakato = 3; - this.kL2RDfatten = 1.1; - this.kBuhin = new Buhin(); - - return this; -} +function Kage(){ + // method + function makeGlyph(polygons, buhin){ // void + var glyphData = this.kBuhin.search(buhin); + if(glyphData != ""){ + this.drawStrokesArray(polygons, this.adjustUroko(this.adjustKakato(this.getEachStrokes(glyphData)))); + } + } + Kage.prototype.makeGlyph = makeGlyph; + + function getEachStrokes(glyphData){ // strokes array + var strokesArray = new Array(); + var strokes = glyphData.split("$"); + for(var i = 0; i < strokes.length; i++){ + var columns = strokes[i].split(":"); + if(Math.floor(columns[0]) != 99){ + strokesArray.push([ + 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 != ""){ + strokesArray = strokesArray.concat(this.getEachStrokesOfBuhin(buhin, + Math.floor(columns[3]), + Math.floor(columns[4]), + Math.floor(columns[5]), + Math.floor(columns[6])) + ); + } + } + } + return strokesArray; + } + Kage.prototype.getEachStrokes = getEachStrokes; + + function getEachStrokesOfBuhin(buhin, x1, y1, x2, y2){ + var temp = this.getEachStrokes(buhin); + var result = new Array(); + for(var i = 0; i < temp.length; i++){ + result.push([temp[i][0], + temp[i][1], + temp[i][2], + x1 + temp[i][3] * (x2 - x1) / 200, + y1 + temp[i][4] * (y2 - y1) / 200, + x1 + temp[i][5] * (x2 - x1) / 200, + y1 + temp[i][6] * (y2 - y1) / 200, + x1 + temp[i][7] * (x2 - x1) / 200, + y1 + temp[i][8] * (y2 - y1) / 200, + x1 + temp[i][9] * (x2 - x1) / 200, + y1 + temp[i][10] * (y2 - y1) / 200]); + } + return result; + } + Kage.prototype.getEachStrokesOfBuhin = getEachStrokesOfBuhin; + + function adjustUroko(strokesArray){ // strokesArray + for(var i = 0; i < strokesArray.length; i++){ + if(strokesArray[i][0] == 1 && strokesArray[i][2] == 0){ // c‚̓EƒƒR‚È‚¢‚Ì‚Å–³Ž‹B‚Å‚àŒvŽZ—Ê‚ª–³‘Ê + for(var k = 0; k < this.kAdjustUrokoLengthStep; k++){ + var tx, ty, tlen; + if(strokesArray[i][4] == strokesArray[i][6]){ // ‰¡ + tx = strokesArray[i][5] - this.kAdjustUrokoLine[k]; + ty = strokesArray[i][6] - 0.5; + tlen = strokesArray[i][5] - strokesArray[i][3]; + } else { + var rad = Math.atan((strokesArray[i][6] - strokesArray[i][4]) / (strokesArray[i][5] - strokesArray[i][3])); + tx = strokesArray[i][5] - this.kAdjustUrokoLine[k] * Math.cos(rad) - 0.5 * Math.sin(rad); + ty = strokesArray[i][6] - this.kAdjustUrokoLine[k] * Math.sin(rad) - 0.5 * Math.cos(rad); + tlen = Math.sqrt((strokesArray[i][6] - strokesArray[i][4]) * (strokesArray[i][6] - strokesArray[i][4]) + + (strokesArray[i][5] - strokesArray[i][3]) * (strokesArray[i][5] - strokesArray[i][3])); + } + if(tlen < this.kAdjustUrokoLength[k] || + isCrossWithOthers(strokesArray, i, tx, ty, strokesArray[i][5], strokesArray[i][6]) + ){ + strokesArray[i][2] += (this.kAdjustUrokoLengthStep - k) * 100; + k = Infinity; + } + } + } + } + return strokesArray; + } + Kage.prototype.adjustUroko = adjustUroko; + + function adjustKakato(strokesArray){ // strokesArray + for(var i = 0; i < strokesArray.length; i++){ + if(strokesArray[i][0] == 1 && + (strokesArray[i][2] == 13 || strokesArray[i][2] == 23)){ + for(var k = 0; k < this.kAdjustKakatoStep; k++){ + if(isCrossBoxWithOthers(strokesArray, i, + strokesArray[i][5] - this.kAdjustKakatoRangeX / 2, + strokesArray[i][6] + this.kAdjustKakatoRangeY[k], + strokesArray[i][5] + this.kAdjustKakatoRangeX / 2, + strokesArray[i][6] + this.kAdjustKakatoRangeY[k + 1]) + ){ + strokesArray[i][2] += (3 - k) * 100; + k = Infinity; + } + } + } + } + return strokesArray; + } + 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])); + } + } + } + } + Kage.prototype.drawGlyph = drawGlyph; + + function drawBuhin(polygons, glyph, x1, y1, x2, y2){ // void + 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]), + 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); + } + } + } + } + Kage.prototype.drawBuhin = drawBuhin; + + //properties + Kage.prototype.kMincho = 0; + Kage.prototype.kGothic = 1; + this.kShotai = this.kMincho; + + this.kRate = 100; + + this.kMinWidthY = 2; + this.kMinWidthT = 6; + this.kWidth = 5; + this.kKakato = 3; + this.kL2RDfatten = 1.1; + this.kMage = 10; + + this.kAdjustKakatoL = ([14, 9, 5, 2]); // ’²®Ï‚݃JƒJƒg—p 000,100,200,300 + this.kAdjustKakatoR = ([8, 6, 4, 2]); // ’²®Ï‚݃JƒJƒg—p 000,100,200,300 + this.kAdjustKakatoRangeX = 20; // ‰e‹¿”»’è‹éŒ`‚Ì‘å‚«‚³ + this.kAdjustKakatoRangeY = ([1, 19, 24, 30]); // ‰e‹¿”»’è‹éŒ`‚Ì‘å‚«‚³‹«ŠEi3—̈æj + this.kAdjustKakatoStep = 3; // ‰e‹¿”»’è‹éŒ`‚Ì’iŠK + + this.kAdjustUrokoX = ([24, 20, 16, 12]); // ’²®Ï‚݃TƒCƒY 000,100,200,300 + this.kAdjustUrokoY = ([12, 11, 9, 8]); // ’²®Ï‚݃TƒCƒY 000,100,200,300 + this.kAdjustUrokoLength = ([22, 36, 50]); // ‰e‹¿”»’è’·‚³‚Ì’iŠK + this.kAdjustUrokoLengthStep = 3; // ‰e‹¿”»’è’·‚³‚Ì’iŠK + this.kAdjustUrokoLine = ([22, 26, 30]); // Œð·‚̉e‹¿”»’èBLength‚ƑΉž + + this.kBuhin = new Buhin(); + + return this; +} diff --git a/engine/kagecd.js b/engine/kagecd.js index aec3dca..a28be90 100755 --- a/engine/kagecd.js +++ b/engine/kagecd.js @@ -603,7 +603,7 @@ function cdDrawCurve(kage, polygons, x1, y1, x2, y2, x3, y3, a1, a2){ deltad = Math.pow(1.0 - t, hosomi); } else{ deltad = 1; } - + if(deltad < 0.15){ deltad = 0.15; } @@ -1099,36 +1099,20 @@ function cdDrawLine(kage, polygons, tx1, ty1, tx2, ty2, ta1, ta2){ } } else{ + //always same poly = new Polygon(4); - switch(a1){ - case 0: - poly.set(0, x1, y1 - kage.kMinWidthY); - poly.set(3, x1, y1 + kage.kMinWidthY); - break; - case 2: - poly.set(0, x1 - kage.kMinWidthT, y1 - kage.kMinWidthY); - poly.set(3, x1 - kage.kMinWidthT, y1 + kage.kMinWidthY); - break; - } - - switch(a2){ - case 0: - poly.set(1, x2, y2 - kage.kMinWidthY); - poly.set(2, x2, y2 + kage.kMinWidthY); - break; - case 2: - poly.set(1, x2 + kage.kMinWidthT, y2 - kage.kMinWidthY); - poly.set(2, x2 + kage.kMinWidthT, y2 + kage.kMinWidthY); - } - + poly.set(0, x1, y1 - kage.kMinWidthY); + poly.set(1, x2, y2 - kage.kMinWidthY); + poly.set(2, x2, y2 + kage.kMinWidthY); + poly.set(3, x1, y1 + kage.kMinWidthY); polygons.push(poly); //UROKO if(a2 == 0){ poly = new Polygon(); poly.push(x2, y2 - kage.kMinWidthY); - poly.push(x2 - 24, y2); - poly.push(x2 - 12, y2 - 12); + poly.push(x2 - kage.kAdjustUrokoX[opt2], y2); + poly.push(x2 - kage.kAdjustUrokoX[opt2] / 2, y2 - kage.kAdjustUrokoY[opt2]); polygons.push(poly); } } @@ -1136,40 +1120,20 @@ function cdDrawLine(kage, polygons, tx1, ty1, tx2, ty2, ta1, ta2){ else{ //for others, use x-axis rad = Math.atan((y2 - y1) / (x2 - x1)); if((Math.abs(y2 - y1) < Math.abs(x2 - x1)) && (a1 != 6) && (a2 != 6) && !(x1 > x2)){ //ASAI KAUDO + //always same poly = new Polygon(4); - switch(a1){ //must be 0 or 2 - case 0: - poly.set(0, x1 + Math.sin(rad) * kage.kMinWidthY, y1 - Math.cos(rad) * kage.kMinWidthY); - poly.set(3, x1 - Math.sin(rad) * kage.kMinWidthY, y1 + Math.cos(rad) * kage.kMinWidthY); - break; - case 2: - poly.set(0, x1 + Math.sin(rad) * kage.kMinWidthY - kage.kMinWidthT * Math.cos(rad), - y1 - Math.cos(rad) * kage.kMinWidthY - kage.kMinWidthT * Math.sin(rad)); - poly.set(3, x1 - Math.sin(rad) * kage.kMinWidthY - kage.kMinWidthT * Math.cos(rad), - y1 + Math.cos(rad) * kage.kMinWidthY - kage.kMinWidthT * Math.sin(rad)); - break; - } - - switch(a2){ //must be 0 or 2 - case 0: - poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthY, y2 - Math.cos(rad) * kage.kMinWidthY); - poly.set(2, x2 - Math.sin(rad) * kage.kMinWidthY, y2 + Math.cos(rad) * kage.kMinWidthY); - break; - case 2: - poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthY + kage.kMinWidthT * Math.cos(rad), - y2 - Math.cos(rad) * kage.kMinWidthY + kage.kMinWidthT * Math.sin(rad)); - poly.set(2, x2 - Math.sin(rad) * kage.kMinWidthY + kage.kMinWidthT * Math.cos(rad), - y2 + Math.cos(rad) * kage.kMinWidthY + kage.kMinWidthT * Math.sin(rad)); - } - + poly.set(0, x1 + Math.sin(rad) * kage.kMinWidthY, y1 - Math.cos(rad) * kage.kMinWidthY); + poly.set(1, x2 + Math.sin(rad) * kage.kMinWidthY, y2 - Math.cos(rad) * kage.kMinWidthY); + poly.set(2, x2 - Math.sin(rad) * kage.kMinWidthY, y2 + Math.cos(rad) * kage.kMinWidthY); + poly.set(3, x1 - Math.sin(rad) * kage.kMinWidthY, y1 + Math.cos(rad) * kage.kMinWidthY); polygons.push(poly); //UROKO if(a2 == 0){ poly = new Polygon(); poly.push(x2 + Math.sin(rad) * kage.kMinWidthY, y2 - Math.cos(rad) * kage.kMinWidthY); - poly.push(x2 - Math.cos(rad) * 24, y2 - Math.sin(rad) * 24); - poly.push(x2 - Math.cos(rad) * 12 + Math.sin(rad) * 12, y2 - Math.sin(rad) * 12 - Math.cos(rad) * 12); + poly.push(x2 - Math.cos(rad) * kage.kAdjustUrokoX[opt2], y2 - Math.sin(rad) * kage.kAdjustUrokoX[opt2]); + poly.push(x2 - Math.cos(rad) * kage.kAdjustUrokoX[opt2] / 2 + Math.sin(rad) * kage.kAdjustUrokoX[opt2] / 2, y2 - Math.sin(rad) * kage.kAdjustUrokoY[opt2] - Math.cos(rad) * kage.kAdjustUrokoY[opt2]); polygons.push(poly); } } -- 1.7.10.4