add function to quad tree to turn items into strings (for later saving to file)

This commit is contained in:
2025-07-12 03:38:20 +01:00
parent 21512cc979
commit 04bb7a18c0
15 changed files with 50 additions and 15 deletions

View File

@@ -500,4 +500,39 @@ struct
in
Vector.concat vec
end
fun toStringFolder ({x, ex, y, ey, data = {r, g, b, a}}, acc) =
let
val item = String.concat
[ "{"
, Int.toString x
, " "
, Int.toString y
, " "
, Int.toString ex
, " "
, Int.toString ey
, " "
, Int.toString r
, " "
, Int.toString g
, " "
, Int.toString b
, " "
, Int.toString a
, " }"
]
in
item :: acc
end
fun toString (squares, size) =
let
val qtree = buildTree (0, 0, size, squares)
val bintree = merge (qtree, squares)
val vec = BinTree.foldr (toStringFolder, bintree, [])
in
Vector.concat vec
end
end