remove 'squares' field from app type, and refactor most functions in common-update.sml to use layer tree instead of squares vector
This commit is contained in:
@@ -10,17 +10,19 @@ struct
|
||||
fun resizeWindow (model, width, height, dots) =
|
||||
let
|
||||
val
|
||||
{ squares
|
||||
, canvasWidth
|
||||
{ canvasWidth
|
||||
, canvasHeight
|
||||
, showGraph
|
||||
, arrowX
|
||||
, arrowY
|
||||
, xClickPoints
|
||||
, yClickPoints
|
||||
, layerTree
|
||||
, ...
|
||||
} = model
|
||||
|
||||
val maxSide = Int.max (canvasWidth, canvasHeight)
|
||||
val squares = LayerTree.flatten (maxSide, layerTree)
|
||||
|
||||
val squares = CollisionTree.toTriangles
|
||||
( width
|
||||
@@ -46,11 +48,12 @@ struct
|
||||
|
||||
fun getSaveSquaresMsg (model: app_type) =
|
||||
let
|
||||
val {canvasWidth, canvasHeight, squares, ...} = model
|
||||
val str = CollisionTree.toSaveString (squares, canvasWidth, canvasHeight)
|
||||
val msg = SAVE_SQUARES str
|
||||
in
|
||||
(model, [FILE msg])
|
||||
(* todo: reimplement, saving each layer to a different line
|
||||
val {canvasWidth, canvasHeight, squares, ...} = model
|
||||
val str = CollisionTree.toSaveString (squares, canvasWidth, canvasHeight)
|
||||
val msg = SAVE_SQUARES str
|
||||
*)
|
||||
in raise Fail "todo common-update.sml: reimplement saving"
|
||||
end
|
||||
|
||||
fun getLoadSquaresMsg model =
|
||||
@@ -58,7 +61,11 @@ struct
|
||||
|
||||
fun getExportSquaresMsg (model: app_type) =
|
||||
let
|
||||
val {squares, canvasWidth, canvasHeight, ...} = model
|
||||
val {layerTree, canvasWidth, canvasHeight, ...} = model
|
||||
|
||||
val maxSide = Int.max (canvasWidth, canvasHeight)
|
||||
val squares = LayerTree.flatten (maxSide, layerTree)
|
||||
|
||||
val exportString =
|
||||
CollisionTree.toExportString (squares, canvasWidth, canvasHeight)
|
||||
val msg = EXPORT_SQUARES exportString
|
||||
@@ -68,7 +75,11 @@ struct
|
||||
|
||||
fun getCollisionMsg (model: app_type) =
|
||||
let
|
||||
val {squares, canvasWidth, canvasHeight, modalNum, ...} = model
|
||||
val {layerTree, canvasWidth, canvasHeight, modalNum, ...} = model
|
||||
|
||||
val maxSide = Int.max (canvasWidth, canvasHeight)
|
||||
val squares = LayerTree.flatten (maxSide, layerTree)
|
||||
|
||||
val exportString =
|
||||
CollisionTree.toCollisionString
|
||||
(squares, canvasWidth, canvasHeight, modalNum)
|
||||
|
||||
Reference in New Issue
Block a user