begin refactoring to use square pixels instead of triangles, focusing on functional core first
This commit is contained in:
@@ -1,55 +1,4 @@
|
||||
signature APP_TYPE =
|
||||
sig
|
||||
datatype app_mode = NORMAL_MODE | BROWSE_MODE
|
||||
|
||||
datatype file_browser_item = IS_FILE of string | IS_FOLDER of string
|
||||
|
||||
datatype triangle_stage =
|
||||
NO_TRIANGLE
|
||||
| FIRST of {x1: Real32.real, y1: Real32.real}
|
||||
| SECOND of
|
||||
{x1: Real32.real, x2: Real32.real, y1: Real32.real, y2: Real32.real}
|
||||
|
||||
type triangle =
|
||||
{ x1: Real32.real
|
||||
, x2: Real32.real
|
||||
, x3: Real32.real
|
||||
, y1: Real32.real
|
||||
, y2: Real32.real
|
||||
, y3: Real32.real
|
||||
, r: Real32.real
|
||||
, g: Real32.real
|
||||
, b: Real32.real
|
||||
}
|
||||
|
||||
type app_type =
|
||||
{ mode: app_mode
|
||||
, triangles: triangle list
|
||||
, triangleStage: triangle_stage
|
||||
, windowWidth: int
|
||||
, windowHeight: int
|
||||
, numClickPointsX: int
|
||||
, numClickPointsY: int
|
||||
, xClickPoints: Real32.real vector
|
||||
, yClickPoints: Real32.real vector
|
||||
, undo: (Real32.real * Real32.real) list
|
||||
, redo: (Real32.real * Real32.real) list
|
||||
, showGraph: bool
|
||||
, mouseX: Real32.real
|
||||
, mouseY: Real32.real
|
||||
, arrowX: int
|
||||
, arrowY: int
|
||||
, openFilePath: string
|
||||
, fileBrowser: file_browser_item vector
|
||||
, fileBrowserIdx: int
|
||||
, r: Real32.real
|
||||
, g: Real32.real
|
||||
, b: Real32.real
|
||||
, num: int
|
||||
}
|
||||
end
|
||||
|
||||
structure AppType :> APP_TYPE =
|
||||
structure AppType =
|
||||
struct
|
||||
datatype app_mode = NORMAL_MODE | BROWSE_MODE
|
||||
|
||||
|
||||
@@ -1,73 +1,4 @@
|
||||
signature APP_WITH =
|
||||
sig
|
||||
val graphVisibility: AppType.app_type * bool -> AppType.app_type
|
||||
|
||||
val mode: AppType.app_type * AppType.app_mode -> AppType.app_type
|
||||
|
||||
val windowResize: AppType.app_type * int * int -> AppType.app_type
|
||||
|
||||
val mousePosition: AppType.app_type * Real32.real * Real32.real
|
||||
-> AppType.app_type
|
||||
|
||||
val fileBrowserAndPath:
|
||||
AppType.app_type * AppType.file_browser_item vector * string
|
||||
-> AppType.app_type
|
||||
|
||||
val fileBrowserIdx: AppType.app_type * int -> AppType.app_type
|
||||
|
||||
val arrowX: AppType.app_type * int -> AppType.app_type
|
||||
val arrowY: AppType.app_type * int -> AppType.app_type
|
||||
|
||||
val undo:
|
||||
AppType.app_type
|
||||
* AppType.triangle_stage
|
||||
* AppType.triangle list
|
||||
* (Real32.real * Real32.real)
|
||||
-> AppType.app_type
|
||||
|
||||
val redo:
|
||||
AppType.app_type
|
||||
* AppType.triangle_stage
|
||||
* AppType.triangle list
|
||||
* (Real32.real * Real32.real)
|
||||
-> AppType.app_type
|
||||
|
||||
(*
|
||||
* add functions clear the redo stack,
|
||||
* as they are meant to be called after a click action,
|
||||
* and also add new click position to undo stack.
|
||||
*)
|
||||
val addTriangleStage:
|
||||
AppType.app_type
|
||||
* AppType.triangle_stage
|
||||
* (Real32.real * Real32.real)
|
||||
* int
|
||||
* int
|
||||
-> AppType.app_type
|
||||
|
||||
val addTriangle:
|
||||
AppType.app_type
|
||||
* Real32.real
|
||||
* Real32.real
|
||||
* Real32.real
|
||||
* Real32.real
|
||||
* Real32.real
|
||||
* Real32.real
|
||||
* (Real32.real * Real32.real)
|
||||
* int
|
||||
* int
|
||||
-> AppType.app_type
|
||||
|
||||
val useTrianglesAndSetNormalMode: AppType.app_type * AppType.triangle list
|
||||
-> AppType.app_type
|
||||
|
||||
val num: AppType.app_type * int -> AppType.app_type
|
||||
val r: AppType.app_type -> AppType.app_type
|
||||
val g: AppType.app_type -> AppType.app_type
|
||||
val b: AppType.app_type -> AppType.app_type
|
||||
end
|
||||
|
||||
structure AppWith :> APP_WITH =
|
||||
structure AppWith =
|
||||
struct
|
||||
open AppType
|
||||
|
||||
|
||||
88
temp-squares/app-init.sml
Normal file
88
temp-squares/app-init.sml
Normal file
@@ -0,0 +1,88 @@
|
||||
signature APP_INIT =
|
||||
sig
|
||||
val fromWindowWidthAndHeight: int * int * int * int -> AppType.app_type
|
||||
end
|
||||
|
||||
structure AppInit :> APP_INIT =
|
||||
struct
|
||||
open AppType
|
||||
|
||||
fun helpFromWidthAndHeight
|
||||
( windowWidth
|
||||
, windowHeight
|
||||
, wStart
|
||||
, wFinish
|
||||
, hStart
|
||||
, hFinish
|
||||
, canvasWidth
|
||||
, canvasHeight
|
||||
) : app_type =
|
||||
let
|
||||
val xClickPoints = ClickPoints.generate (wStart, wFinish, canvasWidth)
|
||||
val yClickPoints = ClickPoints.generate (hStart, hFinish, canvasHeight)
|
||||
|
||||
val maxPoints = Int.max (canvasWidth, canvasHeight) + 1
|
||||
val squares = Vector.tabulate (maxPoints, fn _ =>
|
||||
Vector.tabulate (maxPoints, fn _ => 0))
|
||||
in
|
||||
{ mode = AppType.NORMAL_MODE
|
||||
, squares = squares
|
||||
, canvasWidth = canvasWidth
|
||||
, canvasHeight = canvasHeight
|
||||
, windowWidth = windowWidth
|
||||
, windowHeight = windowHeight
|
||||
, xClickPoints = xClickPoints
|
||||
, yClickPoints = yClickPoints
|
||||
|
||||
, mouseX = 0.0
|
||||
, mouseY = 0.0
|
||||
, showGraph = true
|
||||
, arrowX = 0
|
||||
, arrowY = 0
|
||||
, openFilePath = ""
|
||||
, fileBrowser = Vector.fromList []
|
||||
, fileBrowserIdx = 0
|
||||
, r = 0.0
|
||||
, g = 0.0
|
||||
, b = 0.0
|
||||
, modalNum = 0
|
||||
}
|
||||
end
|
||||
|
||||
fun fromWindowWidthAndHeight
|
||||
(windowWidth, windowHeight, canvasWidth, canvasHeight) =
|
||||
if windowWidth > windowHeight then
|
||||
let
|
||||
val difference = windowWidth - windowHeight
|
||||
val wStart = difference div 2
|
||||
val wFinish = wStart + windowHeight
|
||||
in
|
||||
helpFromWidthAndHeight
|
||||
( windowWidth
|
||||
, windowHeight
|
||||
, wStart
|
||||
, wFinish
|
||||
, 0
|
||||
, windowHeight
|
||||
, canvasWidth
|
||||
, canvasHeight
|
||||
)
|
||||
end
|
||||
else
|
||||
let
|
||||
val difference = windowHeight - windowWidth
|
||||
val hStart = difference div 2
|
||||
val hFinish = hStart + windowWidth
|
||||
in
|
||||
helpFromWidthAndHeight
|
||||
( windowWidth
|
||||
, windowHeight
|
||||
, 0
|
||||
, windowWidth
|
||||
, hStart
|
||||
, hFinish
|
||||
, canvasWidth
|
||||
, canvasHeight
|
||||
)
|
||||
end
|
||||
end
|
||||
35
temp-squares/app-type.sml
Normal file
35
temp-squares/app-type.sml
Normal file
@@ -0,0 +1,35 @@
|
||||
structure AppType =
|
||||
struct
|
||||
datatype app_mode = NORMAL_MODE | BROWSE_MODE
|
||||
|
||||
datatype file_browser_item = IS_FILE of string | IS_FOLDER of string
|
||||
|
||||
type app_type =
|
||||
{ mode: app_mode
|
||||
, squares: int vector vector
|
||||
, canvasWidth: int
|
||||
, canvasHeight: int
|
||||
, windowWidth: int
|
||||
, windowHeight: int
|
||||
, xClickPoints: Real32.real vector
|
||||
, yClickPoints: Real32.real vector
|
||||
|
||||
(* undo and redo commented out temporarily
|
||||
, undo: (Real32.real * Real32.real) list
|
||||
, redo: (Real32.real * Real32.real) list
|
||||
*)
|
||||
|
||||
, showGraph: bool
|
||||
, mouseX: Real32.real
|
||||
, mouseY: Real32.real
|
||||
, arrowX: int
|
||||
, arrowY: int
|
||||
, openFilePath: string
|
||||
, fileBrowser: file_browser_item vector
|
||||
, fileBrowserIdx: int
|
||||
, r: Real32.real
|
||||
, g: Real32.real
|
||||
, b: Real32.real
|
||||
, modalNum: int
|
||||
}
|
||||
end
|
||||
703
temp-squares/app-with.sml
Normal file
703
temp-squares/app-with.sml
Normal file
@@ -0,0 +1,703 @@
|
||||
structure AppWith =
|
||||
struct
|
||||
open AppType
|
||||
|
||||
fun addSquare (app, newX, newY, arrowX, arrowY) : app_type =
|
||||
let
|
||||
val
|
||||
{ mode
|
||||
, squares
|
||||
, arrowX = _
|
||||
, arrowY = _
|
||||
, canvasWidth
|
||||
, canvasHeight
|
||||
, windowWidth
|
||||
, windowHeight
|
||||
, xClickPoints
|
||||
, yClickPoints
|
||||
|
||||
, showGraph
|
||||
, mouseX
|
||||
, mouseY
|
||||
, openFilePath
|
||||
, fileBrowser
|
||||
, fileBrowserIdx
|
||||
, r
|
||||
, g
|
||||
, b
|
||||
, modalNum
|
||||
} = app
|
||||
|
||||
val squares =
|
||||
Vector.mapi
|
||||
(fn (idx, el) =>
|
||||
if idx = newX then
|
||||
Vector.mapi (fn (iidx, iel) => if iidx = newY then 1 else iel) el
|
||||
else
|
||||
el) squares
|
||||
in
|
||||
{ mode = mode
|
||||
, squares = squares
|
||||
, arrowX = arrowX
|
||||
, arrowY = arrowY
|
||||
, canvasWidth = canvasWidth
|
||||
, canvasHeight = canvasHeight
|
||||
, windowWidth = windowWidth
|
||||
, windowHeight = windowHeight
|
||||
, xClickPoints = xClickPoints
|
||||
, yClickPoints = yClickPoints
|
||||
|
||||
, showGraph = showGraph
|
||||
, mouseX = mouseX
|
||||
, mouseY = mouseY
|
||||
, openFilePath = openFilePath
|
||||
, fileBrowser = fileBrowser
|
||||
, fileBrowserIdx = fileBrowserIdx
|
||||
, r = r
|
||||
, g = g
|
||||
, b = b
|
||||
, modalNum = modalNum
|
||||
}
|
||||
end
|
||||
|
||||
fun arrowX (app, arrowX) =
|
||||
let
|
||||
val
|
||||
{ mode
|
||||
, squares
|
||||
, arrowX = _
|
||||
, arrowY
|
||||
, canvasWidth
|
||||
, canvasHeight
|
||||
, windowWidth
|
||||
, windowHeight
|
||||
, xClickPoints
|
||||
, yClickPoints
|
||||
|
||||
, showGraph
|
||||
, mouseX
|
||||
, mouseY
|
||||
, openFilePath
|
||||
, fileBrowser
|
||||
, fileBrowserIdx
|
||||
, r
|
||||
, g
|
||||
, b
|
||||
, modalNum
|
||||
} = app
|
||||
in
|
||||
{ mode = mode
|
||||
, squares = squares
|
||||
, arrowX = arrowX
|
||||
, arrowY = arrowY
|
||||
, canvasWidth = canvasWidth
|
||||
, canvasHeight = canvasHeight
|
||||
, windowWidth = windowWidth
|
||||
, windowHeight = windowHeight
|
||||
, xClickPoints = xClickPoints
|
||||
, yClickPoints = yClickPoints
|
||||
|
||||
, showGraph = showGraph
|
||||
, mouseX = mouseX
|
||||
, mouseY = mouseY
|
||||
, openFilePath = openFilePath
|
||||
, fileBrowser = fileBrowser
|
||||
, fileBrowserIdx = fileBrowserIdx
|
||||
, r = r
|
||||
, g = g
|
||||
, b = b
|
||||
, modalNum = modalNum
|
||||
}
|
||||
end
|
||||
|
||||
fun arrowX (app, arrowY) =
|
||||
let
|
||||
val
|
||||
{ mode
|
||||
, squares
|
||||
, arrowX
|
||||
, arrowY = _
|
||||
, canvasWidth
|
||||
, canvasHeight
|
||||
, windowWidth
|
||||
, windowHeight
|
||||
, xClickPoints
|
||||
, yClickPoints
|
||||
|
||||
, showGraph
|
||||
, mouseX
|
||||
, mouseY
|
||||
, openFilePath
|
||||
, fileBrowser
|
||||
, fileBrowserIdx
|
||||
, r
|
||||
, g
|
||||
, b
|
||||
, modalNum
|
||||
} = app
|
||||
in
|
||||
{ mode = mode
|
||||
, squares = squares
|
||||
, arrowX = arrowX
|
||||
, arrowY = arrowY
|
||||
, canvasWidth = canvasWidth
|
||||
, canvasHeight = canvasHeight
|
||||
, windowWidth = windowWidth
|
||||
, windowHeight = windowHeight
|
||||
, xClickPoints = xClickPoints
|
||||
, yClickPoints = yClickPoints
|
||||
|
||||
, showGraph = showGraph
|
||||
, mouseX = mouseX
|
||||
, mouseY = mouseY
|
||||
, openFilePath = openFilePath
|
||||
, fileBrowser = fileBrowser
|
||||
, fileBrowserIdx = fileBrowserIdx
|
||||
, r = r
|
||||
, g = g
|
||||
, b = b
|
||||
, modalNum = modalNum
|
||||
}
|
||||
end
|
||||
|
||||
fun helpWindowResize
|
||||
(app: app_type, windowWidth, windowHeight, wStart, wFinish, hStart, hFinish) :
|
||||
app_type =
|
||||
let
|
||||
val
|
||||
{ mode
|
||||
, xClickPoints = _
|
||||
, yClickPoints = _
|
||||
, windowWidth = _
|
||||
, windowHeight = _
|
||||
, squares
|
||||
, arrowX
|
||||
, arrowY
|
||||
, canvasWidth
|
||||
, canvasHeight
|
||||
|
||||
, showGraph
|
||||
, mouseX
|
||||
, mouseY
|
||||
, openFilePath
|
||||
, fileBrowser
|
||||
, fileBrowserIdx
|
||||
, r
|
||||
, g
|
||||
, b
|
||||
, modalNum
|
||||
} = app
|
||||
|
||||
val maxPoints = Int.max (canvasWidth, canvasHeight) + 1
|
||||
val xClickPoints = ClickPoints.generate (wStart, wFinish, maxPoints)
|
||||
val yClickPoints = ClickPoints.generate (hStart, hFinish, maxPoints)
|
||||
in
|
||||
{ mode = mode
|
||||
, squares = squares
|
||||
, arrowX = arrowX
|
||||
, arrowY = arrowY
|
||||
, canvasWidth = canvasWidth
|
||||
, canvasHeight = canvasHeight
|
||||
, windowWidth = windowWidth
|
||||
, windowHeight = windowHeight
|
||||
, xClickPoints = xClickPoints
|
||||
, yClickPoints = yClickPoints
|
||||
|
||||
, showGraph = showGraph
|
||||
, mouseX = mouseX
|
||||
, mouseY = mouseY
|
||||
, openFilePath = openFilePath
|
||||
, fileBrowser = fileBrowser
|
||||
, fileBrowserIdx = fileBrowserIdx
|
||||
, r = r
|
||||
, g = g
|
||||
, b = b
|
||||
, modalNum = modalNum
|
||||
}
|
||||
end
|
||||
|
||||
fun windowResize (app: app_type, windowWidth, windowHeight) =
|
||||
if windowWidth = windowHeight then
|
||||
helpWindowResize
|
||||
(app, windowWidth, windowHeight, 0, windowWidth, 0, windowHeight)
|
||||
else if windowWidth > windowHeight then
|
||||
let
|
||||
val difference = windowWidth - windowHeight
|
||||
val wStart = difference div 2
|
||||
val wFinish = wStart + windowHeight
|
||||
in
|
||||
helpWindowResize
|
||||
(app, windowWidth, windowHeight, wStart, wFinish, 0, windowHeight)
|
||||
end
|
||||
else
|
||||
let
|
||||
val difference = windowHeight - windowWidth
|
||||
val hStart = difference div 2
|
||||
val hFinish = hStart + windowWidth
|
||||
in
|
||||
helpWindowResize
|
||||
(app, windowWidth, windowHeight, 0, windowWidth, hStart, hFinish)
|
||||
end
|
||||
|
||||
fun mousePosition (app: app_type, mouseX, mouseY) =
|
||||
let
|
||||
val
|
||||
{ mode
|
||||
, mouseX = _
|
||||
, mouseY = _
|
||||
, xClickPoints
|
||||
, yClickPoints
|
||||
, windowWidth
|
||||
, windowHeight
|
||||
, squares
|
||||
, arrowX
|
||||
, arrowY
|
||||
, canvasWidth
|
||||
, canvasHeight
|
||||
|
||||
, showGraph
|
||||
, openFilePath
|
||||
, fileBrowser
|
||||
, fileBrowserIdx
|
||||
, r
|
||||
, g
|
||||
, b
|
||||
, modalNum
|
||||
} = app
|
||||
in
|
||||
{ mode = mode
|
||||
, mouseX = mouseX
|
||||
, mouseY = mouseY
|
||||
, squares = squares
|
||||
, arrowX = arrowX
|
||||
, arrowY = arrowY
|
||||
, canvasWidth = canvasWidth
|
||||
, canvasHeight = canvasHeight
|
||||
, windowWidth = windowWidth
|
||||
, windowHeight = windowHeight
|
||||
, xClickPoints = xClickPoints
|
||||
, yClickPoints = yClickPoints
|
||||
|
||||
, showGraph = showGraph
|
||||
, openFilePath = openFilePath
|
||||
, fileBrowser = fileBrowser
|
||||
, fileBrowserIdx = fileBrowserIdx
|
||||
, r = r
|
||||
, g = g
|
||||
, b = b
|
||||
, modalNum = modalNum
|
||||
}
|
||||
end
|
||||
|
||||
fun graphVisibility (app: app_type, shouldShowGraph) =
|
||||
let
|
||||
val
|
||||
{ mode
|
||||
, mouseX
|
||||
, mouseY
|
||||
, xClickPoints
|
||||
, yClickPoints
|
||||
, windowWidth
|
||||
, windowHeight
|
||||
, squares
|
||||
, arrowX
|
||||
, arrowY
|
||||
, canvasWidth
|
||||
, canvasHeight
|
||||
|
||||
, showGraph = _
|
||||
, openFilePath
|
||||
, fileBrowser
|
||||
, fileBrowserIdx
|
||||
, r
|
||||
, g
|
||||
, b
|
||||
, modalNum
|
||||
} = app
|
||||
in
|
||||
{ mode = mode
|
||||
, mouseX = mouseX
|
||||
, mouseY = mouseY
|
||||
, squares = squares
|
||||
, arrowX = arrowX
|
||||
, arrowY = arrowY
|
||||
, canvasWidth = canvasWidth
|
||||
, canvasHeight = canvasHeight
|
||||
, windowWidth = windowWidth
|
||||
, windowHeight = windowHeight
|
||||
, xClickPoints = xClickPoints
|
||||
, yClickPoints = yClickPoints
|
||||
|
||||
, showGraph = shouldShowGraph
|
||||
, openFilePath = openFilePath
|
||||
, fileBrowser = fileBrowser
|
||||
, fileBrowserIdx = fileBrowserIdx
|
||||
, r = r
|
||||
, g = g
|
||||
, b = b
|
||||
, modalNum = modalNum
|
||||
}
|
||||
end
|
||||
|
||||
fun mode (app: app_type, newMode) =
|
||||
let
|
||||
val
|
||||
{ mode = _
|
||||
, mouseX
|
||||
, mouseY
|
||||
, xClickPoints
|
||||
, yClickPoints
|
||||
, windowWidth
|
||||
, windowHeight
|
||||
, squares
|
||||
, arrowX
|
||||
, arrowY
|
||||
, canvasWidth
|
||||
, canvasHeight
|
||||
|
||||
, showGraph
|
||||
, openFilePath
|
||||
, fileBrowser
|
||||
, fileBrowserIdx
|
||||
, r
|
||||
, g
|
||||
, b
|
||||
, modalNum
|
||||
} = app
|
||||
in
|
||||
{ mode = newMode
|
||||
, mouseX = mouseX
|
||||
, mouseY = mouseY
|
||||
, squares = squares
|
||||
, arrowX = arrowX
|
||||
, arrowY = arrowY
|
||||
, canvasWidth = canvasWidth
|
||||
, canvasHeight = canvasHeight
|
||||
, windowWidth = windowWidth
|
||||
, windowHeight = windowHeight
|
||||
, xClickPoints = xClickPoints
|
||||
, yClickPoints = yClickPoints
|
||||
|
||||
, showGraph = showGraph
|
||||
, openFilePath = openFilePath
|
||||
, fileBrowser = fileBrowser
|
||||
, fileBrowserIdx = fileBrowserIdx
|
||||
, r = r
|
||||
, g = g
|
||||
, b = b
|
||||
, modalNum = modalNum
|
||||
}
|
||||
end
|
||||
|
||||
fun fileBrowserAndPath (app: app_type, fileBrowser, path) =
|
||||
let
|
||||
val
|
||||
{ mode
|
||||
, mouseX
|
||||
, mouseY
|
||||
, xClickPoints
|
||||
, yClickPoints
|
||||
, windowWidth
|
||||
, windowHeight
|
||||
, squares
|
||||
, arrowX
|
||||
, arrowY
|
||||
, canvasWidth
|
||||
, canvasHeight
|
||||
|
||||
, showGraph
|
||||
, openFilePath = _
|
||||
, fileBrowser = _
|
||||
, fileBrowserIdx
|
||||
, r
|
||||
, g
|
||||
, b
|
||||
, modalNum
|
||||
} = app
|
||||
in
|
||||
{ mode = mode
|
||||
, mouseX = mouseX
|
||||
, mouseY = mouseY
|
||||
, squares = squares
|
||||
, arrowX = arrowX
|
||||
, arrowY = arrowY
|
||||
, canvasWidth = canvasWidth
|
||||
, canvasHeight = canvasHeight
|
||||
, windowWidth = windowWidth
|
||||
, windowHeight = windowHeight
|
||||
, xClickPoints = xClickPoints
|
||||
, yClickPoints = yClickPoints
|
||||
|
||||
, showGraph = showGraph
|
||||
, openFilePath = path
|
||||
, fileBrowser = fileBrowser
|
||||
, fileBrowserIdx = 0
|
||||
, r = r
|
||||
, g = g
|
||||
, b = b
|
||||
, modalNum = modalNum
|
||||
}
|
||||
end
|
||||
|
||||
fun fileBrowserIdx (app: app_type, newFileBrowserIdx) =
|
||||
let
|
||||
val
|
||||
{ mode
|
||||
, mouseX
|
||||
, mouseY
|
||||
, xClickPoints
|
||||
, yClickPoints
|
||||
, windowWidth
|
||||
, windowHeight
|
||||
, squares
|
||||
, arrowX
|
||||
, arrowY
|
||||
, canvasWidth
|
||||
, canvasHeight
|
||||
|
||||
, showGraph
|
||||
, openFilePath
|
||||
, fileBrowser
|
||||
, fileBrowserIdx = _
|
||||
, r
|
||||
, g
|
||||
, b
|
||||
, modalNum
|
||||
} = app
|
||||
in
|
||||
{ mode = mode
|
||||
, mouseX = mouseX
|
||||
, mouseY = mouseY
|
||||
, squares = squares
|
||||
, arrowX = arrowX
|
||||
, arrowY = arrowY
|
||||
, canvasWidth = canvasWidth
|
||||
, canvasHeight = canvasHeight
|
||||
, windowWidth = windowWidth
|
||||
, windowHeight = windowHeight
|
||||
, xClickPoints = xClickPoints
|
||||
, yClickPoints = yClickPoints
|
||||
|
||||
, showGraph = showGraph
|
||||
, openFilePath = openFilePath
|
||||
, fileBrowser = fileBrowser
|
||||
, fileBrowserIdx = newFileBrowserIdx
|
||||
, r = r
|
||||
, g = g
|
||||
, b = b
|
||||
, modalNum = modalNum
|
||||
}
|
||||
end
|
||||
|
||||
fun modalNum (app: app_type, newNum) : app_type =
|
||||
let
|
||||
val
|
||||
{ mode
|
||||
, mouseX
|
||||
, mouseY
|
||||
, xClickPoints
|
||||
, yClickPoints
|
||||
, windowWidth
|
||||
, windowHeight
|
||||
, squares
|
||||
, arrowX
|
||||
, arrowY
|
||||
, canvasWidth
|
||||
, canvasHeight
|
||||
|
||||
, showGraph
|
||||
, openFilePath
|
||||
, fileBrowser
|
||||
, fileBrowserIdx
|
||||
, r
|
||||
, g
|
||||
, b
|
||||
, modalNum = _
|
||||
} = app
|
||||
in
|
||||
{ mode = mode
|
||||
, mouseX = mouseX
|
||||
, mouseY = mouseY
|
||||
, squares = squares
|
||||
, arrowX = arrowX
|
||||
, arrowY = arrowY
|
||||
, canvasWidth = canvasWidth
|
||||
, canvasHeight = canvasHeight
|
||||
, windowWidth = windowWidth
|
||||
, windowHeight = windowHeight
|
||||
, xClickPoints = xClickPoints
|
||||
, yClickPoints = yClickPoints
|
||||
|
||||
, showGraph = showGraph
|
||||
, openFilePath = openFilePath
|
||||
, fileBrowser = fileBrowser
|
||||
, fileBrowserIdx = fileBrowserIdx
|
||||
, r = r
|
||||
, g = g
|
||||
, b = b
|
||||
, modalNum = newNum
|
||||
}
|
||||
end
|
||||
|
||||
fun modalNumToFloat num = Real32.fromInt num / 255.0
|
||||
|
||||
fun r (app: app_type) : app_type =
|
||||
let
|
||||
val
|
||||
{ mode
|
||||
, mouseX
|
||||
, mouseY
|
||||
, xClickPoints
|
||||
, yClickPoints
|
||||
, windowWidth
|
||||
, windowHeight
|
||||
, squares
|
||||
, arrowX
|
||||
, arrowY
|
||||
, canvasWidth
|
||||
, canvasHeight
|
||||
|
||||
, showGraph
|
||||
, openFilePath
|
||||
, fileBrowser
|
||||
, fileBrowserIdx
|
||||
, r = _
|
||||
, g
|
||||
, b
|
||||
, modalNum
|
||||
} = app
|
||||
|
||||
val r = modalNumToFloat modalNum
|
||||
in
|
||||
{ mode = mode
|
||||
, mouseX = mouseX
|
||||
, mouseY = mouseY
|
||||
, squares = squares
|
||||
, arrowX = arrowX
|
||||
, arrowY = arrowY
|
||||
, canvasWidth = canvasWidth
|
||||
, canvasHeight = canvasHeight
|
||||
, windowWidth = windowWidth
|
||||
, windowHeight = windowHeight
|
||||
, xClickPoints = xClickPoints
|
||||
, yClickPoints = yClickPoints
|
||||
|
||||
, showGraph = showGraph
|
||||
, openFilePath = openFilePath
|
||||
, fileBrowser = fileBrowser
|
||||
, fileBrowserIdx = fileBrowserIdx
|
||||
, r = r
|
||||
, g = g
|
||||
, b = b
|
||||
, modalNum = modalNum
|
||||
}
|
||||
end
|
||||
|
||||
fun g (app: app_type) : app_type =
|
||||
let
|
||||
val
|
||||
{ mode
|
||||
, mouseX
|
||||
, mouseY
|
||||
, xClickPoints
|
||||
, yClickPoints
|
||||
, windowWidth
|
||||
, windowHeight
|
||||
, squares
|
||||
, arrowX
|
||||
, arrowY
|
||||
, canvasWidth
|
||||
, canvasHeight
|
||||
|
||||
, showGraph
|
||||
, openFilePath
|
||||
, fileBrowser
|
||||
, fileBrowserIdx
|
||||
, r
|
||||
, g = _
|
||||
, b
|
||||
, modalNum
|
||||
} = app
|
||||
|
||||
val g = modalNumToFloat modalNum
|
||||
in
|
||||
{ mode = mode
|
||||
, mouseX = mouseX
|
||||
, mouseY = mouseY
|
||||
, squares = squares
|
||||
, arrowX = arrowX
|
||||
, arrowY = arrowY
|
||||
, canvasWidth = canvasWidth
|
||||
, canvasHeight = canvasHeight
|
||||
, windowWidth = windowWidth
|
||||
, windowHeight = windowHeight
|
||||
, xClickPoints = xClickPoints
|
||||
, yClickPoints = yClickPoints
|
||||
|
||||
, showGraph = showGraph
|
||||
, openFilePath = openFilePath
|
||||
, fileBrowser = fileBrowser
|
||||
, fileBrowserIdx = fileBrowserIdx
|
||||
, r = r
|
||||
, g = g
|
||||
, b = b
|
||||
, modalNum = modalNum
|
||||
}
|
||||
end
|
||||
|
||||
fun b (app: app_type) : app_type =
|
||||
let
|
||||
val
|
||||
{ mode
|
||||
, mouseX
|
||||
, mouseY
|
||||
, xClickPoints
|
||||
, yClickPoints
|
||||
, windowWidth
|
||||
, windowHeight
|
||||
, squares
|
||||
, arrowX
|
||||
, arrowY
|
||||
, canvasWidth
|
||||
, canvasHeight
|
||||
|
||||
, showGraph
|
||||
, openFilePath
|
||||
, fileBrowser
|
||||
, fileBrowserIdx
|
||||
, r
|
||||
, g
|
||||
, b = _
|
||||
, modalNum
|
||||
} = app
|
||||
|
||||
val b = modalNumToFloat modalNum
|
||||
in
|
||||
{ mode = mode
|
||||
, mouseX = mouseX
|
||||
, mouseY = mouseY
|
||||
, squares = squares
|
||||
, arrowX = arrowX
|
||||
, arrowY = arrowY
|
||||
, canvasWidth = canvasWidth
|
||||
, canvasHeight = canvasHeight
|
||||
, windowWidth = windowWidth
|
||||
, windowHeight = windowHeight
|
||||
, xClickPoints = xClickPoints
|
||||
, yClickPoints = yClickPoints
|
||||
|
||||
, showGraph = showGraph
|
||||
, openFilePath = openFilePath
|
||||
, fileBrowser = fileBrowser
|
||||
, fileBrowserIdx = fileBrowserIdx
|
||||
, r = r
|
||||
, g = g
|
||||
, b = b
|
||||
, modalNum = modalNum
|
||||
}
|
||||
end
|
||||
|
||||
(* todo:
|
||||
fun useSquaresAndSetNormalMode (app: app_type, squares, canvasWidth, canvasHeight) =
|
||||
*)
|
||||
end
|
||||
12
temp-squares/click-points.sml
Normal file
12
temp-squares/click-points.sml
Normal file
@@ -0,0 +1,12 @@
|
||||
structure ClickPoints =
|
||||
struct
|
||||
fun generate (start, finish, numPoints) =
|
||||
let
|
||||
val difference = finish - start
|
||||
val increment = Real32.fromInt difference / Real32.fromInt numPoints
|
||||
val start = Real32.fromInt start
|
||||
in
|
||||
Vector.tabulate (numPoints + 1, fn idx =>
|
||||
(Real32.fromInt idx * increment) + start)
|
||||
end
|
||||
end
|
||||
8
temp-squares/temp.mlb
Normal file
8
temp-squares/temp.mlb
Normal file
@@ -0,0 +1,8 @@
|
||||
$(SML_LIB)/basis/basis.mlb
|
||||
|
||||
(* FUNCTIONAL CORE *)
|
||||
app-type.sml
|
||||
click-points.sml
|
||||
app-init.sml
|
||||
app-with.sml
|
||||
|
||||
Reference in New Issue
Block a user