adjust click points to always keep the canvas at the centre of the screen, even when the canvas width is different from the canvas height

This commit is contained in:
2025-07-11 02:26:24 +01:00
parent 3897a109fb
commit fbec9ec2a7
2 changed files with 10 additions and 2 deletions

BIN
dotscape

Binary file not shown.

View File

@@ -12,10 +12,18 @@ struct
val pixelSize = Real32.min (xPixelSize, yPixelSize)
val actualWidth = pixelSize * realCanvasWidth
val actualHeight = pixelSize * realCanvasHeight
val heightDifference = realWindowHeight - actualHeight
val yOffset = heightDifference / 2.0
val widthDifference = realWindowWidth - actualWidth
val xOffset = widthDifference / 2.0
val xClickPoints = Vector.tabulate (canvasWidth + 1, fn i =>
Real32.fromInt i * pixelSize)
(Real32.fromInt i * pixelSize) + xOffset)
val yClickPoints = Vector.tabulate (canvasHeight + 1, fn i =>
Real32.fromInt i * pixelSize)
(Real32.fromInt i * pixelSize) + yOffset)
in
(xClickPoints, yClickPoints)
end