57 lines
1.5 KiB
Standard ML
57 lines
1.5 KiB
Standard ML
structure AppUpdate =
|
|
struct
|
|
open AppType
|
|
|
|
open DrawMessage
|
|
open FileMessage
|
|
open InputMessage
|
|
open UpdateMessage
|
|
|
|
fun getDotVecFromIndices (model: app_type, hIdx, vIdx) =
|
|
let
|
|
val {windowWidth, windowHeight, xClickPoints, yClickPoints, ...} = model
|
|
val xpos = Vector.sub (xClickPoints, hIdx)
|
|
val ypos = Vector.sub (yClickPoints, vIdx)
|
|
|
|
val endXpos =
|
|
if hIdx + 1 = Vector.length xClickPoints then
|
|
xpos
|
|
else
|
|
Vector.sub (xClickPoints, hIdx + 1)
|
|
|
|
val endYpos =
|
|
if vIdx + 1 = Vector.length yClickPoints then
|
|
ypos
|
|
else
|
|
Vector.sub (yClickPoints, vIdx + 1)
|
|
|
|
val tl =
|
|
ClickPoints.getDrawDotRgb
|
|
(xpos, ypos, 1.0, 0.0, 0.0, windowWidth, windowHeight)
|
|
val tr =
|
|
ClickPoints.getDrawDotRgb
|
|
(endXpos, ypos, 1.0, 0.0, 0.0, windowWidth, windowHeight)
|
|
val bl =
|
|
ClickPoints.getDrawDotRgb
|
|
(xpos, endYpos, 1.0, 0.0, 0.0, windowWidth, windowHeight)
|
|
val br =
|
|
ClickPoints.getDrawDotRgb
|
|
(endXpos, endYpos, 1.0, 0.0, 0.0, windowWidth, windowHeight)
|
|
in
|
|
Vector.concat [tl, tr, bl, br]
|
|
end
|
|
|
|
fun mouseMoveOrRelease (model: app_type) =
|
|
let
|
|
val drawVec =
|
|
case ClickPoints.getClickPositionFromMouse model of
|
|
SOME (hIdx, vIdx) => getDotVecFromIndices (model, hIdx, vIdx)
|
|
| NONE => Vector.fromList []
|
|
|
|
val drawMsg = DRAW_DOT drawVec
|
|
val drawMsg = [DRAW drawMsg]
|
|
in
|
|
(model, drawMsg)
|
|
end
|
|
end
|