Updated.
authorKoichi KAMICHI <kamichi@ic.daito.ac.jp>
Wed, 6 Aug 2014 01:27:06 +0000 (10:27 +0900)
committerKoichi KAMICHI <kamichi@ic.daito.ac.jp>
Wed, 6 Aug 2014 01:27:06 +0000 (10:27 +0900)
kage.js [changed mode: 0755->0644]
kagecd.js [changed mode: 0755->0644]
kagedf.js [changed mode: 0755->0644]

diff --git a/kage.js b/kage.js
old mode 100755 (executable)
new mode 100644 (file)
index cc98136..c58fda5
--- a/kage.js
+++ b/kage.js
@@ -2,19 +2,56 @@ function Kage(size){
   // method\r
   function makeGlyph(polygons, buhin){ // void\r
     var glyphData = this.kBuhin.search(buhin);\r
-    if(glyphData != ""){\r
-       this.drawStrokesArray(polygons, this.adjustKirikuchi(this.adjustUroko2(this.adjustUroko(this.adjustKakato(this.adjustTate(this.adjustMage(this.adjustHane(this.getEachStrokes(glyphData)))))))));\r
-    }\r
+    this.makeGlyph2(polygons, glyphData);\r
   }\r
   Kage.prototype.makeGlyph = makeGlyph;\r
   \r
   function makeGlyph2(polygons, data){ // void\r
-    if(data != ""){\r
-       this.drawStrokesArray(polygons, this.adjustKirikuchi(this.adjustUroko2(this.adjustUroko(this.adjustKakato(this.adjustTate(this.adjustMage(this.adjustHane(this.getEachStrokes(data)))))))));\r
-    }\r
+      if(data != ""){\r
+         var strokesArray = this.adjustKirikuchi(this.adjustUroko2(this.adjustUroko(this.adjustKakato(this.adjustTate(this.adjustMage(this.adjustHane(this.getEachStrokes(data))))))));\r
+         for(var i = 0; i < strokesArray.length; i++){\r
+             dfDrawFont(this, polygons,\r
+                        strokesArray[i][0],\r
+                        strokesArray[i][1],\r
+                        strokesArray[i][2],\r
+                        strokesArray[i][3],\r
+                        strokesArray[i][4],\r
+                        strokesArray[i][5],\r
+                        strokesArray[i][6],\r
+                        strokesArray[i][7],\r
+                        strokesArray[i][8],\r
+                        strokesArray[i][9],\r
+                        strokesArray[i][10]);\r
+         }\r
+      }\r
   }\r
   Kage.prototype.makeGlyph2 = makeGlyph2;\r
   \r
+  function makeGlyph3(data){ // void\r
+      var result = new Array();\r
+      if(data != ""){\r
+         var strokesArray = this.adjustKirikuchi(this.adjustUroko2(this.adjustUroko(this.adjustKakato(this.adjustTate(this.adjustMage(this.adjustHane(this.getEachStrokes(data))))))));\r
+         for(var i = 0; i < strokesArray.length; i++){\r
+             var polygons = new Polygons();\r
+             dfDrawFont(this, polygons,\r
+                        strokesArray[i][0],\r
+                        strokesArray[i][1],\r
+                        strokesArray[i][2],\r
+                        strokesArray[i][3],\r
+                        strokesArray[i][4],\r
+                        strokesArray[i][5],\r
+                        strokesArray[i][6],\r
+                        strokesArray[i][7],\r
+                        strokesArray[i][8],\r
+                        strokesArray[i][9],\r
+                        strokesArray[i][10]);\r
+             result.push(polygons);\r
+         }\r
+      }\r
+      return result;\r
+  }\r
+  Kage.prototype.makeGlyph3 = makeGlyph3;\r
+  \r
   function getEachStrokes(glyphData){ // strokes array\r
     var strokesArray = new Array();\r
     var strokes = glyphData.split("$");\r
@@ -43,7 +80,9 @@ function Kage(size){
                                                   Math.floor(columns[5]),\r
                                                   Math.floor(columns[6]),\r
                                                   Math.floor(columns[1]),\r
-                                                  Math.floor(columns[2]))\r
+                                                  Math.floor(columns[2]),\r
+                                                  Math.floor(columns[9]),\r
+                                                  Math.floor(columns[10]))\r
                             );\r
         }\r
       }\r
