create constant vector that looks like graph paper (grid for clicking points later)
This commit is contained in:
42
functional-core/app-type.sml
Normal file
42
functional-core/app-type.sml
Normal file
@@ -0,0 +1,42 @@
|
||||
structure AppType =
|
||||
struct
|
||||
type triangle =
|
||||
{ x1: Real32.real
|
||||
, y1: Real32.real
|
||||
, x2: Real32.real
|
||||
, y2: Real32.real
|
||||
, x3: Real32.real
|
||||
, y3: Real32.real
|
||||
}
|
||||
|
||||
datatype triangle_stage =
|
||||
NO_TRIANGLE
|
||||
(*
|
||||
* triangle_stage represents a work-in-progress triangle which is not fully completed,
|
||||
* because user has to click one (x, y) pair, then a second pair,
|
||||
* and then a third, to draw a complete triangle.
|
||||
*
|
||||
* There is no THIRD triangle_stage because that represents a complete triangle,
|
||||
* which should be added to the `triangles` list.
|
||||
*)
|
||||
| FIRST of {x1: Real32.real, y1: Real32.real}
|
||||
| SECOND of
|
||||
{x1: Real32.real, y1: Real32.real, x2: Real32.real, y2: Real32.real}
|
||||
|
||||
type app_type = {triangles: triangle list, triangleStage: triangle_stage}
|
||||
|
||||
local
|
||||
fun helpGetTrianglesVector (lst, acc) =
|
||||
case lst of
|
||||
{x1, y1, x2, y2, x3, y3} :: tl =>
|
||||
let val vec = Vector.fromList [x1, y1, x2, y2, x3, y3]
|
||||
in helpGetTrianglesVector (tl, vec :: acc)
|
||||
end
|
||||
| [] => acc
|
||||
in
|
||||
fun getTrianglesVector (app: app_type) =
|
||||
let val lst = helpGetTrianglseVector (#triangles app, [])
|
||||
in Vector.concat lst
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user