add functionality to flip drawing horizontally

This commit is contained in:
2025-08-12 22:25:16 +01:00
parent 55fe9b7605
commit 4a9b5947e7
9 changed files with 32 additions and 2 deletions

View File

@@ -32,4 +32,14 @@ struct
fun makeEmpty maxSide =
Vector.tabulate (maxSide, fn _ =>
Vector.tabulate (maxSide, fn _ => emptyPixel))
fun flipHorizontally (xAxis: t) =
Vector.mapi
(fn (xIdx, yAxis) =>
let
val flippedXIdx = Vector.length xAxis - 1 - xIdx
val flippedYAxis = Vector.sub (xAxis, flippedXIdx)
in
Vector.mapi (fn (yIdx, _) => Vector.sub (flippedYAxis, yIdx)) yAxis
end) xAxis
end