add functionality to delete pixel

This commit is contained in:
2025-07-11 23:55:12 +01:00
parent 973a1610ce
commit 22173a0cdb
3 changed files with 6 additions and 58 deletions

BIN
dotscape

Binary file not shown.

View File

@@ -3,13 +3,6 @@ $(SML_LIB)/basis/basis.mlb
(* FUNCTIONAL CORE *) (* FUNCTIONAL CORE *)
fcore/app-type.sml fcore/app-type.sml
ann
"allowVectorExps true"
in
fcore/ndc.sml
cozette-sml/fonts/cozette-ascii.mlb
end
fcore/graph-lines.sml fcore/graph-lines.sml
fcore/click-points.sml fcore/click-points.sml
fcore/app-init.sml fcore/app-init.sml
@@ -34,21 +27,6 @@ fcore/parse-file.sml
$(SML_LIB)/basis/mlton.mlb $(SML_LIB)/basis/mlton.mlb
$(SML_LIB)/cml/cml.mlb $(SML_LIB)/cml/cml.mlb
ann
"allowFFI true"
in
ffi/gles3-import.sml
ffi/glfw-import.sml
ffi/glfw-input.sml
end
ann
"allowVectorExps true"
in
imperative-shell/constants.sml
imperative-shell/app-draw.sml
end
imperative-shell/input-callbacks.sml imperative-shell/input-callbacks.sml
imperative-shell/update-thread.sml imperative-shell/update-thread.sml

View File

@@ -134,7 +134,7 @@ struct
fun realToInt x = Real32.toInt IEEEReal.TO_NEAREST x fun realToInt x = Real32.toInt IEEEReal.TO_NEAREST x
fun addCoordinates (model: app_type, hIdx, vIdx) = fun changeSquare (model: app_type, hIdx, vIdx, fModel) =
let let
val val
{ windowWidth { windowWidth
@@ -149,7 +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 (model, hIdx, vIdx, hIdx, vIdx) val model = fModel (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)
@@ -170,6 +170,9 @@ struct
(model, [DRAW drawMsg]) (model, [DRAW drawMsg])
end end
fun addCoordinates (model, hIdx, vIdx) =
changeSquare (model, hIdx, vIdx, AppWith.addSquare)
fun mouseLeftClick model = fun mouseLeftClick model =
case ClickPoints.getClickPositionFromMouse model of case ClickPoints.getClickPositionFromMouse model of
SOME (hIdx, vIdx) => addCoordinates (model, hIdx, vIdx) SOME (hIdx, vIdx) => addCoordinates (model, hIdx, vIdx)
@@ -181,40 +184,7 @@ struct
end end
fun deletePixel (model, hIdx, vIdx) = fun deletePixel (model, hIdx, vIdx) =
let changeSquare (model, hIdx, vIdx, AppWith.deleteSquare)
val
{ windowWidth
, windowHeight
, xClickPoints
, yClickPoints
, canvasWidth
, canvasHeight
, ...
} = model
val xpos = Vector.sub (xClickPoints, hIdx)
val ypos = Vector.sub (yClickPoints, vIdx)
val model = AppWith.deleteSquare (model, hIdx, vIdx, hIdx, vIdx)
val squares = #squares model
val dotVec = getDotVecFromIndices (model, hIdx, vIdx)
val maxSide = Int.max (canvasWidth, canvasHeight)
val squares = CollisionTree.toTriangles
( windowWidth
, windowHeight
, squares
, maxSide
, canvasWidth
, canvasHeight
, xClickPoints
, yClickPoints
)
val drawMsg = DRAW_SQUARES_AND_DOTS {squares = squares, dots = dotVec}
in
(model, [DRAW drawMsg])
end
fun backspace model = fun backspace model =
let val {arrowX, arrowY, ...} = model let val {arrowX, arrowY, ...} = model