diff --git a/src/lib/turtle/Structure.hx b/src/lib/turtle/Structure.hx index 74756ca..2b47d9c 100644 --- a/src/lib/turtle/Structure.hx +++ b/src/lib/turtle/Structure.hx @@ -14,6 +14,14 @@ abstract Structure(Array) from Array { public function rotate():Structure { return [for (i in 0...height()) this[i].rotate()]; } + + public function mirrorX():Structure { + return [for (i in 0...height()) this[i].mirrorX()]; + } + + public function mirrorY():Structure { + return [for (i in 0...height()) this[i].mirrorY()]; + } } abstract Layer(Array>) from Array> { @@ -65,4 +73,28 @@ abstract Layer(Array>) from Array> { return rotatedMatrix; } + + public function mirrorX():Layer { + var rtn = []; + + for (y in 0...height()) { + var rev = this[y].copy(); + rev.reverse(); + rtn.push(rev); + } + + return rtn; + } + + public function mirrorY():Layer { + var rtn = [for (_ in 0...height()) []]; + + for (y in 0...height()) { + for (x in 0...width()) { + rtn[height() - 1 - y][x] = get(x, y); + } + } + + return rtn; + } }