1330 lines
28 KiB
Standard ML
1330 lines
28 KiB
Standard ML
structure AppWith =
|
|
struct
|
|
open AppType
|
|
|
|
fun updateSquares (squares, newX, newY, item) =
|
|
let
|
|
val yAxis = Vector.sub (squares, newX)
|
|
val yAxis = Vector.update (yAxis, newY, item)
|
|
in
|
|
Vector.update (squares, newX, yAxis)
|
|
end
|
|
|
|
fun changeSquaresSize (squares, newCanvasWidth, newCanvasHeight) =
|
|
let
|
|
val maxPoints = Int.max (newCanvasWidth, newCanvasHeight)
|
|
in
|
|
Vector.tabulate (maxPoints, fn i =>
|
|
if i < Vector.length squares then
|
|
let
|
|
val yAxis = Vector.sub (squares, i)
|
|
in
|
|
Vector.tabulate (maxPoints, fn ii =>
|
|
if ii < Vector.length yAxis then Vector.sub (yAxis, ii)
|
|
else {r = 0, g = 0, b = 0, a = 0})
|
|
end
|
|
else
|
|
Vector.tabulate (maxPoints, fn _ => {r = 0, g = 0, b = 0, a = 0}))
|
|
end
|
|
|
|
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
|
|
, a
|
|
, layer
|
|
, layerTree
|
|
, modalNum
|
|
, undo
|
|
, redo
|
|
} = app
|
|
|
|
val item = {r = r, g = g, b = b, a = a}
|
|
val squares = updateSquares (squares, newX, newY, item)
|
|
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
|
|
, a = a
|
|
, layer = layer
|
|
, layerTree = layerTree
|
|
, modalNum = modalNum
|
|
, undo = undo
|
|
, redo = redo
|
|
}
|
|
end
|
|
|
|
fun deleteSquare (app, deleteX, deleteY, arrowX, arrowY) =
|
|
let
|
|
val
|
|
{ mode
|
|
, squares
|
|
, arrowX = _
|
|
, arrowY = _
|
|
, canvasWidth
|
|
, canvasHeight
|
|
, windowWidth
|
|
, windowHeight
|
|
, xClickPoints
|
|
, yClickPoints
|
|
|
|
, showGraph
|
|
, mouseX
|
|
, mouseY
|
|
, openFilePath
|
|
, fileBrowser
|
|
, fileBrowserIdx
|
|
, r
|
|
, g
|
|
, b
|
|
, a
|
|
, layer
|
|
, layerTree
|
|
, modalNum
|
|
, undo
|
|
, redo
|
|
} = app
|
|
|
|
val item = {r = 0, g = 0, b = 0, a = 0}
|
|
val squares = updateSquares (squares, deleteX, deleteY, item)
|
|
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
|
|
, a = a
|
|
, layer = layer
|
|
, layerTree = layerTree
|
|
, modalNum = modalNum
|
|
, undo = undo
|
|
, redo = redo
|
|
}
|
|
end
|
|
|
|
fun squares (app, newSquares) =
|
|
let
|
|
val
|
|
{ mode
|
|
, squares
|
|
, arrowX
|
|
, arrowY
|
|
, canvasWidth
|
|
, canvasHeight
|
|
, windowWidth
|
|
, windowHeight
|
|
, xClickPoints
|
|
, yClickPoints
|
|
|
|
, showGraph
|
|
, mouseX
|
|
, mouseY
|
|
, openFilePath
|
|
, fileBrowser
|
|
, fileBrowserIdx
|
|
, r
|
|
, g
|
|
, b
|
|
, a
|
|
, layer
|
|
, layerTree
|
|
, modalNum
|
|
, undo
|
|
, redo
|
|
} = app
|
|
in
|
|
{ mode = mode
|
|
, squares = newSquares
|
|
, 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
|
|
, a = a
|
|
, layer = layer
|
|
, layerTree = layerTree
|
|
, modalNum = modalNum
|
|
, undo = undo
|
|
, redo = redo
|
|
}
|
|
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
|
|
, a
|
|
, layer
|
|
, layerTree
|
|
, modalNum
|
|
, undo
|
|
, redo
|
|
} = 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
|
|
, a = a
|
|
, layer = layer
|
|
, layerTree = layerTree
|
|
, modalNum = modalNum
|
|
, undo = undo
|
|
, redo = redo
|
|
}
|
|
end
|
|
|
|
fun arrowY (app, arrowY) =
|
|
let
|
|
val
|
|
{ mode
|
|
, squares
|
|
, arrowX
|
|
, arrowY = _
|
|
, canvasWidth
|
|
, canvasHeight
|
|
, windowWidth
|
|
, windowHeight
|
|
, xClickPoints
|
|
, yClickPoints
|
|
|
|
, showGraph
|
|
, mouseX
|
|
, mouseY
|
|
, openFilePath
|
|
, fileBrowser
|
|
, fileBrowserIdx
|
|
, r
|
|
, g
|
|
, b
|
|
, a
|
|
, layer
|
|
, layerTree
|
|
, modalNum
|
|
, undo
|
|
, redo
|
|
} = 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
|
|
, a = a
|
|
, layer = layer
|
|
, layerTree = layerTree
|
|
, modalNum = modalNum
|
|
, undo = undo
|
|
, redo = redo
|
|
}
|
|
end
|
|
|
|
fun windowResize (app: app_type, windowWidth, windowHeight) : app_type =
|
|
let
|
|
val
|
|
{ mode
|
|
, xClickPoints = _
|
|
, yClickPoints = _
|
|
, windowWidth = _
|
|
, windowHeight = _
|
|
, squares
|
|
, arrowX
|
|
, arrowY
|
|
, canvasWidth
|
|
, canvasHeight
|
|
|
|
, showGraph
|
|
, mouseX
|
|
, mouseY
|
|
, openFilePath
|
|
, fileBrowser
|
|
, fileBrowserIdx
|
|
, r
|
|
, g
|
|
, b
|
|
, a
|
|
, layer
|
|
, layerTree
|
|
, modalNum
|
|
, undo
|
|
, redo
|
|
} = app
|
|
|
|
val (xClickPoints, yClickPoints) =
|
|
ClickPoints.generate
|
|
(windowWidth, windowHeight, canvasWidth, canvasHeight)
|
|
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
|
|
, a = a
|
|
, layer = layer
|
|
, layerTree = layerTree
|
|
, modalNum = modalNum
|
|
, undo = undo
|
|
, redo = redo
|
|
}
|
|
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
|
|
, a
|
|
, layer
|
|
, layerTree
|
|
, modalNum
|
|
, undo
|
|
, redo
|
|
} = 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
|
|
, a = a
|
|
, layer = layer
|
|
, layerTree = layerTree
|
|
, modalNum = modalNum
|
|
, undo = undo
|
|
, redo = redo
|
|
}
|
|
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
|
|
, a
|
|
, layer
|
|
, layerTree
|
|
, modalNum
|
|
, undo
|
|
, redo
|
|
} = 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
|
|
, a = a
|
|
, layer = layer
|
|
, layerTree = layerTree
|
|
, modalNum = modalNum
|
|
, undo = undo
|
|
, redo = redo
|
|
}
|
|
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
|
|
, a
|
|
, layer
|
|
, layerTree
|
|
, modalNum
|
|
, undo
|
|
, redo
|
|
} = 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
|
|
, a = a
|
|
, layer = layer
|
|
, layerTree = layerTree
|
|
, modalNum = modalNum
|
|
, undo = undo
|
|
, redo = redo
|
|
}
|
|
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
|
|
, a
|
|
, layer
|
|
, layerTree
|
|
, modalNum
|
|
, undo
|
|
, redo
|
|
} = 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
|
|
, a = a
|
|
, layer = layer
|
|
, layerTree = layerTree
|
|
, modalNum = modalNum
|
|
, undo = undo
|
|
, redo = redo
|
|
}
|
|
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
|
|
, a
|
|
, layer
|
|
, layerTree
|
|
, modalNum
|
|
, undo
|
|
, redo
|
|
} = 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
|
|
, a = a
|
|
, layer = layer
|
|
, layerTree = layerTree
|
|
, modalNum = modalNum
|
|
, undo = undo
|
|
, redo = redo
|
|
}
|
|
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
|
|
, a
|
|
, layer
|
|
, layerTree
|
|
, modalNum = prevNum
|
|
, undo
|
|
, redo
|
|
} = app
|
|
|
|
val newNum = (prevNum * 10) + newNum
|
|
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
|
|
, a = a
|
|
, layer = layer
|
|
, layerTree = layerTree
|
|
, modalNum = newNum
|
|
, undo = undo
|
|
, redo = redo
|
|
}
|
|
end
|
|
|
|
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
|
|
, a
|
|
, layer
|
|
, layerTree
|
|
, modalNum
|
|
, undo
|
|
, redo
|
|
} = app
|
|
|
|
val r = Int.min (modalNum, 255)
|
|
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
|
|
, a = a
|
|
, layer = layer
|
|
, layerTree = layerTree
|
|
, modalNum = 0
|
|
, undo = undo
|
|
, redo = redo
|
|
}
|
|
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
|
|
, a
|
|
, layer
|
|
, layerTree
|
|
, modalNum
|
|
, undo
|
|
, redo
|
|
} = app
|
|
|
|
val g = Int.min (modalNum, 255)
|
|
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
|
|
, a = a
|
|
, layer = layer
|
|
, layerTree = layerTree
|
|
, modalNum = 0
|
|
, undo = undo
|
|
, redo = redo
|
|
}
|
|
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 = _
|
|
, a
|
|
, layer
|
|
, layerTree
|
|
, modalNum
|
|
, undo
|
|
, redo
|
|
} = app
|
|
|
|
val b = Int.min (modalNum, 255)
|
|
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
|
|
, a = a
|
|
, layer = layer
|
|
, layerTree = layerTree
|
|
, modalNum = 0
|
|
, undo = undo
|
|
, redo = redo
|
|
}
|
|
end
|
|
|
|
fun a (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
|
|
, a = _
|
|
, layer
|
|
, layerTree
|
|
, modalNum
|
|
, undo
|
|
, redo
|
|
} = app
|
|
|
|
val a = Int.min (modalNum, 255)
|
|
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
|
|
, a = a
|
|
, layer = layer
|
|
, layerTree = layerTree
|
|
, modalNum = 0
|
|
, undo = undo
|
|
, redo = redo
|
|
}
|
|
end
|
|
|
|
fun layer (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
|
|
, a
|
|
, layer = _
|
|
, layerTree
|
|
, modalNum
|
|
, undo
|
|
, redo
|
|
} = app
|
|
|
|
val layer = 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
|
|
, a = a
|
|
, layer = layer
|
|
, layerTree = layerTree
|
|
, modalNum = modalNum
|
|
, undo = undo
|
|
, redo = redo
|
|
}
|
|
end
|
|
|
|
fun canvasWidth (app: app_type, newCanvasWidth) =
|
|
let
|
|
val
|
|
{ mode
|
|
, canvasWidth = _
|
|
, squares
|
|
, arrowX
|
|
, arrowY
|
|
, canvasHeight
|
|
, windowWidth
|
|
, windowHeight
|
|
, xClickPoints
|
|
, yClickPoints
|
|
|
|
, showGraph
|
|
, mouseX
|
|
, mouseY
|
|
, openFilePath
|
|
, fileBrowser
|
|
, fileBrowserIdx
|
|
, r
|
|
, g
|
|
, b
|
|
, a
|
|
, layer
|
|
, layerTree
|
|
, modalNum
|
|
, undo
|
|
, redo
|
|
} = app
|
|
|
|
val squares = changeSquaresSize (squares, newCanvasWidth, canvasHeight)
|
|
val arrowX = Int.min (arrowX, newCanvasWidth)
|
|
val (xClickPoints, yClickPoints) =
|
|
ClickPoints.generate
|
|
(windowWidth, windowHeight, newCanvasWidth, canvasHeight)
|
|
in
|
|
{ mode = mode
|
|
, canvasWidth = newCanvasWidth
|
|
, arrowX = arrowX
|
|
, mouseX = mouseX
|
|
, mouseY = mouseY
|
|
, squares = squares
|
|
, arrowY = arrowY
|
|
, canvasHeight = canvasHeight
|
|
, windowWidth = windowWidth
|
|
, windowHeight = windowHeight
|
|
, xClickPoints = xClickPoints
|
|
, yClickPoints = yClickPoints
|
|
|
|
, showGraph = showGraph
|
|
, openFilePath = openFilePath
|
|
, fileBrowser = fileBrowser
|
|
, fileBrowserIdx = fileBrowserIdx
|
|
, r = r
|
|
, g = g
|
|
, b = b
|
|
, a = a
|
|
, layer = layer
|
|
, layerTree = layerTree
|
|
, modalNum = 0
|
|
, undo = undo
|
|
, redo = redo
|
|
}
|
|
end
|
|
|
|
fun canvasHeight (app: app_type, newCanvasHeight) =
|
|
let
|
|
val
|
|
{ mode
|
|
, canvasHeight = _
|
|
, canvasWidth
|
|
, squares
|
|
, arrowX
|
|
, arrowY
|
|
, windowWidth
|
|
, windowHeight
|
|
, xClickPoints
|
|
, yClickPoints
|
|
|
|
, showGraph
|
|
, mouseX
|
|
, mouseY
|
|
, openFilePath
|
|
, fileBrowser
|
|
, fileBrowserIdx
|
|
, r
|
|
, g
|
|
, b
|
|
, a
|
|
, layer
|
|
, layerTree
|
|
, modalNum
|
|
, undo
|
|
, redo
|
|
} = app
|
|
|
|
val squares = changeSquaresSize (squares, canvasWidth, newCanvasHeight)
|
|
val arrowY = Int.min (arrowY, newCanvasHeight)
|
|
val (xClickPoints, yClickPoints) =
|
|
ClickPoints.generate
|
|
(windowWidth, windowHeight, canvasWidth, newCanvasHeight)
|
|
in
|
|
{ mode = mode
|
|
, canvasHeight = newCanvasHeight
|
|
, canvasWidth = canvasWidth
|
|
, arrowX = arrowX
|
|
, mouseX = mouseX
|
|
, mouseY = mouseY
|
|
, squares = squares
|
|
, arrowY = arrowY
|
|
, windowWidth = windowWidth
|
|
, windowHeight = windowHeight
|
|
, xClickPoints = xClickPoints
|
|
, yClickPoints = yClickPoints
|
|
|
|
, showGraph = showGraph
|
|
, openFilePath = openFilePath
|
|
, fileBrowser = fileBrowser
|
|
, fileBrowserIdx = fileBrowserIdx
|
|
, r = r
|
|
, g = g
|
|
, b = b
|
|
, a = a
|
|
, layer = layer
|
|
, layerTree = layerTree
|
|
, modalNum = 0
|
|
, undo = undo
|
|
, redo = redo
|
|
}
|
|
end
|
|
|
|
fun useSquares (app: app_type, squares, canvasWidth, canvasHeight) =
|
|
let
|
|
val
|
|
{ mode
|
|
, canvasHeight = _
|
|
, canvasWidth = _
|
|
, squares = _
|
|
, arrowX
|
|
, arrowY
|
|
, windowWidth
|
|
, windowHeight
|
|
, xClickPoints
|
|
, yClickPoints
|
|
|
|
, showGraph
|
|
, mouseX
|
|
, mouseY
|
|
, openFilePath
|
|
, fileBrowser
|
|
, fileBrowserIdx
|
|
, r
|
|
, g
|
|
, b
|
|
, a
|
|
, layer
|
|
, layerTree
|
|
, modalNum
|
|
, undo
|
|
, redo
|
|
} = app
|
|
|
|
val arrowX = Int.min (arrowX, canvasWidth)
|
|
val arrowY = Int.min (arrowY, canvasHeight)
|
|
val (xClickPoints, yClickPoints) =
|
|
ClickPoints.generate
|
|
(windowWidth, windowHeight, canvasWidth, canvasHeight)
|
|
in
|
|
{ mode = mode
|
|
, canvasHeight = canvasHeight
|
|
, canvasWidth = canvasWidth
|
|
, arrowX = arrowX
|
|
, mouseX = mouseX
|
|
, mouseY = mouseY
|
|
, squares = squares
|
|
, arrowY = arrowY
|
|
, windowWidth = windowWidth
|
|
, windowHeight = windowHeight
|
|
, xClickPoints = xClickPoints
|
|
, yClickPoints = yClickPoints
|
|
|
|
, showGraph = showGraph
|
|
, openFilePath = openFilePath
|
|
, fileBrowser = fileBrowser
|
|
, fileBrowserIdx = fileBrowserIdx
|
|
, r = r
|
|
, g = g
|
|
, b = b
|
|
, a = a
|
|
, layer = layer
|
|
, layerTree = layerTree
|
|
, modalNum = 0
|
|
, undo = undo
|
|
, redo = redo
|
|
}
|
|
end
|
|
|
|
fun cursorColour (app, r, g, b, a) =
|
|
let
|
|
val
|
|
{ mode
|
|
, canvasHeight
|
|
, canvasWidth
|
|
, squares
|
|
, arrowX
|
|
, arrowY
|
|
, windowWidth
|
|
, windowHeight
|
|
, xClickPoints
|
|
, yClickPoints
|
|
|
|
, showGraph
|
|
, mouseX
|
|
, mouseY
|
|
, openFilePath
|
|
, fileBrowser
|
|
, fileBrowserIdx
|
|
, r = _
|
|
, g = _
|
|
, b = _
|
|
, a = _
|
|
, layer
|
|
, layerTree
|
|
, modalNum
|
|
, undo
|
|
, redo
|
|
} = app
|
|
in
|
|
{ mode = mode
|
|
, canvasHeight = canvasHeight
|
|
, canvasWidth = canvasWidth
|
|
, arrowX = arrowX
|
|
, mouseX = mouseX
|
|
, mouseY = mouseY
|
|
, squares = squares
|
|
, arrowY = arrowY
|
|
, windowWidth = windowWidth
|
|
, windowHeight = windowHeight
|
|
, xClickPoints = xClickPoints
|
|
, yClickPoints = yClickPoints
|
|
|
|
, showGraph = showGraph
|
|
, openFilePath = openFilePath
|
|
, fileBrowser = fileBrowser
|
|
, fileBrowserIdx = fileBrowserIdx
|
|
, r = r
|
|
, g = g
|
|
, b = b
|
|
, a = a
|
|
, layer = layer
|
|
, layerTree = layerTree
|
|
, modalNum = 0
|
|
, undo = undo
|
|
, redo = redo
|
|
}
|
|
end
|
|
end
|