cc981362583f12050369196e4f22701eca27d28a
[chise/kage.git] / kage.js
1 function Kage(size){\r
2   // method\r
3   function makeGlyph(polygons, buhin){ // void\r
4     var glyphData = this.kBuhin.search(buhin);\r
5     if(glyphData != ""){\r
6         this.drawStrokesArray(polygons, this.adjustKirikuchi(this.adjustUroko2(this.adjustUroko(this.adjustKakato(this.adjustTate(this.adjustMage(this.adjustHane(this.getEachStrokes(glyphData)))))))));\r
7     }\r
8   }\r
9   Kage.prototype.makeGlyph = makeGlyph;\r
10   \r
11   function makeGlyph2(polygons, data){ // void\r
12     if(data != ""){\r
13         this.drawStrokesArray(polygons, this.adjustKirikuchi(this.adjustUroko2(this.adjustUroko(this.adjustKakato(this.adjustTate(this.adjustMage(this.adjustHane(this.getEachStrokes(data)))))))));\r
14     }\r
15   }\r
16   Kage.prototype.makeGlyph2 = makeGlyph2;\r
17   \r
18   function getEachStrokes(glyphData){ // strokes array\r
19     var strokesArray = new Array();\r
20     var strokes = glyphData.split("$");\r
21     for(var i = 0; i < strokes.length; i++){\r
22       var columns = strokes[i].split(":");\r
23       if(Math.floor(columns[0]) != 99){\r
24         strokesArray.push([\r
25           Math.floor(columns[0]),\r
26           Math.floor(columns[1]),\r
27           Math.floor(columns[2]),\r
28           Math.floor(columns[3]),\r
29           Math.floor(columns[4]),\r
30           Math.floor(columns[5]),\r
31           Math.floor(columns[6]),\r
32           Math.floor(columns[7]),\r
33           Math.floor(columns[8]),\r
34           Math.floor(columns[9]),\r
35           Math.floor(columns[10])\r
36           ]);\r
37       } else {\r
38         var buhin = this.kBuhin.search(columns[7]);\r
39         if(buhin != ""){\r
40           strokesArray = strokesArray.concat(this.getEachStrokesOfBuhin(buhin,\r
41                                                   Math.floor(columns[3]),\r
42                                                   Math.floor(columns[4]),\r
43                                                   Math.floor(columns[5]),\r
44                                                   Math.floor(columns[6]),\r
45                                                   Math.floor(columns[1]),\r
46                                                   Math.floor(columns[2]))\r
47                             );\r
48         }\r
49       }\r
50     }\r
51     return strokesArray;\r
52   }\r
53   Kage.prototype.getEachStrokes = getEachStrokes;\r
54   \r
55   function getEachStrokesOfBuhin(buhin, x1, y1, x2, y2, a1, a2){\r
56     var temp = this.getEachStrokes(buhin);\r
57     var result = new Array();\r
58     var box = getBox(buhin);\r
59     for(var i = 0; i < temp.length; i++){\r
60 \r
61         var sx = a1;\r
62         var sy = a2;\r
63         if(sx != 0 || sy != 0){\r
64             temp[i][3] = stretch(sx, temp[i][3], box.minX, box.maxX);\r
65             temp[i][4] = stretch(sy, temp[i][4], box.minY, box.maxY);\r
66             temp[i][5] = stretch(sx, temp[i][5], box.minX, box.maxX);\r
67             temp[i][6] = stretch(sy, temp[i][6], box.minY, box.maxY);\r
68             if(temp[i][0] != 99){\r
69                 temp[i][7] = stretch(sx, temp[i][7], box.minX, box.maxX);       \r
70                 temp[i][8] = stretch(sy, temp[i][8], box.minY, box.maxY);\r
71             }\r
72             temp[i][9] = stretch(sx, temp[i][9], box.minX, box.maxX);\r
73             temp[i][10] = stretch(sy, temp[i][10], box.minY, box.maxY);\r
74         }\r
75 \r
76       result.push([temp[i][0],\r
77                    temp[i][1],\r
78                    temp[i][2],\r
79                    x1 + temp[i][3] * (x2 - x1) / 200,\r
80                    y1 + temp[i][4] * (y2 - y1) / 200,\r
81                    x1 + temp[i][5] * (x2 - x1) / 200,\r
82                    y1 + temp[i][6] * (y2 - y1) / 200,\r
83                    x1 + temp[i][7] * (x2 - x1) / 200,\r
84                    y1 + temp[i][8] * (y2 - y1) / 200,\r
85                    x1 + temp[i][9] * (x2 - x1) / 200,\r
86                    y1 + temp[i][10] * (y2 - y1) / 200]);\r
87     }\r
88     return result;\r
89   }\r
90   Kage.prototype.getEachStrokesOfBuhin = getEachStrokesOfBuhin;\r
91   \r
92   function adjustHane(sa){ // strokesArray\r
93       for(var i = 0; i < sa.length; i++){\r
94           if((sa[i][0] == 1 || sa[i][0] == 2 || sa[i][0] == 6) && sa[i][2] == 4){\r
95               var lpx; // lastPointX\r
96               var lpy; // lastPointY\r
97               if(sa[i][0] == 1){\r
98                   lpx = sa[i][5];\r
99                   lpy = sa[i][6];\r
100               } else if(sa[i][0] == 2){\r
101                   lpx = sa[i][7];\r
102                   lpy = sa[i][8];\r
103               } else {\r
104                   lpx = sa[i][9];\r
105                   lpy = sa[i][10];\r
106               }\r
107               var mn = Infinity; // mostNear\r
108               if(lpx + 18 < 100){\r
109                   mn = lpx + 18;\r
110               }\r
111               for(var j = 0; j < sa.length; j++){\r
112                   if(i != j && sa[j][0] == 1 && sa[j][3] == sa[j][5] && sa[j][3] < lpx && sa[j][4] <= lpy && sa[j][6] >= lpy){\r
113                       if(lpx - sa[j][3] < 100){\r
114                           mn = Math.min(mn, lpx - sa[j][3]);\r
115                       }\r
116                   }\r
117               }\r
118               if(mn != Infinity){\r
119                   sa[i][2] += 700 - Math.floor(mn / 15) * 100; // 0-99 -> 0-700\r
120               }\r
121           }\r
122       }\r
123       return sa;\r
124   }\r
125   Kage.prototype.adjustHane = adjustHane;\r
126 \r
127   function adjustUroko(strokesArray){ // strokesArray\r
128     for(var i = 0; i < strokesArray.length; i++){\r
129       if(strokesArray[i][0] == 1 && strokesArray[i][2] == 0){ // no operation for TATE\r
130         for(var k = 0; k < this.kAdjustUrokoLengthStep; k++){\r
131           var tx, ty, tlen;\r
132           if(strokesArray[i][4] == strokesArray[i][6]){ // YOKO\r
133             tx = strokesArray[i][5] - this.kAdjustUrokoLine[k];\r
134             ty = strokesArray[i][6] - 0.5;\r
135             tlen = strokesArray[i][5] - strokesArray[i][3];\r
136           } else {\r
137             var rad = Math.atan((strokesArray[i][6] - strokesArray[i][4]) / (strokesArray[i][5] - strokesArray[i][3]));\r
138             tx = strokesArray[i][5] - this.kAdjustUrokoLine[k] * Math.cos(rad) - 0.5 * Math.sin(rad);\r
139             ty = strokesArray[i][6] - this.kAdjustUrokoLine[k] * Math.sin(rad) - 0.5 * Math.cos(rad);\r
140             tlen = Math.sqrt((strokesArray[i][6] - strokesArray[i][4]) * (strokesArray[i][6] - strokesArray[i][4]) +\r
141                              (strokesArray[i][5] - strokesArray[i][3]) * (strokesArray[i][5] - strokesArray[i][3]));\r
142           }\r
143           if(tlen < this.kAdjustUrokoLength[k] ||\r
144              isCrossWithOthers(strokesArray, i, tx, ty, strokesArray[i][5], strokesArray[i][6])\r
145              ){\r
146             strokesArray[i][2] += (this.kAdjustUrokoLengthStep - k) * 100;\r
147             k = Infinity;\r
148           }\r
149         }\r
150       }\r
151     }\r
152     return strokesArray;\r
153   }\r
154   Kage.prototype.adjustUroko = adjustUroko;\r
155   \r
156   function adjustUroko2(strokesArray){ // strokesArray\r
157     for(var i = 0; i < strokesArray.length; i++){\r
158       if(strokesArray[i][0] == 1 && strokesArray[i][2] == 0 && strokesArray[i][4] == strokesArray[i][6]){\r
159         var pressure = 0;\r
160         for(var j = 0; j < strokesArray.length; j++){\r
161           if(i != j && (\r
162              (strokesArray[j][0] == 1 && strokesArray[j][4] == strokesArray[j][6] &&\r
163               !(strokesArray[i][3] + 1 > strokesArray[j][5] || strokesArray[i][5] - 1 < strokesArray[j][3]) &&\r
164               Math.abs(strokesArray[i][4] - strokesArray[j][4]) < this.kAdjustUroko2Length) ||\r
165              (strokesArray[j][0] == 3 && strokesArray[j][6] == strokesArray[j][8] &&\r
166               !(strokesArray[i][3] + 1 > strokesArray[j][7] || strokesArray[i][5] - 1 < strokesArray[j][5]) &&\r
167               Math.abs(strokesArray[i][4] - strokesArray[j][6]) < this.kAdjustUroko2Length)\r
168              )){\r
169             pressure += Math.pow(this.kAdjustUroko2Length - Math.abs(strokesArray[i][4] - strokesArray[j][6]), 1.1);\r
170           }\r
171         }\r
172         var result = Math.min(Math.floor(pressure / this.kAdjustUroko2Length), this.kAdjustUroko2Step) * 100;\r
173         if(strokesArray[i][2] < result){\r
174           strokesArray[i][2] = strokesArray[i][2] % 100 + Math.min(Math.floor(pressure / this.kAdjustUroko2Length), this.kAdjustUroko2Step) * 100;\r
175         }\r
176       }\r
177     }\r
178     return strokesArray;\r
179   }\r
180   Kage.prototype.adjustUroko2 = adjustUroko2;\r
181   \r
182   function adjustTate(strokesArray){ // strokesArray\r
183     for(var i = 0; i < strokesArray.length; i++){\r
184       if((strokesArray[i][0] == 1 || strokesArray[i][0] == 3 || strokesArray[i][0] == 7) && strokesArray[i][3] == strokesArray[i][5]){\r
185         for(var j = 0; j < strokesArray.length; j++){\r
186           if(i != j && (strokesArray[j][0] == 1 || strokesArray[j][0] == 3 || strokesArray[j][0] == 7) && strokesArray[j][3] == strokesArray[j][5] &&\r
187              !(strokesArray[i][4] + 1 > strokesArray[j][6] || strokesArray[i][6] - 1 < strokesArray[j][4]) &&\r
188              Math.abs(strokesArray[i][3] - strokesArray[j][3]) < this.kMinWidthT * this.kAdjustTateStep){\r
189             strokesArray[i][1] += (this.kAdjustTateStep - Math.floor(Math.abs(strokesArray[i][3] - strokesArray[j][3]) / this.kMinWidthT)) * 1000;\r
190             if(strokesArray[i][1] > this.kAdjustTateStep * 1000){\r
191               strokesArray[i][1] = strokesArray[i][1] % 1000 + this.kAdjustTateStep * 1000;\r
192             }\r
193           }\r
194         }\r
195       }\r
196     }\r
197     return strokesArray;\r
198   }\r
199   Kage.prototype.adjustTate = adjustTate;\r
200   \r
201   function adjustMage(strokesArray){ // strokesArray\r
202     for(var i = 0; i < strokesArray.length; i++){\r
203       if((strokesArray[i][0] == 3) && strokesArray[i][6] == strokesArray[i][8]){\r
204         for(var j = 0; j < strokesArray.length; j++){\r
205           if(i != j && (\r
206              (strokesArray[j][0] == 1 && strokesArray[j][4] == strokesArray[j][6] &&\r
207               !(strokesArray[i][5] + 1 > strokesArray[j][5] || strokesArray[i][7] - 1 < strokesArray[j][3]) &&\r
208               Math.abs(strokesArray[i][6] - strokesArray[j][4]) < this.kMinWidthT * this.kAdjustMageStep) ||\r
209              (strokesArray[j][0] == 3 && strokesArray[j][6] == strokesArray[j][8] &&\r
210               !(strokesArray[i][5] + 1 > strokesArray[j][7] || strokesArray[i][7] - 1 < strokesArray[j][5]) &&\r
211               Math.abs(strokesArray[i][6] - strokesArray[j][6]) < this.kMinWidthT * this.kAdjustMageStep)\r
212              )){\r
213             strokesArray[i][2] += (this.kAdjustMageStep - Math.floor(Math.abs(strokesArray[i][6] - strokesArray[j][6]) / this.kMinWidthT)) * 1000;\r
214             if(strokesArray[i][2] > this.kAdjustMageStep * 1000){\r
215               strokesArray[i][2] = strokesArray[i][2] % 1000 + this.kAdjustMageStep * 1000;\r
216             }\r
217           }\r
218         }\r
219       }\r
220     }\r
221     return strokesArray;\r
222   }\r
223   Kage.prototype.adjustMage = adjustMage;\r
224   \r
225   function adjustKirikuchi(strokesArray){ // strokesArray\r
226     for(var i = 0; i < strokesArray.length; i++){\r
227       if(strokesArray[i][0] == 2 && strokesArray[i][1] == 32 &&\r
228          strokesArray[i][3] > strokesArray[i][5] &&\r
229          strokesArray[i][4] < strokesArray[i][6]){\r
230         for(var j = 0; j < strokesArray.length; j++){ // no need to skip when i == j\r
231           if(strokesArray[j][0] == 1 &&\r
232              strokesArray[j][3] < strokesArray[i][3] && strokesArray[j][5] > strokesArray[i][3] &&\r
233              strokesArray[j][4] == strokesArray[i][4] && strokesArray[j][4] == strokesArray[j][6]){\r
234             strokesArray[i][1] = 132;\r
235             j = strokesArray.length;\r
236           }\r
237         }\r
238       }\r
239     }\r
240     return strokesArray;\r
241   }\r
242   Kage.prototype.adjustKirikuchi = adjustKirikuchi;\r
243   \r
244   function adjustKakato(strokesArray){ // strokesArray\r
245     for(var i = 0; i < strokesArray.length; i++){\r
246       if(strokesArray[i][0] == 1 &&\r
247          (strokesArray[i][2] == 13 || strokesArray[i][2] == 23)){\r
248         for(var k = 0; k < this.kAdjustKakatoStep; k++){\r
249           if(isCrossBoxWithOthers(strokesArray, i,\r
250                                strokesArray[i][5] - this.kAdjustKakatoRangeX / 2,\r
251                                strokesArray[i][6] + this.kAdjustKakatoRangeY[k],\r
252                                strokesArray[i][5] + this.kAdjustKakatoRangeX / 2,\r
253                                strokesArray[i][6] + this.kAdjustKakatoRangeY[k + 1])\r
254              | strokesArray[i][6] + this.kAdjustKakatoRangeY[k + 1] > 200 // adjust for baseline\r
255              | strokesArray[i][6] - strokesArray[i][4] < this.kAdjustKakatoRangeY[k + 1] // for thin box\r
256              ){\r
257             strokesArray[i][2] += (3 - k) * 100;\r
258             k = Infinity;\r
259           }\r
260         }\r
261       }\r
262     }\r
263     return strokesArray;\r
264   }\r
265   Kage.prototype.adjustKakato = adjustKakato;\r
266   \r
267   function drawStrokesArray(polygons, strokesArray){\r
268     for(var i = 0; i < strokesArray.length; i++){\r
269       dfDrawFont(this, polygons,\r
270                  strokesArray[i][0],\r
271                  strokesArray[i][1],\r
272                  strokesArray[i][2],\r
273                  strokesArray[i][3],\r
274                  strokesArray[i][4],\r
275                  strokesArray[i][5],\r
276                  strokesArray[i][6],\r
277                  strokesArray[i][7],\r
278                  strokesArray[i][8],\r
279                  strokesArray[i][9],\r
280                  strokesArray[i][10]);\r
281     }\r
282   }\r
283   Kage.prototype.drawStrokesArray = drawStrokesArray;\r
284   \r
285   function drawGlyph(polygons, glyph){ // void\r
286     // [glyph] : [stroke]$[stroke]$.....\r
287     // [stroke] : [column]:[column]:.....\r
288     var strokes = glyph.split("$");\r
289     for(var i = 0; i < strokes.length; i++){\r
290       var columns = strokes[i].split(":");\r
291       if(Math.floor(columns[0]) != 99){\r
292         dfDrawFont(this, polygons,\r
293                    Math.floor(columns[0]),\r
294                    Math.floor(columns[1]), Math.floor(columns[2]),\r
295                    Math.floor(columns[3]), Math.floor(columns[4]),\r
296                    Math.floor(columns[5]), Math.floor(columns[6]),\r
297                    Math.floor(columns[7]), Math.floor(columns[8]),\r
298                    Math.floor(columns[9]), Math.floor(columns[10]));\r
299       } else {\r
300         var buhin = this.kBuhin.search(columns[7]);\r
301         if(buhin != ""){\r
302           this.drawBuhin(polygons, buhin,\r
303                          Math.floor(columns[3]),\r
304                          Math.floor(columns[4]),\r
305                          Math.floor(columns[5]),\r
306                          Math.floor(columns[6]),\r
307                          Math.floor(columns[1]),\r
308                          Math.floor(columns[2]));\r
309         }\r
310       }\r
311     }\r
312   }\r
313   Kage.prototype.drawGlyph = drawGlyph;\r
314   \r
315   function getBox(glyph){ // minX, minY, maxX, maxY\r
316       var a = new Object();\r
317       a.minX = 200;\r
318       a.minY = 200;\r
319       a.maxX = 0;\r
320       a.maxY = 0;\r
321       \r
322       var strokes = getEachStrokes(glyph);\r
323       for(var i = 0; i < strokes.length; i++){\r
324           if(strokes[i][0] == 0){ continue; }\r
325           a.minX = Math.min(a.minX, strokes[i][3]);\r
326           a.maxX = Math.max(a.maxX, strokes[i][3]);\r
327           a.minY = Math.min(a.minY, strokes[i][4]);\r
328           a.maxY = Math.max(a.maxY, strokes[i][4]);\r
329           a.minX = Math.min(a.minX, strokes[i][5]);\r
330           a.maxX = Math.max(a.maxX, strokes[i][5]);\r
331           a.minY = Math.min(a.minY, strokes[i][6]);\r
332           a.maxY = Math.max(a.maxY, strokes[i][6]);\r
333           if(strokes[i][0] == 1){ continue; }\r
334           if(strokes[i][0] == 99){ continue; }\r
335           a.minX = Math.min(a.minX, strokes[i][7]);\r
336           a.maxX = Math.max(a.maxX, strokes[i][7]);\r
337           a.minY = Math.min(a.minY, strokes[i][8]);\r
338           a.maxY = Math.max(a.maxY, strokes[i][8]);\r
339           if(strokes[i][0] == 2){ continue; }\r
340           if(strokes[i][0] == 3){ continue; }\r
341           a.minX = Math.min(a.minX, strokes[i][9]);\r
342           a.maxX = Math.max(a.maxX, strokes[i][9]);\r
343           a.minY = Math.min(a.minY, strokes[i][10]);\r
344           a.maxY = Math.max(a.maxY, strokes[i][10]);\r
345       }\r
346       return a;\r
347   }\r
348   Kage.prototype.getBox = getBox;\r
349 \r
350   function stretch(dp, sp, min, max){ // interger\r
351       var p1, p2, p3, p4;\r
352       if(sp < 100){\r
353           p1 = min;\r
354           p3 = min;\r
355           p2 = 100;\r
356           p4 = 100 + dp;\r
357       } else {\r
358           p1 = 100;\r
359           p3 = 100 + dp;\r
360           p2 = max;\r
361           p4 = max;\r
362       }\r
363       return Math.floor(((sp - p1) / (p2 - p1)) * (p4 - p3) + p3);\r
364   }\r
365   Kage.prototype.stretch = stretch;\r
366 \r
367   function drawBuhin(polygons, glyph, x1, y1, x2, y2, sx, sy){ // void\r
368     var strokes = glyph.split("$");\r
369     var box = getBox(glyph);\r
370     for(var i = 0; i < strokes.length; i++){\r
371       var columns = strokes[i].split(":");\r
372 \r
373         if(sx != 0 || sy != 0){\r
374             columns[3] = stretch(sx, columns[3], box.minX, box.maxX);\r
375             columns[4] = stretch(sy, columns[4], box.minY, box.maxY);\r
376             columns[5] = stretch(sx, columns[5], box.minX, box.maxX);\r
377             columns[6] = stretch(sy, columns[6], box.minY, box.maxY);\r
378             if(columns[0] != 99){\r
379                 columns[7] = stretch(sx, columns[7], box.minX, box.maxX);\r
380                 columns[8] = stretch(sy, columns[8], box.minY, box.maxY);\r
381             }\r
382             columns[9] = stretch(sx, columns[9], box.minX, box.maxX);\r
383             columns[10] = stretch(sy, columns[10], box.minY, box.maxY);\r
384         }\r
385 \r
386       if(Math.floor(columns[0]) != 99){\r
387         dfDrawFont(this, polygons,\r
388                    Math.floor(columns[0]),\r
389                    Math.floor(columns[1]),\r
390                    Math.floor(columns[2]),\r
391                    x1 + Math.floor(columns[3]) * (x2 - x1) / 200,\r
392                    y1 + Math.floor(columns[4]) * (y2 - y1) / 200,\r
393                    x1 + Math.floor(columns[5]) * (x2 - x1) / 200,\r
394                    y1 + Math.floor(columns[6]) * (y2 - y1) / 200,\r
395                    x1 + Math.floor(columns[7]) * (x2 - x1) / 200,\r
396                    y1 + Math.floor(columns[8]) * (y2 - y1) / 200,\r
397                    x1 + Math.floor(columns[9]) * (x2 - x1) / 200,\r
398                    y1 + Math.floor(columns[10]) * (y2 - y1) / 200);\r
399       } else {\r
400         var buhin = this.kBuhin.search(columns[7]);\r
401         if(buhin != ""){\r
402           this.drawBuhin(polygons, buhin,\r
403                          x1 + Math.floor(columns[3]) * (x2 - x1) / 200,\r
404                          y1 + Math.floor(columns[4]) * (y2 - y1) / 200,\r
405                          x1 + Math.floor(columns[5]) * (x2 - x1) / 200,\r
406                          y1 + Math.floor(columns[6]) * (y2 - y1) / 200,\r
407                          Math.floor(columns[1]),\r
408                          Math.floor(columns[2]));\r
409         }\r
410       }\r
411     }\r
412   }\r
413   Kage.prototype.drawBuhin = drawBuhin;\r
414   \r
415   //properties\r
416   Kage.prototype.kMincho = 0;\r
417   Kage.prototype.kGothic = 1;\r
418   this.kShotai = this.kMincho;\r
419   \r
420   this.kRate = 100;\r
421   \r
422   if(size == 1){\r
423     this.kMinWidthY = 1.2;\r
424     this.kMinWidthT = 3.6;\r
425     this.kWidth = 3;\r
426     this.kKakato = 1.8;\r
427     this.kL2RDfatten = 1.1;\r
428     this.kMage = 6;\r
429     this.kUseCurve = 0;\r
430     \r
431     this.kAdjustKakatoL = ([8, 5, 3, 1]); // for KAKATO adjustment 000,100,200,300\r
432     this.kAdjustKakatoR = ([4, 3, 2, 1]); // for KAKATO adjustment 000,100,200,300\r
433     this.kAdjustKakatoRangeX = 12; // check area width\r
434     this.kAdjustKakatoRangeY = ([1, 11, 14, 18]); // 3 steps of checking\r
435     this.kAdjustKakatoStep = 3; // number of steps\r
436     \r
437     this.kAdjustUrokoX = ([14, 12, 9, 7]); // for UROKO adjustment 000,100,200,300\r
438     this.kAdjustUrokoY = ([7, 6, 5, 4]); // for UROKO adjustment 000,100,200,300\r
439     this.kAdjustUrokoLength = ([13, 21, 30]); // length for checking\r
440     this.kAdjustUrokoLengthStep = 3; // number of steps\r
441     this.kAdjustUrokoLine = ([13, 15, 18]); // check for crossing. corresponds to length\r
442   } else {\r
443     this.kMinWidthY = 2;\r
444     this.kMinWidthT = 6;\r
445     this.kWidth = 5;\r
446     this.kKakato = 3;\r
447     this.kL2RDfatten = 1.1;\r
448     this.kMage = 10;\r
449     this.kUseCurve = 0;\r
450     \r
451     this.kAdjustKakatoL = ([14, 9, 5, 2]); // for KAKATO adjustment 000,100,200,300\r
452     this.kAdjustKakatoR = ([8, 6, 4, 2]); // for KAKATO adjustment 000,100,200,300\r
453     this.kAdjustKakatoRangeX = 20; // check area width\r
454     this.kAdjustKakatoRangeY = ([1, 19, 24, 30]); // 3 steps of checking\r
455     this.kAdjustKakatoStep = 3; // number of steps\r
456     \r
457     this.kAdjustUrokoX = ([24, 20, 16, 12]); // for UROKO adjustment 000,100,200,300\r
458     this.kAdjustUrokoY = ([12, 11, 9, 8]); // for UROKO adjustment 000,100,200,300\r
459     this.kAdjustUrokoLength = ([22, 36, 50]); // length for checking\r
460     this.kAdjustUrokoLengthStep = 3; // number of steps\r
461     this.kAdjustUrokoLine = ([22, 26, 30]); // check for crossing. corresponds to length\r
462     \r
463     this.kAdjustUroko2Step = 3;\r
464     this.kAdjustUroko2Length = 40;\r
465     \r
466     this.kAdjustTateStep = 4;\r
467     \r
468     this.kAdjustMageStep = 5;\r
469   }\r
470   \r
471   this.kBuhin = new Buhin();\r
472   \r
473   return this;\r
474 }\r
475 \r