progress moving away from 'squares' field to layer tree
This commit is contained in:
@@ -134,7 +134,7 @@ struct
|
||||
|
||||
fun realToInt x = Real32.toInt IEEEReal.TO_NEAREST x
|
||||
|
||||
fun changeSquare (model: app_type, hIdx, vIdx, fModel) =
|
||||
fun changePixel (model: app_type, hIdx, vIdx, pixel) =
|
||||
let
|
||||
val
|
||||
{ windowWidth
|
||||
@@ -143,18 +143,28 @@ struct
|
||||
, yClickPoints
|
||||
, canvasWidth
|
||||
, canvasHeight
|
||||
, layer
|
||||
, layerTree
|
||||
, r
|
||||
, g
|
||||
, b
|
||||
, a
|
||||
, ...
|
||||
} = model
|
||||
|
||||
val maxSide = Int.max (canvasWidth, canvasHeight)
|
||||
|
||||
val xpos = Vector.sub (xClickPoints, hIdx)
|
||||
val ypos = Vector.sub (yClickPoints, vIdx)
|
||||
|
||||
val model = fModel (model, hIdx, vIdx, hIdx, vIdx)
|
||||
val squares = #squares model
|
||||
val layerTree = LayerTree.addPixel
|
||||
(layer, hIdx, vIdx, maxSide, pixel, layerTree)
|
||||
val model = AppWith.layerTree (model, layerTree, hIdx, vIdx)
|
||||
|
||||
val squares = LayerTree.flatten (maxSide, layerTree)
|
||||
|
||||
val dotVec = getDotVecFromIndices (model, hIdx, vIdx)
|
||||
|
||||
val maxSide = Int.max (canvasWidth, canvasHeight)
|
||||
val squares = CollisionTree.toTriangles
|
||||
( windowWidth
|
||||
, windowHeight
|
||||
@@ -170,22 +180,27 @@ struct
|
||||
(model, [DRAW drawMsg])
|
||||
end
|
||||
|
||||
fun addCoordinates (model, hIdx, vIdx) =
|
||||
changeSquare (model, hIdx, vIdx, AppWith.addSquare)
|
||||
fun addPixel (model: app_type, hIdx, vIdx) =
|
||||
let
|
||||
val {r, g, b, a, ...} = model
|
||||
val pixel = {r = r, g = g, b = b, a = a}
|
||||
in
|
||||
changePixel (model, hIdx, vIdx, pixel)
|
||||
end
|
||||
|
||||
fun deletePixel (model, hIdx, vIdx) =
|
||||
changePixel (model, hIdx, vIdx, Grid.emptyPixel)
|
||||
|
||||
fun mouseLeftClick model =
|
||||
case ClickPoints.getClickPositionFromMouse model of
|
||||
SOME (hIdx, vIdx) => addCoordinates (model, hIdx, vIdx)
|
||||
SOME (hIdx, vIdx) => addPixel (model, hIdx, vIdx)
|
||||
| NONE => (model, [])
|
||||
|
||||
fun enterOrSpaceCoordinates model =
|
||||
let val {arrowX, arrowY, ...} = model
|
||||
in addCoordinates (model, arrowX, arrowY)
|
||||
in addPixel (model, arrowX, arrowY)
|
||||
end
|
||||
|
||||
fun deletePixel (model, hIdx, vIdx) =
|
||||
changeSquare (model, hIdx, vIdx, AppWith.deleteSquare)
|
||||
|
||||
fun backspace model =
|
||||
let val {arrowX, arrowY, ...} = model
|
||||
in deletePixel (model, arrowX, arrowY)
|
||||
|
||||
Reference in New Issue
Block a user