get drawing of triangles implemented
This commit is contained in:
@@ -20,6 +20,16 @@ sig
|
||||
val initial: app_type
|
||||
|
||||
val withTriangleStage: app_type * triangle_stage -> app_type
|
||||
|
||||
val addTriangleAndResetStage :
|
||||
app_type *
|
||||
Real32.real *
|
||||
Real32.real *
|
||||
Real32.real *
|
||||
Real32.real *
|
||||
Real32.real *
|
||||
Real32.real ->
|
||||
app_type
|
||||
end
|
||||
|
||||
structure AppType :> APP_TYPE =
|
||||
@@ -56,4 +66,15 @@ struct
|
||||
let val {triangles, triangleStage = _} = app
|
||||
in {triangles = triangles, triangleStage = newTriangleStage}
|
||||
end
|
||||
|
||||
fun addTriangleAndResetStage (app: app_type, x1, y1, x2, y2, x3, y3) :
|
||||
app_type =
|
||||
let
|
||||
val {triangles, triangleStage = _} = app
|
||||
|
||||
val newTriangle = {x1 = x1, y1 = y1, x2 = x2, y2 = y2, x3 = x3, y3 = y3}
|
||||
val newTriangles = newTriangle :: triangles
|
||||
in
|
||||
{triangles = newTriangles, triangleStage = NO_TRIANGLE}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -189,7 +189,8 @@ struct
|
||||
end
|
||||
| FIRST {x1, y1} =>
|
||||
let
|
||||
val drawVec = getFirstTriangleStageVector (x1, y1, buttonVec)
|
||||
val drawVec =
|
||||
getFirstTriangleStageVector (x1, y1, buttonVec)
|
||||
val drawMsg = DRAW_BUTTON drawVec
|
||||
|
||||
val newTriangleStage = SECOND
|
||||
@@ -201,13 +202,12 @@ struct
|
||||
end
|
||||
| SECOND {x1, y1, x2, y2} =>
|
||||
let
|
||||
val drawVec =
|
||||
getSecondTriangleStageVector (x1, y1, x2, y2, buttonVec)
|
||||
val drawMsg = DRAW_BUTTON drawVec
|
||||
|
||||
val newTriangleStage = NO_TRIANGLE
|
||||
val model =
|
||||
AppType.withTriangleStage (model, newTriangleStage)
|
||||
AppType.addTriangleAndResetStage
|
||||
(model, x1, y1, x2, y2, hpos, vpos)
|
||||
|
||||
val drawVec = getTrianglesVector model
|
||||
val drawMsg = DRAW_TRIANGLES_AND_RESET_BUTTONS drawVec
|
||||
in
|
||||
(model, drawMsg, mouseX, mouseY)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user