0a91bb7334d55947aa74dbfd5b6748c496aefad5
[chise/kage.git] / engine / kage.js
1 function Kage(){\r
2         // method\r
3         function drawFont(polygons, glyph){ // void\r
4                 // [glyph] : [stroke]$[stroke]$.....\r
5                 // [stroke] : [column]:[column]:.....\r
6                 var strokes = glyph.split("$");\r
7                 for(var i = 0; i < strokes.length; i++){\r
8                         var columns = strokes[i].split(":");\r
9                         if(Math.floor(columns[0]) != 99){\r
10                                 dfDrawFont(this, polygons,\r
11                                                                          Math.floor(columns[0]),\r
12                                                                          Math.floor(columns[1]), Math.floor(columns[2]),\r
13                                                                          Math.floor(columns[3]), Math.floor(columns[4]),\r
14                                                                          Math.floor(columns[5]), Math.floor(columns[6]),\r
15                                                                          Math.floor(columns[7]), Math.floor(columns[8]),\r
16                                                                          Math.floor(columns[9]), Math.floor(columns[10]));\r
17                         } else {\r
18                                 var buhin = this.kBuhin.search(columns[7]);\r
19                                 if(buhin != ""){\r
20                                         this.drawBuhin(polygons, buhin,\r
21                                                                                                  Math.floor(columns[3]),\r
22                                                                                                  Math.floor(columns[4]),\r
23                                                                                                  Math.floor(columns[5]),\r
24                                                                                                  Math.floor(columns[6]));\r
25                                 }\r
26                         }\r
27                 }\r
28         }\r
29         Kage.prototype.drawFont = drawFont;\r
30         \r
31   function drawBuhin(polygons, glyph, x1, y1, x2, y2){\r
32                 var strokes = glyph.split("$");\r
33                 for(var i = 0; i < strokes.length; i++){\r
34                         var columns = strokes[i].split(":");\r
35                         if(Math.floor(columns[0]) != 99){\r
36                                 dfDrawFont(this, polygons,\r
37                                                                          Math.floor(columns[0]),\r
38                                                                          Math.floor(columns[1]),\r
39                                                                          Math.floor(columns[2]),\r
40                                                                          x1 + Math.floor(columns[3]) * (x2 - x1) / 200,\r
41                                                                          y1 + Math.floor(columns[4]) * (y2 - y1) / 200,\r
42                                                                          x1 + Math.floor(columns[5]) * (x2 - x1) / 200,\r
43                                                                          y1 + Math.floor(columns[6]) * (y2 - y1) / 200,\r
44                                                                          x1 + Math.floor(columns[7]) * (x2 - x1) / 200,\r
45                                                                          y1 + Math.floor(columns[8]) * (y2 - y1) / 200,\r
46                                                                          x1 + Math.floor(columns[9]) * (x2 - x1) / 200,\r
47                                                                          y1 + Math.floor(columns[10]) * (y2 - y1) / 200);\r
48                         } else {\r
49                                 var buhin = this.kBuhin.search(columns[7]);\r
50                                 if(buhin != ""){\r
51                                         this.drawBuhin(polygons, buhin,\r
52                                                                                                  x1 + Math.floor(columns[3]) * (x2 - x1) / 200,\r
53                                                                                                  y1 + Math.floor(columns[4]) * (y2 - y1) / 200,\r
54                                                                                                  x1 + Math.floor(columns[5]) * (x2 - x1) / 200,\r
55                                                                                                  y1 + Math.floor(columns[6]) * (y2 - y1) / 200);\r
56                                 }\r
57                         }\r
58                 }\r
59   }\r
60   Kage.prototype.drawBuhin = drawBuhin;\r
61   \r
62   //properties\r
63   Kage.prototype.kMincho = 0;\r
64   Kage.prototype.kGothic = 1;\r
65   this.kShotai = this.kMincho;\r
66   this.kMage = 10;\r
67   this.kRate = 100;\r
68   this.kMinWidthY = 2;\r
69   this.kMinWidthT = 6;\r
70   this.kWidth = 5;\r
71   this.kKakato = 3;\r
72   //has KAKATO = 2, no KAKATO = 1\r
73   this.kL2RDfatten = 1.1;\r
74   this.kBuhin = new Buhin();\r
75   \r
76   return this;\r
77 }\r