diff --git a/dotscape b/dotscape index 0b83805..2a56919 100755 Binary files a/dotscape and b/dotscape differ diff --git a/fcore/app-with.sml b/fcore/app-with.sml index 364677e..8c217e6 100644 --- a/fcore/app-with.sml +++ b/fcore/app-with.sml @@ -875,7 +875,7 @@ struct } end - fun canvasWidth (app: app_type, newCanvasWidth) = + fun canvasWidth (app: app_type, newCanvasWidth, newLayerTree) = let val { mode @@ -900,11 +900,10 @@ struct , b , a , layer - , layerTree + , layerTree = _ , modalNum } = app - val squares = changeSquaresSize (squares, newCanvasWidth, canvasHeight) val arrowX = Int.min (arrowX, newCanvasWidth) val (xClickPoints, yClickPoints) = ClickPoints.generate @@ -932,12 +931,12 @@ struct , b = b , a = a , layer = layer - , layerTree = layerTree + , layerTree = newLayerTree , modalNum = 0 } end - fun canvasHeight (app: app_type, newCanvasHeight) = + fun canvasHeight (app: app_type, newCanvasHeight, newLayerTree) = let val { mode @@ -962,11 +961,10 @@ struct , b , a , layer - , layerTree + , layerTree = _ , modalNum } = app - val squares = changeSquaresSize (squares, canvasWidth, newCanvasHeight) val arrowY = Int.min (arrowY, newCanvasHeight) val (xClickPoints, yClickPoints) = ClickPoints.generate @@ -994,7 +992,7 @@ struct , b = b , a = a , layer = layer - , layerTree = layerTree + , layerTree = newLayerTree , modalNum = 0 } end diff --git a/fcore/normal-mode.sml b/fcore/normal-mode.sml index 76840e7..a2c428f 100644 --- a/fcore/normal-mode.sml +++ b/fcore/normal-mode.sml @@ -251,12 +251,18 @@ struct fun selectCursorColour (model: app_type) = let - val {squares, arrowX, arrowY, ...} = model - val yAxis = Vector.sub (squares, arrowX) - val {r, g, b, a} = Vector.sub (yAxis, arrowY) - val model = AppWith.cursorColour (model, r, g, b, a) + val {layer, layerTree, arrowX, arrowY, ...} = model in - (model, []) + case LayerTree.get (layer, layerTree) of + SOME grid => + let + val yAxis = Vector.sub (grid, arrowX) + val {r, g, b, a} = Vector.sub (yAxis, arrowY) + val model = AppWith.cursorColour (model, r, g, b, a) + in + (model, []) + end + | NONE => (model, []) end fun updateCanvas (model, canvasWidth, canvasHeight) = @@ -266,10 +272,10 @@ struct , arrowY , windowWidth , windowHeight - , squares , xClickPoints , yClickPoints , showGraph + , layerTree , ... } = model @@ -278,6 +284,8 @@ struct if showGraph then GraphLines.generate model else Vector.fromList [] val maxSide = Int.max (canvasWidth, canvasHeight) + val squares = LayerTree.flatten (maxSide, layerTree) + val squares = CollisionTree.toTriangles ( windowWidth , windowHeight @@ -298,9 +306,13 @@ struct fun updateCanvasWidth model = let - val newCanvasWidth = #modalNum model - val (model as {canvasWidth, canvasHeight, ...}) = - AppWith.canvasWidth (model, newCanvasWidth) + val {modalNum, layerTree, canvasHeight, ...} = model + val newCanvasWidth = modalNum + + val maxSide = Int.max (newCanvasWidth, canvasHeight) + val layerTree = LayerTree.changeGridSize (maxSide, layerTree) + + val model = AppWith.canvasWidth (model, newCanvasWidth, layerTree) val {canvasWidth, canvasHeight, ...} = model in updateCanvas (model, canvasWidth, canvasHeight) @@ -308,8 +320,13 @@ struct fun updateCanvasHeight model = let - val newCanvasHeight = #modalNum model - val model = AppWith.canvasHeight (model, newCanvasHeight) + val {modalNum, layerTree, canvasWidth, ...} = model + val newCanvasHeight = modalNum + + val maxSide = Int.max (newCanvasHeight, canvasWidth) + val layerTree = LayerTree.changeGridSize (maxSide, layerTree) + + val model = AppWith.canvasHeight (model, newCanvasHeight, layerTree) val {canvasWidth, canvasHeight, ...} = model in updateCanvas (model, canvasWidth, canvasHeight)