add functionality to draw in different colours

This commit is contained in:
2025-07-11 16:39:39 +01:00
parent 040fc67c80
commit 7028391298
5 changed files with 35 additions and 29 deletions

View File

@@ -99,10 +99,7 @@ end
structure CollisionTree =
struct
(* ignoreData = any data we find in grid but which doesn't concern us
* so we omit from tree, to reduce number of items in tree,
* and therefore decrease the constant in O(n) *)
val ignoreData = 0
fun shouldIgnoreData {a, r = _, g = _, b = _} = a = 0
local
fun loopYAxis (x, y, eX, eY, yAxis, col) =
@@ -147,7 +144,7 @@ struct
val yAxis = Vector.sub (grid, x)
val data = Vector.sub (yAxis, y)
in
if data = ignoreData then
if shouldIgnoreData data then
bintree
else
let
@@ -218,8 +215,14 @@ struct
val endX = Ndc.fromPixelX (ex, windowWidth, windowHeight)
val startY = Ndc.fromPixelY (y, windowWidth, windowHeight)
val endY = Ndc.fromPixelY (ey, windowWidth, windowHeight)
val {r, g, b, a} = data
val r = Real32.fromInt r / 255.0
val g = Real32.fromInt g / 255.0
val b = Real32.fromInt b / 255.0
val a = Real32.fromInt a / 255.0
in
Ndc.ltrbToVertexRgb (startX, startY, endX, endY, 0.0, 0.0, 0.0) :: acc
Ndc.ltrbToVertexRgb (startX, startY, endX, endY, r, g, b) :: acc
end
fun toTriangles
@@ -250,7 +253,7 @@ struct
(* building and querying quad tree, plus compression *)
datatype quad_tree =
LEAF of {x: int, y: int, ex: int, ey: int, data: int}
LEAF of {x: int, y: int, ex: int, ey: int, data: AppType.square}
| NODE of {tl: quad_tree, tr: quad_tree, bl: quad_tree, br: quad_tree}
| EMPTY
@@ -278,7 +281,7 @@ struct
val yAxis = Vector.sub (grid, x)
val data = Vector.sub (yAxis, y)
in
if data = ignoreData then
if shouldIgnoreData data then
EMPTY
else
let