fix bugs moving image up/down in move mode
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user