formatt a couple of files

This commit is contained in:
2025-07-11 00:57:55 +01:00
parent d5fda8b488
commit 024f1293c0
2 changed files with 46 additions and 24 deletions

View File

@@ -5,8 +5,8 @@ end
structure GraphLines :> GRAPH_LINES = structure GraphLines :> GRAPH_LINES =
struct struct
fun helpGenGraphLinesX (pos, xClickPoints, yClickPoints, acc, fun helpGenGraphLinesX
windowWidth, windowHeight) = (pos, xClickPoints, yClickPoints, acc, windowWidth, windowHeight) =
if pos = Vector.length xClickPoints then if pos = Vector.length xClickPoints then
Vector.concat acc Vector.concat acc
else else
@@ -21,7 +21,7 @@ struct
val minY = Vector.sub (xClickPoints, 0) val minY = Vector.sub (xClickPoints, 0)
val minY = (~(minY - halfHeight)) / halfHeight val minY = (~(minY - halfHeight)) / halfHeight
val maxY = Vector.sub (xClickPoints, Vector.length xClickPoints - 1) val maxY = Vector.sub (xClickPoints, Vector.length xClickPoints - 1)
val maxY = (~(maxY - halfHeight)) /halfHeight val maxY = (~(maxY - halfHeight)) / halfHeight
val acc = Ndc.ltrbToVertex (minusX, maxY, plusX, minY) :: acc val acc = Ndc.ltrbToVertex (minusX, maxY, plusX, minY) :: acc
in in
@@ -29,8 +29,8 @@ struct
(pos + 1, xClickPoints, yClickPoints, acc, windowWidth, windowHeight) (pos + 1, xClickPoints, yClickPoints, acc, windowWidth, windowHeight)
end end
fun helpGenGraphLinesY (pos, yClickPoints, xClickPoints, acc, fun helpGenGraphLinesY
windowWidth, windowHeight) = (pos, yClickPoints, xClickPoints, acc, windowWidth, windowHeight) =
if pos = Vector.length yClickPoints then if pos = Vector.length yClickPoints then
acc acc
else else
@@ -56,16 +56,16 @@ struct
end end
fun helpGenerate (windowWidth, windowHeight, xClickPoints, yClickPoints) = fun helpGenerate (windowWidth, windowHeight, xClickPoints, yClickPoints) =
let
val acc = helpGenGraphLinesY (0, yClickPoints, xClickPoints, [], windowWidth, windowHeight)
in
helpGenGraphLinesX (0, xClickPoints, yClickPoints, acc, windowWidth, windowHeight)
end
fun generate (app: AppType.app_type) =
let let
val {windowWidth, windowHeight, xClickPoints, yClickPoints, ...} = app val acc = helpGenGraphLinesY
(0, yClickPoints, xClickPoints, [], windowWidth, windowHeight)
in in
helpGenerate (windowWidth, windowHeight, xClickPoints, yClickPoints) helpGenGraphLinesX
(0, xClickPoints, yClickPoints, acc, windowWidth, windowHeight)
end
fun generate (app: AppType.app_type) =
let val {windowWidth, windowHeight, xClickPoints, yClickPoints, ...} = app
in helpGenerate (windowWidth, windowHeight, xClickPoints, yClickPoints)
end end
end end

View File

@@ -149,8 +149,7 @@ struct
val xpos = Vector.sub (xClickPoints, hIdx) val xpos = Vector.sub (xClickPoints, hIdx)
val ypos = Vector.sub (yClickPoints, vIdx) val ypos = Vector.sub (yClickPoints, vIdx)
val model = AppWith.addSquare val model = AppWith.addSquare (model, hIdx, vIdx, hIdx, vIdx)
(model, hIdx, vIdx, hIdx, vIdx)
val squares = #squares model val squares = #squares model
val dotVec = getDotVecFromIndices (model, hIdx, vIdx) val dotVec = getDotVecFromIndices (model, hIdx, vIdx)
@@ -159,9 +158,16 @@ struct
val halfHeight = Real32.fromInt (windowHeight div 2) val halfHeight = Real32.fromInt (windowHeight div 2)
val maxSide = Int.max (canvasWidth, canvasHeight) val maxSide = Int.max (canvasWidth, canvasHeight)
val squares = val squares = CollisionTree.toTriangles
CollisionTree.toTriangles (windowWidth, windowHeight, squares, maxSide, ( windowWidth
canvasWidth, canvasHeight, xClickPoints, yClickPoints) , windowHeight
, squares
, maxSide
, canvasWidth
, canvasHeight
, xClickPoints
, yClickPoints
)
val drawMsg = DRAW_SQUARES_AND_DOTS {squares = squares, dots = dotVec} val drawMsg = DRAW_SQUARES_AND_DOTS {squares = squares, dots = dotVec}
in in
(model, [DRAW drawMsg]) (model, [DRAW drawMsg])
@@ -181,13 +187,29 @@ struct
let let
val model = AppWith.windowResize (model, width, height) val model = AppWith.windowResize (model, width, height)
val {squares, canvasWidth, canvasHeight, showGraph, arrowX, arrowY, val
xClickPoints, yClickPoints, ...} = { squares
model , canvasWidth
, canvasHeight
, showGraph
, arrowX
, arrowY
, xClickPoints
, yClickPoints
, ...
} = model
val maxSide = Int.max (canvasWidth, canvasHeight) val maxSide = Int.max (canvasWidth, canvasHeight)
val squares = CollisionTree.toTriangles (width, height, squares, maxSide, val squares = CollisionTree.toTriangles
canvasWidth, canvasHeight, xClickPoints, yClickPoints) ( width
, height
, squares
, maxSide
, canvasWidth
, canvasHeight
, xClickPoints
, yClickPoints
)
val graphLines = val graphLines =
if showGraph then GraphLines.generate model else Vector.fromList [] if showGraph then GraphLines.generate model else Vector.fromList []