def tree.at
gralha-coverage@0.1.0.1 · cover.bend:56
import gralha-coverage@0.1.0.1/cover.bend as Cover
import Base
import gralha-text-scan@0.1.0.1/scan.bend as U
56def tree.at(t: CovTree, +half: U32, +x: U32, +y: U32) -> F32:
57 match t:
58 case CovFlat{v}: v
59 case CovQuad{a, b, c, d}:
60 +left = U32.is_lt(x, half)
61 +top = U32.is_lt(y, half)
62 +xx = U.choose(U32, left, x, (x - half : U32))
63 +yy = U.choose(U32, top, y, (y - half : U32))
64 +next = U32.div(half, 2)
65 tree.at(U.choose(CovTree, top, U.choose(CovTree, left, a, b), U.choose(CovTree, left, c, d)), next, xx, yy)