package matrix
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=9e4e90d17f9b2af1b07071fe425bc2c519c849c4f1d1ab73cde512be2d874849
sha512=06e9c4a741590942e81a27738d0b5c0413fafec8cf3b7dae047ad69f155e7b718aa4223818dc161b7d028efffcfd3365905e264d6fd31d453910ddfa91dcf9b9
doc/matrix.screen/Screen/Hit_grid/index.html
Module Screen.Hit_gridSource
Spatial indexing for mouse hit testing.
A hit grid maps screen coordinates to integer element IDs. Lookup is O(1); registration is O(region area).
Constants
empty_id is 0. Represents the absence of any element.
Types
The type for rectangular areas in cell coordinates.
The type for hit grids. Internally backed by an int32 bigarray for cache locality.
Lifecycle
create ~width ~height is a hit grid of the given dimensions with all cells set to empty_id.
resize t ~width ~height updates t's dimensions to width and height. All cells are reset to empty_id. Internal storage is grown only when necessary.
Operations
add t ~x ~y ~width ~height ~id fills the rectangular region with id (painter's algorithm: overwrites any existing IDs). The rectangle is clipped to the grid bounds and the active clip region. Zero or negative dimensions are a no-op.
get t ~x ~y is the element ID at (x, y), or empty_id if the coordinates are out of bounds.
blit ~src ~dst copies the content of src into dst. dst is resized to match src.
Clipping
Hierarchical clipping for hit regions. When a clip is active, add operations are constrained to the intersection of the clip rectangle and the grid bounds. This prevents elements inside overflow-hidden containers from receiving mouse events outside their visible area.
Push/pop pairs must be balanced.
push_clip t r pushes a clipping rectangle. The effective clip is the intersection of r with the current clip (hierarchical narrowing).