add functionality to flip drawing horizontally

This commit is contained in:
2025-08-12 22:25:16 +01:00
parent 55fe9b7605
commit 4a9b5947e7
9 changed files with 32 additions and 2 deletions

BIN
dotscape

Binary file not shown.

View File

@@ -32,4 +32,14 @@ struct
fun makeEmpty maxSide =
Vector.tabulate (maxSide, fn _ =>
Vector.tabulate (maxSide, fn _ => emptyPixel))
fun flipHorizontally (xAxis: t) =
Vector.mapi
(fn (xIdx, yAxis) =>
let
val flippedXIdx = Vector.length xAxis - 1 - xIdx
val flippedYAxis = Vector.sub (xAxis, flippedXIdx)
in
Vector.mapi (fn (yIdx, _) => Vector.sub (flippedYAxis, yIdx)) yAxis
end) xAxis
end

View File

@@ -107,4 +107,6 @@ struct
in
insert (key, grid, tree)
end
fun flipHorizontally tree = map (Grid.flipHorizontally, tree)
end

View File

@@ -369,6 +369,15 @@ struct
in (model, [])
end
fun flipHorizontally (model: app_type) =
let
val {layerTree, arrowX, arrowY, ...} = model
val layerTree = LayerTree.flipHorizontally layerTree
val model = AppWith.layerTree (model, layerTree, arrowX, arrowY)
in
getDrawMessage (model, [])
end
fun update (model: app_type, inputMsg) =
case inputMsg of
MOUSE_MOVE {x = mouseX, y = mouseY} =>
@@ -388,6 +397,7 @@ struct
| KEY_W => updateCanvasWidth model
| KEY_H => updateCanvasHeight model
| KEY_M => enterMoveMode model
| KEY_F => flipHorizontally model
| RESIZE_WINDOW {width, height} => resizeWindow (model, width, height)
| UNDO_ACTION => undoAction model
| REDO_ACTION => redoAction model

View File

@@ -24,6 +24,7 @@ int KEY_W = GLFW_KEY_W;
int KEY_H = GLFW_KEY_H;
int KEY_C = GLFW_KEY_C;
int KEY_M = GLFW_KEY_M;
int KEY_F = GLFW_KEY_F;
int KEY_ENTER = GLFW_KEY_ENTER;
int KEY_SPACE = GLFW_KEY_SPACE;

View File

@@ -41,6 +41,8 @@ struct
_symbol "KEY_C" public : ( unit -> int ) * ( int -> unit );
val (KEY_M, _) =
_symbol "KEY_M" public : ( unit -> int ) * ( int -> unit );
val (KEY_F, _) =
_symbol "KEY_F" public : ( unit -> int ) * ( int -> unit );
val (KEY_T, _) =
_symbol "KEY_T" public : ( unit -> int ) * ( int -> unit );

View File

@@ -1,3 +1,3 @@
24 3 {
[ {0 1 0 1 0 0 0 1 } {1 0 22 0 0 0 0 1 } {1 1 22 1 239 239 239 1 } {1 2 22 2 0 0 0 1 } {23 1 23 1 0 0 0 1 } ]
50 50 {
[ { 1 48 1 50 0 0 0 1 } { 1 49 18 50 0 0 0 1 } { 2 47 2 47 0 0 0 1 } { 3 46 3 46 0 0 0 1 } { 4 45 5 45 0 0 0 1 } { 6 44 7 44 0 0 0 1 } { 8 43 9 43 0 0 0 1 } { 10 38 10 42 0 0 0 1 } { 10 42 11 42 0 0 0 1 } { 11 35 11 37 0 0 0 1 } { 12 33 12 34 0 0 0 1 } { 13 31 13 32 0 0 0 1 } { 14 30 14 30 0 0 0 1 } { 15 29 15 29 0 0 0 1 } { 16 28 16 28 0 0 0 1 } { 17 25 17 27 0 0 0 1 } { 17 29 17 30 0 0 0 1 } { 17 42 18 42 0 0 0 1 } { 18 24 18 24 0 0 0 1 } { 18 31 18 32 0 0 0 1 } { 18 42 18 50 0 0 0 1 } { 19 23 19 23 0 0 0 1 } { 19 33 19 33 0 0 0 1 } { 19 39 19 41 0 0 0 1 } { 20 22 20 22 0 0 0 1 } { 20 30 20 32 0 0 0 1 } { 20 34 20 38 0 0 0 1 } { 21 27 21 29 0 0 0 1 } { 22 25 22 26 0 0 0 1 } { 23 24 23 24 0 0 0 1 } ]
}

View File

@@ -180,6 +180,10 @@ struct
key = Input.KEY_M () andalso action = Input.PRESS () andalso mods = 0
then
Mailbox.send (mailbox, KEY_M)
else if
key = Input.KEY_F () andalso action = Input.PRESS () andalso mods = 0
then
Mailbox.send (mailbox, KEY_F)
else
()

View File

@@ -17,6 +17,7 @@ struct
| KEY_M
| KEY_C
| KEY_L
| KEY_F
| KEY_BACKSPACE
| KEY_CTRL_S
| KEY_CTRL_L