Function
isPointInBar
(x: number, y: number, barBounds: BarBounds)
Source from the content-addressed store, hash-verified
| 29 | export type BarBounds = { left: number; right: number; top: number; bottom: number }; |
| 30 | |
| 31 | export function isPointInBar(x: number, y: number, barBounds: BarBounds): boolean { |
| 32 | // Inclusive bounds. |
| 33 | // Note: stacked bar segments can share edges; tie-breaking is handled by the caller. |
| 34 | return ( |
| 35 | x >= barBounds.left && |
| 36 | x <= barBounds.right && |
| 37 | y >= barBounds.top && |
| 38 | y <= barBounds.bottom |
| 39 | ); |
| 40 | } |
| 41 | |
| 42 | const clamp01 = (v: number): number => Math.min(1, Math.max(0, v)); |
| 43 | |
Tested by
no test coverage detected