fix bugs moving image up/down in move mode

This commit is contained in:
2025-08-09 00:22:25 +01:00
parent f46ca01d42
commit 7a3fc728f6
2 changed files with 17 additions and 10 deletions

BIN
dotscape

Binary file not shown.

View File

@@ -5,7 +5,7 @@ struct
open DrawMessage
open UpdateMessage
(* todo: resize message, escape button to go back to normal mode *)
(* todo: resize message *)
fun getDrawMsg (model: app_type) =
let
@@ -37,8 +37,13 @@ struct
(model, [DRAW drawMsg])
end
val blankPixel = {r = 0, g = 0, b = 0, a = 0}
fun makeBlankYAxis length =
Vector.tabulate (length, fn _ => {r = 0, g = 0, b = 0, a = 0})
Vector.tabulate (length, fn _ => blankPixel)
fun makeBlankXAxis length =
Vector.tabulate (length, fn _ => makeBlankYAxis length)
fun moveImageUp (model: app_type) =
let
@@ -46,11 +51,11 @@ struct
val squares =
Vector.mapi
(fn (idx, yAxis) =>
if idx + 1 < Vector.length squares then
Vector.sub (squares, idx + 1)
else
makeBlankYAxis (Vector.length yAxis)) squares
(fn (_, yAxis) =>
Vector.mapi
(fn (yIdx, pixel) =>
if yIdx = Vector.length yAxis - 1 then blankPixel
else Vector.sub (yAxis, yIdx + 1)) yAxis) squares
val model = AppWith.squares (model, squares)
in
@@ -63,9 +68,11 @@ struct
val squares =
Vector.mapi
(fn (idx, yAxis) =>
if idx = 0 then makeBlankYAxis (Vector.length yAxis)
else Vector.sub (squares, idx - 1)) squares
(fn (_, yAxis) =>
Vector.mapi
(fn (yIdx, pixel) =>
if yIdx = 0 then blankPixel else Vector.sub (yAxis, yIdx - 1))
yAxis) squares
val model = AppWith.squares (model, squares)
in