@@ -52,27 +91,31 @@ function Kage(size){
   }\r
   Kage.prototype.getEachStrokes = getEachStrokes;\r
   \r
-  function getEachStrokesOfBuhin(buhin, x1, y1, x2, y2, a1, a2){\r
+  function getEachStrokesOfBuhin(buhin, x1, y1, x2, y2, sx, sy, sx2, sy2){\r
     var temp = this.getEachStrokes(buhin);\r
     var result = new Array();\r
-    var box = getBox(buhin);\r
+    var box = this.getBox(buhin);\r
+      if(sx != 0 || sy != 0){\r
+         if(sx > 100){\r
+             sx -= 200; // Ç¤°ÕÅÀ¥â¡¼¥É\r
+         } else {\r
+             sx2 = 0; // Ãæ¿´ÅÀ¥â¡¼¥É\r
+             sy2 = 0;\r
+         }\r
+      }\r
     for(var i = 0; i < temp.length; i++){\r
-\r
-       var sx = a1;\r
-       var sy = a2;\r
        if(sx != 0 || sy != 0){\r
-           temp[i][3] = stretch(sx, temp[i][3], box.minX, box.maxX);\r
-           temp[i][4] = stretch(sy, temp[i][4], box.minY, box.maxY);\r
-           temp[i][5] = stretch(sx, temp[i][5], box.minX, box.maxX);\r
-           temp[i][6] = stretch(sy, temp[i][6], box.minY, box.maxY);\r
+           temp[i][3] = stretch(sx, sx2, temp[i][3], box.minX, box.maxX);\r
+           temp[i][4] = stretch(sy, sy2, temp[i][4], box.minY, box.maxY);\r
+           temp[i][5] = stretch(sx, sx2, temp[i][5], box.minX, box.maxX);\r
+           temp[i][6] = stretch(sy, sy2,temp[i][6], box.minY, box.maxY);\r
            if(temp[i][0] != 99){\r
-               temp[i][7] = stretch(sx, temp[i][7], box.minX, box.maxX);       \r
-               temp[i][8] = stretch(sy, temp[i][8], box.minY, box.maxY);\r
+               temp[i][7] = stretch(sx, sx2, temp[i][7], box.minX, box.maxX);  \r
+               temp[i][8] = stretch(sy, sy2, temp[i][8], box.minY, box.maxY);\r
+               temp[i][9] = stretch(sx, sx2, temp[i][9], box.minX, box.maxX);\r
+               temp[i][10] = stretch(sy, sy2, temp[i][10], box.minY, box.maxY);\r
            }\r
-           temp[i][9] = stretch(sx, temp[i][9], box.minX, box.maxX);\r
-           temp[i][10] = stretch(sy, temp[i][10], box.minY, box.maxY);\r
        }\r
-\r
       result.push([temp[i][0],\r
                    temp[i][1],\r
                    temp[i][2],\r
@@ -264,54 +307,6 @@ function Kage(size){
   }\r
   Kage.prototype.adjustKakato = adjustKakato;\r
   \r
-  function drawStrokesArray(polygons, strokesArray){\r
-    for(var i = 0; i < strokesArray.length; i++){\r
-      dfDrawFont(this, polygons,\r
-                 strokesArray[i][0],\r
-                 strokesArray[i][1],\r
-                 strokesArray[i][2],\r
-                 strokesArray[i][3],\r
-                 strokesArray[i][4],\r
-                 strokesArray[i][5],\r
-                 strokesArray[i][6],\r
-                 strokesArray[i][7],\r
-                 strokesArray[i][8],\r
-                 strokesArray[i][9],\r
-                 strokesArray[i][10]);\r
-    }\r
-  }\r
-  Kage.prototype.drawStrokesArray = drawStrokesArray;\r
-  \r
-  function drawGlyph(polygons, glyph){ // void\r
-    // [glyph] : [stroke]$[stroke]$.....\r
-    // [stroke] : [column]:[column]:.....\r
-    var strokes = glyph.split("$");\r
-    for(var i = 0; i < strokes.length; i++){\r
-      var columns = strokes[i].split(":");\r
-      if(Math.floor(columns[0]) != 99){\r
-        dfDrawFont(this, polygons,\r
-                   Math.floor(columns[0]),\r
-                   Math.floor(columns[1]), Math.floor(columns[2]),\r
-                   Math.floor(columns[3]), Math.floor(columns[4]),\r
-                   Math.floor(columns[5]), Math.floor(columns[6]),\r
-                   Math.floor(columns[7]), Math.floor(columns[8]),\r
-                   Math.floor(columns[9]), Math.floor(columns[10]));\r
-      } else {\r
-        var buhin = this.kBuhin.search(columns[7]);\r
-        if(buhin != ""){\r
-          this.drawBuhin(polygons, buhin,\r
-                         Math.floor(columns[3]),\r
-                         Math.floor(columns[4]),\r
-                         Math.floor(columns[5]),\r
-                         Math.floor(columns[6]),\r
-                         Math.floor(columns[1]),\r
-                         Math.floor(columns[2]));\r
-        }\r
-      }\r
-    }\r
-  }\r
-  Kage.prototype.drawGlyph = drawGlyph;\r
-  \r
   function getBox(glyph){ // minX, minY, maxX, maxY\r
       var a = new Object();\r
       a.minX = 200;\r
@@ -319,7 +314,7 @@ function Kage(size){
       a.maxX = 0;\r
       a.maxY = 0;\r
       \r
-      var strokes = getEachStrokes(glyph);\r
+      var strokes = this.getEachStrokes(glyph);\r
       for(var i = 0; i < strokes.length; i++){\r
          if(strokes[i][0] == 0){ continue; }\r
          a.minX = Math.min(a.minX, strokes[i][3]);\r
@@ -338,6 +333,7 @@ function Kage(size){
          a.maxY = Math.max(a.maxY, strokes[i][8]);\r
          if(strokes[i][0] == 2){ continue; }\r
          if(strokes[i][0] == 3){ continue; }\r
+         if(strokes[i][0] == 4){ continue; }\r
          a.minX = Math.min(a.minX, strokes[i][9]);\r
          a.maxX = Math.max(a.maxX, strokes[i][9]);\r
          a.minY = Math.min(a.minY, strokes[i][10]);\r
@@ -347,71 +343,23 @@ function Kage(size){
   }\r
   Kage.prototype.getBox = getBox;\r
 \r
-  function stretch(dp, sp, min, max){ // interger\r
+  function stretch(dp, sp, p, min, max){ // interger\r
       var p1, p2, p3, p4;\r
-      if(sp < 100){\r
+      if(p < sp + 100){\r
          p1 = min;\r
          p3 = min;\r
-         p2 = 100;\r
-         p4 = 100 + dp;\r
+         p2 = sp + 100;\r
+         p4 = dp + 100;\r
       } else {\r
-         p1 = 100;\r
-         p3 = 100 + dp;\r
+         p1 = sp + 100;\r
+         p3 = dp + 100;\r
          p2 = max;\r
          p4 = max;\r
       }\r
-      return Math.floor(((sp - p1) / (p2 - p1)) * (p4 - p3) + p3);\r
+      return Math.floor(((p - p1) / (p2 - p1)) * (p4 - p3) + p3);\r
   }\r
   Kage.prototype.stretch = stretch;\r
 \r
-  function drawBuhin(polygons, glyph, x1, y1, x2, y2, sx, sy){ // void\r
-    var strokes = glyph.split("$");\r
-    var box = getBox(glyph);\r
-    for(var i = 0; i < strokes.length; i++){\r
-      var columns = strokes[i].split(":");\r
-\r
-       if(sx != 0 || sy != 0){\r
-           columns[3] = stretch(sx, columns[3], box.minX, box.maxX);\r
-           columns[4] = stretch(sy, columns[4], box.minY, box.maxY);\r
-           columns[5] = stretch(sx, columns[5], box.minX, box.maxX);\r
-           columns[6] = stretch(sy, columns[6], box.minY, box.maxY);\r
-           if(columns[0] != 99){\r
-               columns[7] = stretch(sx, columns[7], box.minX, box.maxX);\r
-               columns[8] = stretch(sy, columns[8], box.minY, box.maxY);\r
-           }\r
-           columns[9] = stretch(sx, columns[9], box.minX, box.maxX);\r
-           columns[10] = stretch(sy, columns[10], box.minY, box.maxY);\r
-       }\r
-\r
-      if(Math.floor(columns[0]) != 99){\r
-        dfDrawFont(this, polygons,\r
-                   Math.floor(columns[0]),\r
-                   Math.floor(columns[1]),\r
-                   Math.floor(columns[2]),\r
-                   x1 + Math.floor(columns[3]) * (x2 - x1) / 200,\r
-                   y1 + Math.floor(columns[4]) * (y2 - y1) / 200,\r
-                   x1 + Math.floor(columns[5]) * (x2 - x1) / 200,\r
-                   y1 + Math.floor(columns[6]) * (y2 - y1) / 200,\r
-                   x1 + Math.floor(columns[7]) * (x2 - x1) / 200,\r
-                   y1 + Math.floor(columns[8]) * (y2 - y1) / 200,\r
-                   x1 + Math.floor(columns[9]) * (x2 - x1) / 200,\r
-                   y1 + Math.floor(columns[10]) * (y2 - y1) / 200);\r
-      } else {\r
-        var buhin = this.kBuhin.search(columns[7]);\r
-        if(buhin != ""){\r
-          this.drawBuhin(polygons, buhin,\r
-                         x1 + Math.floor(columns[3]) * (x2 - x1) / 200,\r
-                         y1 + Math.floor(columns[4]) * (y2 - y1) / 200,\r
-                         x1 + Math.floor(columns[5]) * (x2 - x1) / 200,\r
-                         y1 + Math.floor(columns[6]) * (y2 - y1) / 200,\r
-                        Math.floor(columns[1]),\r
-                        Math.floor(columns[2]));\r
-        }\r
-      }\r
-    }\r
-  }\r
-  Kage.prototype.drawBuhin = drawBuhin;\r
-  \r
   //properties\r
   Kage.prototype.kMincho = 0;\r
   Kage.prototype.kGothic = 1;\r
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index c420387..92e42bf
--- a/kagedf.js
+++ b/kagedf.js
@@ -229,7 +229,7 @@ function dfDrawFont(kage, polygons, a1, a2, a3, x1, y1, x2, y2, x3, y3, x4, y4){
       }\r
       break;\r
     case 6:\r
-      if(a3 == 4){\r
+      if(a3 % 100 == 4){\r
         if(x3 == x4){\r
           tx1 = x4;\r
           ty1 = y4 - kage.kMage;\r
@@ -245,7 +245,7 @@ function dfDrawFont(kage, polygons, a1, a2, a3, x1, y1, x2, y2, x3, y3, x4, y4){
           ty1 = y4 - kage.kMage * Math.sin(rad) * v;\r
         }\r
         cdDrawBezier(kage, polygons, x1, y1, x2, y2, x3, y3, tx1, ty1, a2, 1);\r
-        cdDrawCurve(kage, polygons, tx1, ty1, x4, y4, x4 - kage.kMage, y4, 1, 14);\r
+        cdDrawCurve(kage, polygons, tx1, ty1, x4, y4, x4 - kage.kMage, y4, 1, a3 + 10);\r
       }\r
       else if(a3 == 5){\r
         cdDrawBezier(kage, polygons, x1, y1, x2, y2, x3, y3, x4, y4, a2, 15);\r