port function to handlw window resizing event
This commit is contained in:
@@ -14,29 +14,21 @@ struct
|
|||||||
val ypos = Vector.sub (yClickPoints, vIdx)
|
val ypos = Vector.sub (yClickPoints, vIdx)
|
||||||
|
|
||||||
val endXpos =
|
val endXpos =
|
||||||
if hIdx + 1 = Vector.length xClickPoints then
|
if hIdx + 1 = Vector.length xClickPoints then xpos
|
||||||
xpos
|
else Vector.sub (xClickPoints, hIdx + 1)
|
||||||
else
|
|
||||||
Vector.sub (xClickPoints, hIdx + 1)
|
|
||||||
|
|
||||||
val endYpos =
|
val endYpos =
|
||||||
if vIdx + 1 = Vector.length yClickPoints then
|
if vIdx + 1 = Vector.length yClickPoints then ypos
|
||||||
ypos
|
else Vector.sub (yClickPoints, vIdx + 1)
|
||||||
else
|
|
||||||
Vector.sub (yClickPoints, vIdx + 1)
|
|
||||||
|
|
||||||
val tl =
|
val tl = ClickPoints.getDrawDotRgb
|
||||||
ClickPoints.getDrawDotRgb
|
(xpos, ypos, 0.0, 0.0, 1.0, windowWidth, windowHeight)
|
||||||
(xpos, ypos, 0.0, 0.0, 1.0, windowWidth, windowHeight)
|
val tr = ClickPoints.getDrawDotRgb
|
||||||
val tr =
|
(endXpos, ypos, 0.0, 0.0, 1.0, windowWidth, windowHeight)
|
||||||
ClickPoints.getDrawDotRgb
|
val bl = ClickPoints.getDrawDotRgb
|
||||||
(endXpos, ypos, 0.0, 0.0, 1.0, windowWidth, windowHeight)
|
(xpos, endYpos, 0.0, 0.0, 1.0, windowWidth, windowHeight)
|
||||||
val bl =
|
val br = ClickPoints.getDrawDotRgb
|
||||||
ClickPoints.getDrawDotRgb
|
(endXpos, endYpos, 0.0, 0.0, 1.0, windowWidth, windowHeight)
|
||||||
(xpos, endYpos, 0.0, 0.0, 1.0, windowWidth, windowHeight)
|
|
||||||
val br =
|
|
||||||
ClickPoints.getDrawDotRgb
|
|
||||||
(endXpos, endYpos, 0.0, 0.0, 1.0, windowWidth, windowHeight)
|
|
||||||
in
|
in
|
||||||
Vector.concat [tl, tr, bl, br]
|
Vector.concat [tl, tr, bl, br]
|
||||||
end
|
end
|
||||||
@@ -157,7 +149,8 @@ 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, realToInt xpos, realToInt ypos, hIdx, vIdx)
|
val model = AppWith.addSquare
|
||||||
|
(model, realToInt xpos, realToInt ypos, hIdx, vIdx)
|
||||||
val squares = #squares model
|
val squares = #squares model
|
||||||
|
|
||||||
val dotVec = getDotVecFromIndices (model, hIdx, vIdx)
|
val dotVec = getDotVecFromIndices (model, hIdx, vIdx)
|
||||||
@@ -166,7 +159,7 @@ struct
|
|||||||
val halfHeight = Real32.fromInt (windowHeight div 2)
|
val halfHeight = Real32.fromInt (windowHeight div 2)
|
||||||
|
|
||||||
val maxSide = Int.max (canvasWidth, canvasHeight)
|
val maxSide = Int.max (canvasWidth, canvasHeight)
|
||||||
val squares =
|
val squares =
|
||||||
CollisionTree.toTriangles (windowWidth, windowHeight, squares, maxSide)
|
CollisionTree.toTriangles (windowWidth, windowHeight, squares, maxSide)
|
||||||
val drawMsg = DRAW_SQUARES_AND_DOTS {squares = squares, dots = dotVec}
|
val drawMsg = DRAW_SQUARES_AND_DOTS {squares = squares, dots = dotVec}
|
||||||
in
|
in
|
||||||
@@ -183,4 +176,26 @@ struct
|
|||||||
in addCoordinates (model, arrowX, arrowY)
|
in addCoordinates (model, arrowX, arrowY)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
fun resizeWindow (model, width, height) =
|
||||||
|
let
|
||||||
|
val model = AppWith.windowResize (model, width, height)
|
||||||
|
|
||||||
|
val {squares, canvasWidth, canvasHeight, showGraph, arrowX, arrowY, ...} =
|
||||||
|
model
|
||||||
|
val maxSide = Int.max (canvasWidth, canvasHeight)
|
||||||
|
|
||||||
|
val squares = CollisionTree.toTriangles (width, height, squares, maxSide)
|
||||||
|
|
||||||
|
val graphLines =
|
||||||
|
if showGraph then GraphLines.generate model else Vector.fromList []
|
||||||
|
|
||||||
|
val dots = getDotVecFromIndices (model, arrowX, arrowY)
|
||||||
|
|
||||||
|
val drawMsg =
|
||||||
|
RESIZE_SQUARES_DOTS_AND_GRAPH
|
||||||
|
{squares = squares, graphLines = graphLines, dots = dots}
|
||||||
|
val drawMsg = [DRAW drawMsg]
|
||||||
|
in
|
||||||
|
(model, drawMsg)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user