diff --git a/dotscape b/dotscape index d60ade2..16b81a1 100755 Binary files a/dotscape and b/dotscape differ diff --git a/fcore/quad-tree.sml b/fcore/quad-tree.sml index 7cfefc4..27a8d54 100644 --- a/fcore/quad-tree.sml +++ b/fcore/quad-tree.sml @@ -534,14 +534,15 @@ struct in "endYToNdc (yOffset, " ^ startY ^ ", " ^ endY ^ ", scale, halfHeight)" end - fun toExportStringFolder ({x, ex, y, ey, data = {r, g, b, a}}, acc) = + fun toExportStringFolder (maxWidth, maxHeight) ({x, ex, y, ey, data = {r, g, b, a}}, acc) = let - val ey = if ey = y then y + 1 else ey + val ex = if ex < maxWidth then ex + 1 else ex + val ey = if ey < maxHeight then ey + 1 else ey val x = makeXString x val y = makeYString y val ex = makeEndXString (x, ex) - val ey = makeYString ey + val ey = makeEndYString (y, ey) val r = colToRealString r val g = colToRealString g val b = colToRealString b @@ -589,7 +590,8 @@ struct val qtree = buildTree (0, 0, size, squares) val bintree = merge (qtree, squares) - val coords = BinTree.foldr (toExportStringFolder, bintree, []) + val f = toExportStringFolder (canvasWidth, canvasHeight) + val coords = BinTree.foldr (f, bintree, []) val coords = String.concatWith ",\n" coords in String.concat @@ -630,10 +632,10 @@ struct fun mapGrid grid = Vector.map (fn yAxis => Vector.map (fn item => mapItem item) yAxis) grid - fun toCollisionStringFolder scale ({x, ex, y, ey, data = _}, acc) = + fun toCollisionStringFolder (scale, maxWidth, maxHeight) ({x, ex, y, ey, data = _}, acc) = let - val ex = ex + 1 - val ey = if y = ey then ey + 1 else ey + val ex = if ex < maxWidth then ex + 1 else ex + val ey = if ey < maxHeight then ey + 1 else ey val width = ex - x val width = if width = 0 then width + 1 else width @@ -662,11 +664,12 @@ struct fun toCollisionString (squares, canvasWidth, canvasHeight, scale) = let + val scale = if scale = 0 then 1 else scale val size = Int.max (canvasWidth, canvasHeight) val qtree = buildTree (0, 0, size, squares) val bintree = merge (qtree, squares) - val f = toCollisionStringFolder scale + val f = toCollisionStringFolder (scale, canvasWidth, canvasHeight) val collisions = BinTree.foldr (f, bintree, []) val collisions = String.concatWith ",\n" collisions in