diff --git a/dotscape b/dotscape index 386c075..51dcc57 100755 Binary files a/dotscape and b/dotscape differ diff --git a/dotscape.mlb b/dotscape.mlb index 10e6668..0ed4285 100644 --- a/dotscape.mlb +++ b/dotscape.mlb @@ -25,6 +25,7 @@ fcore/quad-tree.sml fcore/common-update.sml fcore/normal-mode.sml fcore/browse-mode.sml +fcore/move-mode.sml fcore/app-update.sml (* pure file parsing functions *) diff --git a/fcore/app-type.sml b/fcore/app-type.sml index cac39c3..69111df 100644 --- a/fcore/app-type.sml +++ b/fcore/app-type.sml @@ -1,6 +1,6 @@ structure AppType = struct - datatype app_mode = NORMAL_MODE | BROWSE_MODE + datatype app_mode = NORMAL_MODE | BROWSE_MODE | MOVE_MODE datatype file_browser_item = IS_FILE of string | IS_FOLDER of string diff --git a/fcore/app-update.sml b/fcore/app-update.sml index 1d6469f..43df695 100644 --- a/fcore/app-update.sml +++ b/fcore/app-update.sml @@ -6,4 +6,5 @@ struct case #mode model of NORMAL_MODE => NormalMode.update (model, inputMsg) | BROWSE_MODE => BrowseMode.update (model, inputMsg) + | MOVE_MODE => MoveMode.update (model, inputMsg) end diff --git a/fcore/app-with.sml b/fcore/app-with.sml index 00702d9..9107802 100644 --- a/fcore/app-with.sml +++ b/fcore/app-with.sml @@ -145,6 +145,62 @@ struct } 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 + , 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 + , modalNum = modalNum + , undo = undo + , redo = redo + } + end + fun arrowX (app, arrowX) = let val diff --git a/fcore/move-mode.sml b/fcore/move-mode.sml new file mode 100644 index 0000000..eb4f96e --- /dev/null +++ b/fcore/move-mode.sml @@ -0,0 +1,35 @@ +structure MoveMode = +struct + open AppType + open InputMessage + + fun makeBlankYAxis length = + Vector.tabulate (length, fn _ => {r = 0, g = 0, b = 0, a = 0}) + + fun moveImageUp (model: app_type) = + let + val {squares, ...} = model + + val squares = + Vector.mapi + (fn (idx, yAxis) => + if idx + 1 < Vector.length squares then + Vector.sub (squares, idx + 1) + else + makeBlankYAxis (Vector.length yAxis)) squares + + val model = AppWith.squares (model, squares) + in + (model, []) + end + + fun update (model, inputMsg) = + case inputMsg of + ARROW_UP => moveImageUp model + (* + | ARROW_LEFT => moveImageLeft model + | ARROW_RIGHT => moveImageRight model + | ARROW_DOWN => moveImageDown model + *) + | _ => (model, []) +end diff --git a/green.dsc b/green.dsc new file mode 100644 index 0000000..d9b6004 --- /dev/null +++ b/green.dsc @@ -0,0 +1 @@ +25 25 { {0 10 0 12 25 25 25 1 } {1 9 1 9 25 25 25 1 } {2 10 2 14 25 25 25 1 } {3 8 3 9 25 25 25 1 } {3 15 3 15 25 25 25 1 } {4 7 5 7 25 25 25 1 } {4 16 6 18 25 25 25 1 } {5 16 5 19 25 25 25 1 } {6 8 6 8 25 25 25 1 } {7 7 9 7 25 25 25 1 } {7 15 7 15 25 25 25 1 } {8 16 10 18 25 25 25 1 } {9 16 9 19 25 25 25 1 } {10 8 10 8 25 25 25 1 } {11 7 13 7 25 25 25 1 } {11 15 11 15 25 25 25 1 } {12 16 14 18 25 25 25 1 } {13 16 13 19 25 25 25 1 } {14 8 14 8 25 25 25 1 } {15 7 17 7 25 25 25 1 } {15 15 15 15 25 25 25 1 } {16 16 18 18 25 25 25 1 } {17 16 17 19 25 25 25 1 } {18 8 18 8 25 25 25 1 } {19 9 19 15 25 25 25 1 } {19 14 23 14 25 25 25 1 } {20 4 20 5 25 25 25 1 } {20 7 20 8 25 25 25 1 } {21 6 23 6 25 25 25 1 } {24 4 24 5 25 25 25 1 } {24 7 24 13 25 25 25 1 } } \ No newline at end of file