add 'numClickPoints' field to app type, and add parameter with same name to
ClickPoints.generate function
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
signature APP_INIT =
|
signature APP_INIT =
|
||||||
sig
|
sig
|
||||||
val fromWindowWidthAndHeight: int * int -> AppType.app_type
|
val fromWindowWidthAndHeight: int * int * int -> AppType.app_type
|
||||||
end
|
end
|
||||||
|
|
||||||
structure AppInit :> APP_INIT =
|
structure AppInit :> APP_INIT =
|
||||||
@@ -8,15 +8,23 @@ struct
|
|||||||
open AppType
|
open AppType
|
||||||
|
|
||||||
fun helpFromWidthAndHeight
|
fun helpFromWidthAndHeight
|
||||||
(windowWidth, windowHeight, wStart, wFinish, hStart, hFinish) : app_type =
|
( windowWidth
|
||||||
|
, windowHeight
|
||||||
|
, wStart
|
||||||
|
, wFinish
|
||||||
|
, hStart
|
||||||
|
, hFinish
|
||||||
|
, numClickPoints
|
||||||
|
) : app_type =
|
||||||
let
|
let
|
||||||
val xClickPoints = ClickPoints.generate (wStart, wFinish)
|
val xClickPoints = ClickPoints.generate (wStart, wFinish, numClickPoints)
|
||||||
val yClickPoints = ClickPoints.generate (hStart, hFinish)
|
val yClickPoints = ClickPoints.generate (hStart, hFinish, numClickPoints)
|
||||||
in
|
in
|
||||||
{ triangles = []
|
{ triangles = []
|
||||||
, triangleStage = NO_TRIANGLE
|
, triangleStage = NO_TRIANGLE
|
||||||
, windowWidth = windowWidth
|
, windowWidth = windowWidth
|
||||||
, windowHeight = windowHeight
|
, windowHeight = windowHeight
|
||||||
|
, numClickPoints = numClickPoints
|
||||||
, xClickPoints = xClickPoints
|
, xClickPoints = xClickPoints
|
||||||
, yClickPoints = yClickPoints
|
, yClickPoints = yClickPoints
|
||||||
, undo = []
|
, undo = []
|
||||||
@@ -29,10 +37,17 @@ struct
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
fun fromWindowWidthAndHeight (windowWidth, windowHeight) =
|
fun fromWindowWidthAndHeight (windowWidth, windowHeight, numClickPoints) =
|
||||||
if windowWidth = windowHeight then
|
if windowWidth = windowHeight then
|
||||||
helpFromWidthAndHeight
|
helpFromWidthAndHeight
|
||||||
(windowWidth, windowHeight, 0, windowWidth, 0, windowHeight)
|
( windowWidth
|
||||||
|
, windowHeight
|
||||||
|
, 0
|
||||||
|
, windowWidth
|
||||||
|
, 0
|
||||||
|
, windowHeight
|
||||||
|
, numClickPoints
|
||||||
|
)
|
||||||
else if windowWidth > windowHeight then
|
else if windowWidth > windowHeight then
|
||||||
let
|
let
|
||||||
val difference = windowWidth - windowHeight
|
val difference = windowWidth - windowHeight
|
||||||
@@ -40,7 +55,14 @@ struct
|
|||||||
val wFinish = wStart + windowHeight
|
val wFinish = wStart + windowHeight
|
||||||
in
|
in
|
||||||
helpFromWidthAndHeight
|
helpFromWidthAndHeight
|
||||||
(windowWidth, windowHeight, wStart, wFinish, 0, windowHeight)
|
( windowWidth
|
||||||
|
, windowHeight
|
||||||
|
, wStart
|
||||||
|
, wFinish
|
||||||
|
, 0
|
||||||
|
, windowHeight
|
||||||
|
, numClickPoints
|
||||||
|
)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
let
|
let
|
||||||
@@ -49,6 +71,13 @@ struct
|
|||||||
val hFinish = hStart + windowWidth
|
val hFinish = hStart + windowWidth
|
||||||
in
|
in
|
||||||
helpFromWidthAndHeight
|
helpFromWidthAndHeight
|
||||||
(windowWidth, windowHeight, 0, windowWidth, hStart, hFinish)
|
( windowWidth
|
||||||
|
, windowHeight
|
||||||
|
, 0
|
||||||
|
, windowWidth
|
||||||
|
, hStart
|
||||||
|
, hFinish
|
||||||
|
, numClickPoints
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,12 +15,12 @@ sig
|
|||||||
, y3: Real32.real
|
, y3: Real32.real
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type app_type =
|
type app_type =
|
||||||
{ triangles: triangle list
|
{ triangles: triangle list
|
||||||
, triangleStage: triangle_stage
|
, triangleStage: triangle_stage
|
||||||
, windowWidth: int
|
, windowWidth: int
|
||||||
, windowHeight: int
|
, windowHeight: int
|
||||||
|
, numClickPoints: int
|
||||||
, xClickPoints: Real32.real vector
|
, xClickPoints: Real32.real vector
|
||||||
, yClickPoints: Real32.real vector
|
, yClickPoints: Real32.real vector
|
||||||
, undo: (Real32.real * Real32.real) list
|
, undo: (Real32.real * Real32.real) list
|
||||||
@@ -63,6 +63,7 @@ struct
|
|||||||
, triangleStage: triangle_stage
|
, triangleStage: triangle_stage
|
||||||
, windowWidth: int
|
, windowWidth: int
|
||||||
, windowHeight: int
|
, windowHeight: int
|
||||||
|
, numClickPoints: int
|
||||||
, xClickPoints: Real32.real vector
|
, xClickPoints: Real32.real vector
|
||||||
, yClickPoints: Real32.real vector
|
, yClickPoints: Real32.real vector
|
||||||
, undo: (Real32.real * Real32.real) list
|
, undo: (Real32.real * Real32.real) list
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ struct
|
|||||||
val
|
val
|
||||||
{ triangleStage = _
|
{ triangleStage = _
|
||||||
, triangles
|
, triangles
|
||||||
|
, numClickPoints
|
||||||
, xClickPoints
|
, xClickPoints
|
||||||
, yClickPoints
|
, yClickPoints
|
||||||
, windowWidth
|
, windowWidth
|
||||||
@@ -84,6 +85,7 @@ struct
|
|||||||
, undo = newUndo
|
, undo = newUndo
|
||||||
, redo = []
|
, redo = []
|
||||||
, triangles = triangles
|
, triangles = triangles
|
||||||
|
, numClickPoints = numClickPoints
|
||||||
, xClickPoints = xClickPoints
|
, xClickPoints = xClickPoints
|
||||||
, yClickPoints = yClickPoints
|
, yClickPoints = yClickPoints
|
||||||
, windowWidth = windowWidth
|
, windowWidth = windowWidth
|
||||||
@@ -103,6 +105,7 @@ struct
|
|||||||
val
|
val
|
||||||
{ triangles
|
{ triangles
|
||||||
, triangleStage = _
|
, triangleStage = _
|
||||||
|
, numClickPoints
|
||||||
, xClickPoints
|
, xClickPoints
|
||||||
, yClickPoints
|
, yClickPoints
|
||||||
, windowWidth
|
, windowWidth
|
||||||
@@ -124,6 +127,7 @@ struct
|
|||||||
, triangles = newTriangles
|
, triangles = newTriangles
|
||||||
, undo = newUndo
|
, undo = newUndo
|
||||||
, redo = []
|
, redo = []
|
||||||
|
, numClickPoints = numClickPoints
|
||||||
, xClickPoints = xClickPoints
|
, xClickPoints = xClickPoints
|
||||||
, yClickPoints = yClickPoints
|
, yClickPoints = yClickPoints
|
||||||
, windowWidth = windowWidth
|
, windowWidth = windowWidth
|
||||||
@@ -141,6 +145,7 @@ struct
|
|||||||
val
|
val
|
||||||
{ xClickPoints
|
{ xClickPoints
|
||||||
, yClickPoints
|
, yClickPoints
|
||||||
|
, numClickPoints
|
||||||
, windowWidth
|
, windowWidth
|
||||||
, windowHeight
|
, windowHeight
|
||||||
, triangles
|
, triangles
|
||||||
@@ -156,6 +161,7 @@ struct
|
|||||||
in
|
in
|
||||||
{ xClickPoints = xClickPoints
|
{ xClickPoints = xClickPoints
|
||||||
, yClickPoints = yClickPoints
|
, yClickPoints = yClickPoints
|
||||||
|
, numClickPoints = numClickPoints
|
||||||
, triangles = triangles
|
, triangles = triangles
|
||||||
, triangleStage = triangleStage
|
, triangleStage = triangleStage
|
||||||
, windowWidth = windowWidth
|
, windowWidth = windowWidth
|
||||||
@@ -175,6 +181,7 @@ struct
|
|||||||
val
|
val
|
||||||
{ xClickPoints
|
{ xClickPoints
|
||||||
, yClickPoints
|
, yClickPoints
|
||||||
|
, numClickPoints
|
||||||
, windowWidth
|
, windowWidth
|
||||||
, windowHeight
|
, windowHeight
|
||||||
, triangles
|
, triangles
|
||||||
@@ -190,6 +197,7 @@ struct
|
|||||||
in
|
in
|
||||||
{ xClickPoints = xClickPoints
|
{ xClickPoints = xClickPoints
|
||||||
, yClickPoints = yClickPoints
|
, yClickPoints = yClickPoints
|
||||||
|
, numClickPoints = numClickPoints
|
||||||
, triangles = triangles
|
, triangles = triangles
|
||||||
, triangleStage = triangleStage
|
, triangleStage = triangleStage
|
||||||
, windowWidth = windowWidth
|
, windowWidth = windowWidth
|
||||||
@@ -211,6 +219,7 @@ struct
|
|||||||
val
|
val
|
||||||
{ xClickPoints = _
|
{ xClickPoints = _
|
||||||
, yClickPoints = _
|
, yClickPoints = _
|
||||||
|
, numClickPoints
|
||||||
, windowWidth = _
|
, windowWidth = _
|
||||||
, windowHeight = _
|
, windowHeight = _
|
||||||
, triangles
|
, triangles
|
||||||
@@ -224,11 +233,12 @@ struct
|
|||||||
, arrowY
|
, arrowY
|
||||||
} = app
|
} = app
|
||||||
|
|
||||||
val xClickPoints = ClickPoints.generate (wStart, wFinish)
|
val xClickPoints = ClickPoints.generate (wStart, wFinish, numClickPoints)
|
||||||
val yClickPoints = ClickPoints.generate (hStart, hFinish)
|
val yClickPoints = ClickPoints.generate (hStart, hFinish, numClickPoints)
|
||||||
in
|
in
|
||||||
{ xClickPoints = xClickPoints
|
{ xClickPoints = xClickPoints
|
||||||
, yClickPoints = yClickPoints
|
, yClickPoints = yClickPoints
|
||||||
|
, numClickPoints = numClickPoints
|
||||||
, triangles = triangles
|
, triangles = triangles
|
||||||
, triangleStage = triangleStage
|
, triangleStage = triangleStage
|
||||||
, windowWidth = windowWidth
|
, windowWidth = windowWidth
|
||||||
@@ -273,6 +283,7 @@ struct
|
|||||||
, mouseY = _
|
, mouseY = _
|
||||||
, triangles
|
, triangles
|
||||||
, triangleStage
|
, triangleStage
|
||||||
|
, numClickPoints
|
||||||
, xClickPoints
|
, xClickPoints
|
||||||
, yClickPoints
|
, yClickPoints
|
||||||
, windowWidth
|
, windowWidth
|
||||||
@@ -288,6 +299,7 @@ struct
|
|||||||
, mouseY = mouseY
|
, mouseY = mouseY
|
||||||
, triangles = triangles
|
, triangles = triangles
|
||||||
, triangleStage = triangleStage
|
, triangleStage = triangleStage
|
||||||
|
, numClickPoints = numClickPoints
|
||||||
, xClickPoints = xClickPoints
|
, xClickPoints = xClickPoints
|
||||||
, yClickPoints = yClickPoints
|
, yClickPoints = yClickPoints
|
||||||
, windowWidth = windowWidth
|
, windowWidth = windowWidth
|
||||||
@@ -306,6 +318,7 @@ struct
|
|||||||
val
|
val
|
||||||
{ triangleStage = _
|
{ triangleStage = _
|
||||||
, triangles = _
|
, triangles = _
|
||||||
|
, numClickPoints
|
||||||
, xClickPoints
|
, xClickPoints
|
||||||
, yClickPoints
|
, yClickPoints
|
||||||
, windowWidth
|
, windowWidth
|
||||||
@@ -330,6 +343,7 @@ struct
|
|||||||
, triangles = newTriangles
|
, triangles = newTriangles
|
||||||
, undo = newUndo
|
, undo = newUndo
|
||||||
, redo = newRedo
|
, redo = newRedo
|
||||||
|
, numClickPoints = numClickPoints
|
||||||
, xClickPoints = xClickPoints
|
, xClickPoints = xClickPoints
|
||||||
, yClickPoints = yClickPoints
|
, yClickPoints = yClickPoints
|
||||||
, windowWidth = windowWidth
|
, windowWidth = windowWidth
|
||||||
@@ -348,6 +362,7 @@ struct
|
|||||||
val
|
val
|
||||||
{ triangleStage = _
|
{ triangleStage = _
|
||||||
, triangles = _
|
, triangles = _
|
||||||
|
, numClickPoints
|
||||||
, xClickPoints
|
, xClickPoints
|
||||||
, yClickPoints
|
, yClickPoints
|
||||||
, windowWidth
|
, windowWidth
|
||||||
@@ -371,6 +386,7 @@ struct
|
|||||||
, triangles = newTriangles
|
, triangles = newTriangles
|
||||||
, undo = newUndo
|
, undo = newUndo
|
||||||
, redo = newRedo
|
, redo = newRedo
|
||||||
|
, numClickPoints = numClickPoints
|
||||||
, xClickPoints = xClickPoints
|
, xClickPoints = xClickPoints
|
||||||
, yClickPoints = yClickPoints
|
, yClickPoints = yClickPoints
|
||||||
, windowWidth = windowWidth
|
, windowWidth = windowWidth
|
||||||
@@ -388,6 +404,7 @@ struct
|
|||||||
val
|
val
|
||||||
{ triangleStage
|
{ triangleStage
|
||||||
, triangles
|
, triangles
|
||||||
|
, numClickPoints
|
||||||
, xClickPoints
|
, xClickPoints
|
||||||
, yClickPoints
|
, yClickPoints
|
||||||
, windowWidth
|
, windowWidth
|
||||||
@@ -406,6 +423,7 @@ struct
|
|||||||
, triangles = triangles
|
, triangles = triangles
|
||||||
, undo = undo
|
, undo = undo
|
||||||
, redo = redo
|
, redo = redo
|
||||||
|
, numClickPoints = numClickPoints
|
||||||
, xClickPoints = xClickPoints
|
, xClickPoints = xClickPoints
|
||||||
, yClickPoints = yClickPoints
|
, yClickPoints = yClickPoints
|
||||||
, windowWidth = windowWidth
|
, windowWidth = windowWidth
|
||||||
@@ -422,6 +440,7 @@ struct
|
|||||||
val
|
val
|
||||||
{ xClickPoints
|
{ xClickPoints
|
||||||
, yClickPoints
|
, yClickPoints
|
||||||
|
, numClickPoints
|
||||||
, windowWidth
|
, windowWidth
|
||||||
, windowHeight
|
, windowHeight
|
||||||
, undo
|
, undo
|
||||||
@@ -442,6 +461,7 @@ struct
|
|||||||
, undo = []
|
, undo = []
|
||||||
, redo = []
|
, redo = []
|
||||||
, showGraph = showGraph
|
, showGraph = showGraph
|
||||||
|
, numClickPoints = numClickPoints
|
||||||
, xClickPoints = xClickPoints
|
, xClickPoints = xClickPoints
|
||||||
, yClickPoints = yClickPoints
|
, yClickPoints = yClickPoints
|
||||||
, windowWidth = windowWidth
|
, windowWidth = windowWidth
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
signature CLICK_POINTS =
|
signature CLICK_POINTS =
|
||||||
sig
|
sig
|
||||||
val generate: int * int -> Real32.real vector
|
val generate: int * int * int -> Real32.real vector
|
||||||
val getClickPositionFromMouse: AppType.app_type -> (int * int) option
|
val getClickPositionFromMouse: AppType.app_type -> (int * int) option
|
||||||
val getDrawDot:
|
val getDrawDot:
|
||||||
Real32.real
|
Real32.real
|
||||||
@@ -18,13 +18,14 @@ end
|
|||||||
|
|
||||||
structure ClickPoints :> CLICK_POINTS =
|
structure ClickPoints :> CLICK_POINTS =
|
||||||
struct
|
struct
|
||||||
fun generate (start, finish) =
|
fun generate (start, finish, numPoints) =
|
||||||
let
|
let
|
||||||
val difference = finish - start
|
val difference = finish - start
|
||||||
val increment = Real32.fromInt difference / 40.0
|
val increment = Real32.fromInt difference / Real32.fromInt numPoints
|
||||||
val start = Real32.fromInt start
|
val start = Real32.fromInt start
|
||||||
in
|
in
|
||||||
Vector.tabulate (41, fn idx => (Real32.fromInt idx * increment) + start)
|
Vector.tabulate (numPoints + 1, fn idx =>
|
||||||
|
(Real32.fromInt idx * increment) + start)
|
||||||
end
|
end
|
||||||
|
|
||||||
(*
|
(*
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ structure Constants =
|
|||||||
struct
|
struct
|
||||||
val windowWidth = 1000
|
val windowWidth = 1000
|
||||||
val windowHeight = 900
|
val windowHeight = 900
|
||||||
|
val initialNumClickPoints = 26
|
||||||
|
|
||||||
val graphVertexShaderString =
|
val graphVertexShaderString =
|
||||||
"#version 300 es\n\
|
"#version 300 es\n\
|
||||||
|
|||||||
@@ -15,9 +15,11 @@ struct
|
|||||||
val _ = Glfw.makeContextCurrent window
|
val _ = Glfw.makeContextCurrent window
|
||||||
val _ = Gles3.loadGlad ()
|
val _ = Gles3.loadGlad ()
|
||||||
|
|
||||||
val initialModel =
|
val initialModel = AppInit.fromWindowWidthAndHeight
|
||||||
AppInit.fromWindowWidthAndHeight
|
( Constants.windowWidth
|
||||||
(Constants.windowWidth, Constants.windowHeight)
|
, Constants.windowHeight
|
||||||
|
, Constants.initialNumClickPoints
|
||||||
|
)
|
||||||
|
|
||||||
val graphLines = GraphLines.generate initialModel
|
val graphLines = GraphLines.generate initialModel
|
||||||
val graphDrawObject = AppDraw.initGraphLines ()
|
val graphDrawObject = AppDraw.initGraphLines ()
|
||||||
|
|||||||
Reference in New Issue
Block a user