done adding export-collision functionality, including collision message, in functional core. Next: add imperative shell scaffolding

This commit is contained in:
2025-07-13 15:33:32 +01:00
parent de16e816b4
commit 7e96203f92
7 changed files with 15 additions and 56 deletions

BIN
dotscape

Binary file not shown.

View File

@@ -29,6 +29,18 @@ struct
(model, [FILE msg])
end
fun getCollisionMsg (model: app_type) =
let
val {squares, canvasWidth, canvasHeight, modalNum, ...} = model
val exportString =
CollisionTree.toCollisionString (squares, canvasWidth, canvasHeight, modalNum)
val msg = EXPORT_COLLISIONS exportString
val model = AppWith.modalNum (model, 0)
in
(model, [FILE msg])
end
(* unimplemented *)
fun useSquaresInNormalMode (model, squares) = (model, [])

View File

@@ -363,6 +363,7 @@ struct
| KEY_CTRL_S => CommonUpdate.getSaveSquaresMsg model
| KEY_CTRL_L => CommonUpdate.getLoadSquaresMsg model
| KEY_CTRL_E => CommonUpdate.getExportSquaresMsg model
| KEY_CTRL_C => CommonUpdate.getCollisionMsg model
| USE_SQUARES {squares, canvasWidth, canvasHeight} =>
useSquares (model, squares, canvasWidth, canvasHeight)
| SQUARES_LOAD_ERROR => CommonUpdate.squaresLoadError model

View File

@@ -666,7 +666,6 @@ struct
val qtree = buildTree (0, 0, size, squares)
val bintree = merge (qtree, squares)
val scale = if scale = 0 then 1 else scale
val f = toCollisionStringFolder scale
val collisions = BinTree.foldr (f, bintree, [])
val collisions = String.concatWith ",\n" collisions

View File

@@ -1,55 +0,0 @@
structure AAA =
struct
fun xToNdc (xOffset, xpos, scale, halfWidth) =
((xpos * scale + xOffset) - halfWidth) / halfWidth
fun endXToNdc (xOffset, startX, endX, scale, halfWidth) =
(((endX - startX) * scale + xOffset) - halfWidth) / halfWidth
fun yToNdc (yOffset, ypos, scale, halfHeight) =
~(((ypos * scale + yOffset) - halfHeight) / halfHeight)
fun endYToNdc (yOffset, startY, endY, scale, halfHeight) =
~((((endY - startY) * scale + yOffset) - halfHeight) / halfHeight)
fun lerp (xOffset, yOffset, scale, windowWidth, windowHeight) =
let
val windowWidth = Real32.fromInt windowWidth
val halfWidth = windowWidth / 2.0
val windowHeight = Real32.fromInt windowHeight
val halfHeight = windowHeight / 2.0
in
#[
xToNdc (xOffset, 1.000000000000000, scale, halfWidth),
yToNdc (yOffset, 2.000000000000000, scale, halfHeight),
0.000000000000000,
0.000000000000000,
0.000000000000000,
endXToNdc (xOffset, xToNdc (xOffset, 1.000000000000000, scale, halfWidth), 1.000000000000000, scale, halfWidth),
yToNdc (yOffset, 2.000000000000000, scale, halfHeight),
0.000000000000000,
0.000000000000000,
0.000000000000000,
xToNdc (xOffset, 1.000000000000000, scale, halfWidth),
yToNdc (yOffset, 1.000000000000000, scale, halfHeight),
0.000000000000000,
0.000000000000000,
0.000000000000000,
xToNdc (xOffset, 1.000000000000000, scale, halfWidth),
yToNdc (yOffset, 1.000000000000000, scale, halfHeight),
0.000000000000000,
0.000000000000000,
0.000000000000000,
endXToNdc (xOffset, xToNdc (xOffset, 1.000000000000000, scale, halfWidth), 1.000000000000000, scale, halfWidth),
yToNdc (yOffset, 2.000000000000000, scale, halfHeight),
0.000000000000000,
0.000000000000000,
0.000000000000000,
endXToNdc (xOffset, xToNdc (xOffset, 1.000000000000000, scale, halfWidth), 1.000000000000000, scale, halfWidth),
yToNdc (yOffset, 1.000000000000000, scale, halfHeight),
0.000000000000000,
0.000000000000000,
0.000000000000000
]
end
end

View File

@@ -4,6 +4,7 @@ struct
SAVE_SQUARES of string
| LOAD_SQUARES
| EXPORT_SQUARES of string
| EXPORT_COLLISIONS of string
| LOAD_FILES of string
| SELECT_PATH of string
end

View File

@@ -19,6 +19,7 @@ struct
| KEY_CTRL_L
| KEY_CTRL_E
| KEY_CTRL_O
| KEY_CTRL_C
| NUM of int
| ARROW_UP
| ARROW_LEFT