code wiki / _hdl_build / nx_viz_brush.nx
nx_viz_brush.nx source
↩ module page · 23 lines · 1030 B
1// nx_viz_brush.nx -- the BRUSH math core of the INTERACTION layer (the d3-brush/d3-drag core, bits-up). A drag
2// from (x0,y0) to (x1,y1) defines a normalized selection rectangle; hit-test points against it. Pure integer ->
3// WASM-deployable. (Drag-pan reuses nx_viz_zoom vz_pan.) Closes interact-drag-brush. license_tier: ORIGINAL
4import "nx_syscalls.nx"
5
6// normalized brush extent from drag endpoints -> out4 = [minx, miny, maxx, maxy].
7func vb_extent(x0: i64, y0: i64, x1: i64, y1: i64, out4: *i64) -> i64 {
8 var ax: i64 = x0; var bx: i64 = x1
9 if x1 < x0 { ax = x1; bx = x0 }
10 var ay: i64 = y0; var by: i64 = y1
11 if y1 < y0 { ay = y1; by = y0 }
12 out4[0] = ax; out4[1] = ay; out4[2] = bx; out4[3] = by
13 return 0
14}
15// is point (px,py) inside the brush extent (inclusive)?
16func vb_contains(ext4: *i64, px: i64, py: i64) -> i64 {
17 if px < ext4[0] { return 0 }
18 if px > ext4[2] { return 0 }
19 if py < ext4[1] { return 0 }
20 if py > ext4[3] { return 0 }
21 return 1
22}
23func main() -> i64 { return 0 }