| 135 | }; |
| 136 | |
| 137 | const computePlotScissorDevicePx = ( |
| 138 | gridArea: GridArea |
| 139 | ): { readonly x: number; readonly y: number; readonly w: number; readonly h: number } => { |
| 140 | const { canvasWidth, canvasHeight, devicePixelRatio } = gridArea; |
| 141 | |
| 142 | const plotLeftDevice = gridArea.left * devicePixelRatio; |
| 143 | const plotRightDevice = canvasWidth - gridArea.right * devicePixelRatio; |
| 144 | const plotTopDevice = gridArea.top * devicePixelRatio; |
| 145 | const plotBottomDevice = canvasHeight - gridArea.bottom * devicePixelRatio; |
| 146 | |
| 147 | const scissorX = clampInt(Math.floor(plotLeftDevice), 0, Math.max(0, canvasWidth)); |
| 148 | const scissorY = clampInt(Math.floor(plotTopDevice), 0, Math.max(0, canvasHeight)); |
| 149 | const scissorR = clampInt(Math.ceil(plotRightDevice), 0, Math.max(0, canvasWidth)); |
| 150 | const scissorB = clampInt(Math.ceil(plotBottomDevice), 0, Math.max(0, canvasHeight)); |
| 151 | const scissorW = Math.max(0, scissorR - scissorX); |
| 152 | const scissorH = Math.max(0, scissorB - scissorY); |
| 153 | |
| 154 | return { x: scissorX, y: scissorY, w: scissorW, h: scissorH }; |
| 155 | }; |
| 156 | |
| 157 | export function createScatterRenderer(device: GPUDevice, options?: ScatterRendererOptions): ScatterRenderer { |
| 158 | let disposed = false; |