progress towards saving export string in correct format (but note there is currently an exception somewhere because of changes; need to fix)

This commit is contained in:
2025-08-09 11:56:18 +01:00
parent 99a47a410f
commit d6f7583273
4 changed files with 27 additions and 8 deletions

View File

@@ -460,7 +460,7 @@ struct
fun toSaveStringFolder ({x, ex, y, ey, data = {r, g, b, a}}, acc) =
let
val item = String.concat
[ "{"
[ "["
, Int.toString x
, " "
, Int.toString y
@@ -476,20 +476,28 @@ struct
, Int.toString b
, " "
, Int.toString a
, " } "
, " ] "
]
in
item :: acc
end
fun toSaveString (squares, canvasWidth, canvasHeight) =
fun toSaveStringTreeFolder size (grid, acc) =
let
val qtree = buildTree (0, 0, size, grid)
val bintree = merge (qtree, grid)
val str = BinTree.foldr (toSaveStringFolder, bintree, [])
in
String.concat str :: acc
end
fun toSaveString (layerTree, canvasWidth, canvasHeight) =
let
val size = Int.max (canvasWidth, canvasHeight)
val qtree = buildTree (0, 0, size, squares)
val bintree = merge (qtree, squares)
val f = toSaveStringTreeFolder size
val initial = ["}"]
val acc = BinTree.foldr (toSaveStringFolder, bintree, initial)
val acc = LayerTree.foldr (f, layerTree, initial)
val acc =
String.concat
[Int.toString canvasWidth, " ", Int.toString canvasHeight, " { "]