2 updates.
[chise/kage.git] / polygon.js
1 function Polygon(number){\r
2   // resolution : 0.1\r
3   \r
4   // method\r
5   function push(x, y, off){ // void\r
6     var temp = new Object();\r
7     temp.x = Math.floor(x*10)/10;\r
8     temp.y = Math.floor(y*10)/10;\r
9     if(off != 1){\r
10       off = 0;\r
11     }\r
12     temp.off = off;\r
13     this.array.push(temp);\r
14   }\r
15   Polygon.prototype.push = push;\r
16   \r
17   function set(index, x, y, off){ // void\r
18     this.array[index].x = Math.floor(x*10)/10;\r
19     this.array[index].y = Math.floor(y*10)/10;\r
20     if(off != 1){\r
21       off = 0;\r
22     }\r
23     this.array[index].off = off;\r
24   }\r
25   Polygon.prototype.set = set;\r
26   \r
27   function reverse(){ // void\r
28     this.array.reverse();\r
29   }\r
30   Polygon.prototype.reverse = reverse;\r
31   \r
32   function concat(poly){ // void\r
33     this.array = this.array.concat(poly.array);\r
34   }\r
35   Polygon.prototype.concat = concat;\r
36         \r
37   function shift(){ // void\r
38     this.array.shift();\r
39   }\r
40   Polygon.prototype.shift = shift;\r
41         \r
42   function unshift(x, y, off){ // void\r
43     var temp = new Object();\r
44     temp.x = Math.floor(x*10)/10;\r
45     temp.y = Math.floor(y*10)/10;\r
46     if(off != 1){\r
47       off = 0;\r
48     }\r
49     temp.off = off;\r
50     this.array.unshift(temp);\r
51   }\r
52   Polygon.prototype.unshift = unshift;\r
53         \r
54   // property\r
55   this.array = new Array();\r
56   \r
57   // initialize\r
58   if(number){\r
59     for(var i = 0; i < number; i++){\r
60       this.push(0, 0, 0);\r
61     }\r
62   }\r
63   \r
64   return this;\r
65 }\r