finished coding merging functionality

This commit is contained in:
2025-07-08 16:59:21 +01:00
parent 1ae67bb616
commit 3fe3aa1d4d
2 changed files with 13 additions and 22 deletions

BIN
dotscape

Binary file not shown.

View File

@@ -320,13 +320,12 @@ struct
local local
fun loop (x, y, ex, ey, grid) = fun loop (x, y, ex, ey, grid) =
if x > 0 then if x < 0 then
if quadHasSameColour (x, y, ex, ey, grid) then
loop (x - 1, y, x, ey, grid)
else
ex
else
0 0
else if quadHasSameColour (x, y, ex, ey, grid) then
loop (x - 1, y, x, ey, grid)
else
ex
in in
fun getLeftmostX ({x, y, ex, ey, data}, grid) = fun getLeftmostX ({x, y, ex, ey, data}, grid) =
loop (x - 1, y, x, ey, grid) loop (x - 1, y, x, ey, grid)
@@ -348,7 +347,7 @@ struct
local local
fun loop (x, y, ex, ey, grid) = fun loop (x, y, ex, ey, grid) =
if y = 0 orelse ey = 0 then if y < 0 then
0 0
else if quadHasSameColour (x, y, ex, ey, grid) then else if quadHasSameColour (x, y, ex, ey, grid) then
loop (x, y - 1, ex, y, grid) loop (x, y - 1, ex, y, grid)
@@ -356,7 +355,7 @@ struct
ey ey
in in
fun getTopmostY ({x, y, ex, ey, data}, grid) = fun getTopmostY ({x, y, ex, ey, data}, grid) =
if y <= 0 orelse ey <= 0 then if y < 0 orelse ey <= 0 then
0 0
else if quadHasSameColour (x, y, ex, ey, grid) then else if quadHasSameColour (x, y, ex, ey, grid) then
loop (x, y - 1, ex, y, grid) loop (x, y - 1, ex, y, grid)
@@ -465,13 +464,14 @@ struct
end end
fun merge (tree, grid) = fun merge (tree, grid) =
let val tree = mergeVertical (tree, grid) let
in toBintree tree val tree = mergeVertical (tree, grid)
val tree = mergeHorizontal (tree, grid)
in
toBintree tree
end end
(* temporarily shadow previous "toTriangles" function. fun toTrianglesMerged
* When this is done being implemented, rename to "toTrianglesCompressed" *)
fun toTriangles
( windowWidth ( windowWidth
, windowHeight , windowHeight
, squares , squares
@@ -483,17 +483,8 @@ struct
) = ) =
let let
val qtree = buildTree (0, 0, size, squares) val qtree = buildTree (0, 0, size, squares)
val bintree = toBintree qtree
val bintree = merge (qtree, squares) val bintree = merge (qtree, squares)
val list = BinTree.toList bintree
val length = List.length list
val _ = print ("length = " ^ Int.toString length ^ "\n")
val _ = print "start fold\n"
val _ = List.foldl (fn (item, _) => printItem item) () list
val _ = print "finish fold\n"
val f = folder val f = folder
( windowWidth ( windowWidth
, windowHeight , windowHeight