summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pos.lua1
1 files changed, 1 insertions, 0 deletions
diff --git a/pos.lua b/pos.lua
index ba1a404..8f4ad94 100644
--- a/pos.lua
+++ b/pos.lua
@@ -48,6 +48,7 @@ function Pos.floor(self) return Pos:make(math.floor(self.x),math.floor(self.y))
function Pos.ceil(self) return Pos:make(math.ceil(self.x),math.ceil(self.y)) end
function Pos.round(self) return Pos:make(rmath.round(self.x),rmath.round(self.y)) end
function Pos.divmod(self,size) local div = (self/size):floor() return div, self-div*size end
+function Pos.index(self,size) return 1+self.x*size+self.y end
function Pos.__tostring(self)
return string.format("(%.2f,%.2f)",self.x,self.y)
end