add functionality to delete pixel
This commit is contained in:
@@ -56,11 +56,6 @@ struct
|
||||
, redo
|
||||
} = app
|
||||
|
||||
val yAxis = Vector.sub (squares, newX)
|
||||
val undoData = Vector.sub (yAxis, newY)
|
||||
val undo = undoData :: undo
|
||||
val redo = []
|
||||
|
||||
val item = {r = r, g = g, b = b, a = a}
|
||||
val squares = updateSquares (squares, newX, newY, item)
|
||||
in
|
||||
@@ -91,6 +86,65 @@ struct
|
||||
}
|
||||
end
|
||||
|
||||
fun deleteSquare (app, deleteX, deleteY, arrowX, arrowY) =
|
||||
let
|
||||
val
|
||||
{ mode
|
||||
, squares
|
||||
, arrowX = _
|
||||
, arrowY = _
|
||||
, canvasWidth
|
||||
, canvasHeight
|
||||
, windowWidth
|
||||
, windowHeight
|
||||
, xClickPoints
|
||||
, yClickPoints
|
||||
|
||||
, showGraph
|
||||
, mouseX
|
||||
, mouseY
|
||||
, openFilePath
|
||||
, fileBrowser
|
||||
, fileBrowserIdx
|
||||
, r
|
||||
, g
|
||||
, b
|
||||
, a
|
||||
, modalNum
|
||||
, undo
|
||||
, redo
|
||||
} = app
|
||||
|
||||
val item = {r = 0, g = 0, b = 0, a = 0}
|
||||
val squares = updateSquares (squares, deleteX, deleteY, item)
|
||||
in
|
||||
{ mode = mode
|
||||
, squares = squares
|
||||
, arrowX = arrowX
|
||||
, arrowY = arrowY
|
||||
, canvasWidth = canvasWidth
|
||||
, canvasHeight = canvasHeight
|
||||
, windowWidth = windowWidth
|
||||
, windowHeight = windowHeight
|
||||
, xClickPoints = xClickPoints
|
||||
, yClickPoints = yClickPoints
|
||||
|
||||
, showGraph = showGraph
|
||||
, mouseX = mouseX
|
||||
, mouseY = mouseY
|
||||
, openFilePath = openFilePath
|
||||
, fileBrowser = fileBrowser
|
||||
, fileBrowserIdx = fileBrowserIdx
|
||||
, r = r
|
||||
, g = g
|
||||
, b = b
|
||||
, a = a
|
||||
, modalNum = modalNum
|
||||
, undo = undo
|
||||
, redo = redo
|
||||
}
|
||||
end
|
||||
|
||||
fun arrowX (app, arrowX) =
|
||||
let
|
||||
val
|
||||
|
||||
@@ -180,6 +180,47 @@ struct
|
||||
in addCoordinates (model, arrowX, arrowY)
|
||||
end
|
||||
|
||||
fun deletePixel (model, hIdx, vIdx) =
|
||||
let
|
||||
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 =
|
||||
let val {arrowX, arrowY, ...} = model
|
||||
in deletePixel (model, arrowX, arrowY)
|
||||
end
|
||||
|
||||
fun resizeWindow (model, width, height) =
|
||||
let
|
||||
val model = AppWith.windowResize (model, width, height)
|
||||
@@ -355,6 +396,7 @@ struct
|
||||
| ARROW_LEFT => moveArrowLeft model
|
||||
| ARROW_RIGHT => moveArrowRight model
|
||||
| ARROW_DOWN => moveArrowDown model
|
||||
| KEY_BACKSPACE => backspace model
|
||||
| KEY_ENTER => enterOrSpaceCoordinates model
|
||||
| KEY_SPACE => enterOrSpaceCoordinates model
|
||||
| FILE_BROWSER_AND_PATH {fileBrowser, path} =>
|
||||
|
||||
Reference in New Issue
Block a user