summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrebecca <ubq323@ubq323.website>2026-07-14 20:52:23 +0100
committerrebecca <ubq323@ubq323.website>2026-09-17 20:52:23 +0100
commitec3b1b1c6f6ed364ece503588c780f3d6e564f10 (patch)
tree54176d5f30f3f91a57e35408eb2b476634975959
parent8bdea1890ef7971bcf7b7666d3bac3d8797546ee (diff)
pos: add index()
-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