fix bugs relating to resizing canvas width

This commit is contained in:
2025-07-11 22:20:29 +01:00
parent e3729a1ce5
commit a448fcf469
2 changed files with 15 additions and 9 deletions

BIN
dotscape

Binary file not shown.

View File

@@ -11,18 +11,21 @@ struct
el) squares el) squares
fun changeSquaresSize (squares, newCanvasWidth, newCanvasHeight) = fun changeSquaresSize (squares, newCanvasWidth, newCanvasHeight) =
Vector.tabulate (newCanvasWidth + 1, fn i => let
if i < Vector.length squares then val maxPoints = Int.max (newCanvasWidth, newCanvasHeight)
Vector.tabulate (newCanvasHeight + 1, fn ii => in
Vector.tabulate (maxPoints, fn i =>
if i < Vector.length squares then
let let
val yAxis = Vector.sub (squares, i) val yAxis = Vector.sub (squares, i)
in in
if ii < Vector.length yAxis then Vector.sub (yAxis, ii) Vector.tabulate (maxPoints, fn ii =>
else {r = 0, g = 0, b = 0, a = 0} if ii < Vector.length yAxis then Vector.sub (yAxis, ii)
end) else {r = 0, g = 0, b = 0, a = 0})
else end
Vector.tabulate (newCanvasHeight + 1, fn _ => else
{r = 0, g = 0, b = 0, a = 0})) Vector.tabulate (maxPoints, fn _ => {r = 0, g = 0, b = 0, a = 0}))
end
fun addSquare (app, newX, newY, arrowX, arrowY) : app_type = fun addSquare (app, newX, newY, arrowX, arrowY) : app_type =
let let
@@ -861,6 +864,9 @@ struct
val squares = changeSquaresSize (squares, newCanvasWidth, canvasHeight) val squares = changeSquaresSize (squares, newCanvasWidth, canvasHeight)
val arrowX = Int.min (arrowX, newCanvasWidth) val arrowX = Int.min (arrowX, newCanvasWidth)
val (xClickPoints, yClickPoints) =
ClickPoints.generate
(windowWidth, windowHeight, newCanvasWidth, canvasHeight)
in in
{ mode = mode { mode = mode
, canvasWidth = newCanvasWidth , canvasWidth = newCanvasWidth