set polygons to counter-clockwise
[chise/kage.git] / engine / polygon.js
index e89ea72..4d26b38 100755 (executable)
@@ -2,17 +2,25 @@ function Polygon(number){
   // resolution : 0.1\r
   \r
   // method\r
-  function push(x, y){ // void\r
+  function push(x, y, off){ // void\r
     var temp = new Object();\r
     temp.x = Math.floor(x*10)/10;\r
     temp.y = Math.floor(y*10)/10;\r
+    if(off != 1){\r
+      off = 0;\r
+    }\r
+    temp.off = off;\r
     this.array.push(temp);\r
   }\r
   Polygon.prototype.push = push;\r
   \r
-  function set(index, x, y){ // void\r
+  function set(index, x, y, off){ // void\r
     this.array[index].x = Math.floor(x*10)/10;\r
     this.array[index].y = Math.floor(y*10)/10;\r
+    if(off != 1){\r
+      off = 0;\r
+    }\r
+    this.array[index].off = off;\r
   }\r
   Polygon.prototype.set = set;\r
   \r
@@ -25,14 +33,31 @@ function Polygon(number){
     this.array = this.array.concat(poly.array);\r
   }\r
   Polygon.prototype.concat = concat;\r
-\r
+       \r
+  function shift(){ // void\r
+    this.array.shift();\r
+  }\r
+  Polygon.prototype.shift = shift;\r
+       \r
+  function unshift(x, y, off){ // void\r
+    var temp = new Object();\r
+    temp.x = Math.floor(x*10)/10;\r
+    temp.y = Math.floor(y*10)/10;\r
+    if(off != 1){\r
+      off = 0;\r
+    }\r
+    temp.off = off;\r
+    this.array.unshift(temp);\r
+  }\r
+  Polygon.prototype.unshift = unshift;\r
+       \r
   // property\r
   this.array = new Array();\r
   \r
   // initialize\r
   if(number){\r
     for(var i = 0; i < number; i++){\r
-      this.push(0, 0);\r
+      this.push(0, 0, 0);\r
     }\r
   }\r
   \r