done generating collision string
This commit is contained in:
@@ -632,15 +632,43 @@ struct
|
|||||||
|
|
||||||
fun toCollisionStringFolder ({x, ex, y, ey, data = _}, acc) =
|
fun toCollisionStringFolder ({x, ex, y, ey, data = _}, acc) =
|
||||||
let
|
let
|
||||||
val ex = if x = ex then ex + 1 else ex
|
val ex = ex + 1
|
||||||
val ey = if y = ey then ey + 1 else ey
|
val ey = if y = ey then ey + 1 else ey
|
||||||
|
|
||||||
|
val width = ex - x
|
||||||
|
val width = if width = 0 then width + 1 else width
|
||||||
|
val height = ey - y
|
||||||
|
val height = if height = 0 then height + 1 else height
|
||||||
|
|
||||||
|
val x = Int.toString x
|
||||||
|
val y = Int.toString y
|
||||||
|
val width = Int.toString width
|
||||||
|
val height = Int.toString height
|
||||||
|
|
||||||
|
val item = String.concat
|
||||||
|
[ "{x = "
|
||||||
|
, x
|
||||||
|
, ", y = "
|
||||||
|
, y
|
||||||
|
, ", width = "
|
||||||
|
, width
|
||||||
|
, ", height = "
|
||||||
|
, height
|
||||||
|
, " }"
|
||||||
|
]
|
||||||
|
in
|
||||||
|
item :: acc
|
||||||
|
end
|
||||||
|
|
||||||
fun toCollisionString (squares, canvasWidth, canvasHeight) =
|
fun toCollisionString (squares, canvasWidth, canvasHeight) =
|
||||||
let
|
let
|
||||||
val size = Int.max (canvasWidth, canvasHeight)
|
val size = Int.max (canvasWidth, canvasHeight)
|
||||||
val qtree = buildTree (0, 0, size, squares)
|
val qtree = buildTree (0, 0, size, squares)
|
||||||
val bintree = merge (qtree, squares)
|
val bintree = merge (qtree, squares)
|
||||||
|
|
||||||
val collisions = BinTree.foldr (toExportStringFolder, bintree, [])
|
val collisions = BinTree.foldr (toCollisionStringFolder, bintree, [])
|
||||||
val collisions = String.concatWith ",\n" coords
|
val collisions = String.concatWith ",\n" collisions
|
||||||
|
in
|
||||||
|
String.concat ["val collisions = #[", collisions, "]\n"]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
10 10 { {0 0 0 10 0 0 0 1 } {0 0 9 0 0 0 0 1 } {0 9 9 10 0 0 0 1 } {2 2 7 2 0 0 0 1 } {9 0 9 10 0 0 0 1 } }
|
|
||||||
85
green.sml
85
green.sml
@@ -1,85 +0,0 @@
|
|||||||
structure AAA =
|
|
||||||
struct
|
|
||||||
fun xToNdc (xOffset, xpos, scale, halfWidth) =
|
|
||||||
((xpos * scale + xOffset) - halfWidth) / halfWidth
|
|
||||||
|
|
||||||
fun endXToNdc (xOffset, startX, endX, scale, halfWidth) =
|
|
||||||
(((endX - startX) * scale + xOffset) - halfWidth) / halfWidth
|
|
||||||
|
|
||||||
fun yToNdc (yOffset, ypos, scale, halfHeight) =
|
|
||||||
~(((ypos * scale + yOffset) - halfHeight) / halfHeight)
|
|
||||||
|
|
||||||
fun endYToNdc (yOffset, startY, endY, scale, halfHeight) =
|
|
||||||
~((((endY - startY) * scale + yOffset) - halfHeight) / halfHeight)
|
|
||||||
|
|
||||||
fun lerp (xOffset, yOffset, scale, windowWidth, windowHeight) =
|
|
||||||
let
|
|
||||||
val windowWidth = Real32.fromInt windowWidth
|
|
||||||
val halfWidth = windowWidth / 2.0
|
|
||||||
val windowHeight = Real32.fromInt windowHeight
|
|
||||||
val halfHeight = windowHeight / 2.0
|
|
||||||
in
|
|
||||||
#[
|
|
||||||
xToNdc (xOffset, 0.000000000000000, scale, halfWidth),
|
|
||||||
yToNdc (yOffset, 10.000000000000000, scale, halfHeight),
|
|
||||||
endXToNdc (xOffset, xToNdc (xOffset, 0.000000000000000, scale, halfWidth), 0.000000000000000, scale, halfWidth),
|
|
||||||
yToNdc (yOffset, 10.000000000000000, scale, halfHeight),
|
|
||||||
xToNdc (xOffset, 0.000000000000000, scale, halfWidth),
|
|
||||||
yToNdc (yOffset, 0.000000000000000, scale, halfHeight),
|
|
||||||
xToNdc (xOffset, 0.000000000000000, scale, halfWidth),
|
|
||||||
yToNdc (yOffset, 0.000000000000000, scale, halfHeight),
|
|
||||||
endXToNdc (xOffset, xToNdc (xOffset, 0.000000000000000, scale, halfWidth), 0.000000000000000, scale, halfWidth),
|
|
||||||
yToNdc (yOffset, 10.000000000000000, scale, halfHeight),
|
|
||||||
endXToNdc (xOffset, xToNdc (xOffset, 0.000000000000000, scale, halfWidth), 0.000000000000000, scale, halfWidth),
|
|
||||||
yToNdc (yOffset, 0.000000000000000, scale, halfHeight),
|
|
||||||
xToNdc (xOffset, 0.000000000000000, scale, halfWidth),
|
|
||||||
yToNdc (yOffset, 1.000000000000000, scale, halfHeight),
|
|
||||||
endXToNdc (xOffset, xToNdc (xOffset, 0.000000000000000, scale, halfWidth), 9.000000000000000, scale, halfWidth),
|
|
||||||
yToNdc (yOffset, 1.000000000000000, scale, halfHeight),
|
|
||||||
xToNdc (xOffset, 0.000000000000000, scale, halfWidth),
|
|
||||||
yToNdc (yOffset, 0.000000000000000, scale, halfHeight),
|
|
||||||
xToNdc (xOffset, 0.000000000000000, scale, halfWidth),
|
|
||||||
yToNdc (yOffset, 0.000000000000000, scale, halfHeight),
|
|
||||||
endXToNdc (xOffset, xToNdc (xOffset, 0.000000000000000, scale, halfWidth), 9.000000000000000, scale, halfWidth),
|
|
||||||
yToNdc (yOffset, 1.000000000000000, scale, halfHeight),
|
|
||||||
endXToNdc (xOffset, xToNdc (xOffset, 0.000000000000000, scale, halfWidth), 9.000000000000000, scale, halfWidth),
|
|
||||||
yToNdc (yOffset, 0.000000000000000, scale, halfHeight),
|
|
||||||
xToNdc (xOffset, 0.000000000000000, scale, halfWidth),
|
|
||||||
yToNdc (yOffset, 10.000000000000000, scale, halfHeight),
|
|
||||||
endXToNdc (xOffset, xToNdc (xOffset, 0.000000000000000, scale, halfWidth), 9.000000000000000, scale, halfWidth),
|
|
||||||
yToNdc (yOffset, 10.000000000000000, scale, halfHeight),
|
|
||||||
xToNdc (xOffset, 0.000000000000000, scale, halfWidth),
|
|
||||||
yToNdc (yOffset, 9.000000000000000, scale, halfHeight),
|
|
||||||
xToNdc (xOffset, 0.000000000000000, scale, halfWidth),
|
|
||||||
yToNdc (yOffset, 9.000000000000000, scale, halfHeight),
|
|
||||||
endXToNdc (xOffset, xToNdc (xOffset, 0.000000000000000, scale, halfWidth), 9.000000000000000, scale, halfWidth),
|
|
||||||
yToNdc (yOffset, 10.000000000000000, scale, halfHeight),
|
|
||||||
endXToNdc (xOffset, xToNdc (xOffset, 0.000000000000000, scale, halfWidth), 9.000000000000000, scale, halfWidth),
|
|
||||||
yToNdc (yOffset, 9.000000000000000, scale, halfHeight),
|
|
||||||
xToNdc (xOffset, 2.000000000000000, scale, halfWidth),
|
|
||||||
yToNdc (yOffset, 3.000000000000000, scale, halfHeight),
|
|
||||||
endXToNdc (xOffset, xToNdc (xOffset, 2.000000000000000, scale, halfWidth), 7.000000000000000, scale, halfWidth),
|
|
||||||
yToNdc (yOffset, 3.000000000000000, scale, halfHeight),
|
|
||||||
xToNdc (xOffset, 2.000000000000000, scale, halfWidth),
|
|
||||||
yToNdc (yOffset, 2.000000000000000, scale, halfHeight),
|
|
||||||
xToNdc (xOffset, 2.000000000000000, scale, halfWidth),
|
|
||||||
yToNdc (yOffset, 2.000000000000000, scale, halfHeight),
|
|
||||||
endXToNdc (xOffset, xToNdc (xOffset, 2.000000000000000, scale, halfWidth), 7.000000000000000, scale, halfWidth),
|
|
||||||
yToNdc (yOffset, 3.000000000000000, scale, halfHeight),
|
|
||||||
endXToNdc (xOffset, xToNdc (xOffset, 2.000000000000000, scale, halfWidth), 7.000000000000000, scale, halfWidth),
|
|
||||||
yToNdc (yOffset, 2.000000000000000, scale, halfHeight),
|
|
||||||
xToNdc (xOffset, 9.000000000000000, scale, halfWidth),
|
|
||||||
yToNdc (yOffset, 10.000000000000000, scale, halfHeight),
|
|
||||||
endXToNdc (xOffset, xToNdc (xOffset, 9.000000000000000, scale, halfWidth), 9.000000000000000, scale, halfWidth),
|
|
||||||
yToNdc (yOffset, 10.000000000000000, scale, halfHeight),
|
|
||||||
xToNdc (xOffset, 9.000000000000000, scale, halfWidth),
|
|
||||||
yToNdc (yOffset, 0.000000000000000, scale, halfHeight),
|
|
||||||
xToNdc (xOffset, 9.000000000000000, scale, halfWidth),
|
|
||||||
yToNdc (yOffset, 0.000000000000000, scale, halfHeight),
|
|
||||||
endXToNdc (xOffset, xToNdc (xOffset, 9.000000000000000, scale, halfWidth), 9.000000000000000, scale, halfWidth),
|
|
||||||
yToNdc (yOffset, 10.000000000000000, scale, halfHeight),
|
|
||||||
endXToNdc (xOffset, xToNdc (xOffset, 9.000000000000000, scale, halfWidth), 9.000000000000000, scale, halfWidth),
|
|
||||||
yToNdc (yOffset, 0.000000000000000, scale, halfHeight)
|
|
||||||
]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Reference in New Issue
Block a user