diff options
| author | rebecca <ubq323@ubq323.website> | 2026-07-14 20:52:23 +0100 |
|---|---|---|
| committer | rebecca <ubq323@ubq323.website> | 2026-09-17 20:52:23 +0100 |
| commit | ec3b1b1c6f6ed364ece503588c780f3d6e564f10 (patch) | |
| tree | 54176d5f30f3f91a57e35408eb2b476634975959 | |
| parent | 8bdea1890ef7971bcf7b7666d3bac3d8797546ee (diff) | |
pos: add index()
| -rw-r--r-- | pos.lua | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -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 |
