| 121 | }; |
| 122 | |
| 123 | const computePlotScissorDevicePx = ( |
| 124 | gridArea: GridArea |
| 125 | ): { readonly x: number; readonly y: number; readonly w: number; readonly h: number } => { |
| 126 | const { canvasWidth, canvasHeight, devicePixelRatio } = gridArea; |
| 127 | |
| 128 | const plotLeftDevice = gridArea.left * devicePixelRatio; |
| 129 | const plotRightDevice = canvasWidth - gridArea.right * devicePixelRatio; |
| 130 | const plotTopDevice = gridArea.top * devicePixelRatio; |
| 131 | const plotBottomDevice = canvasHeight - gridArea.bottom * devicePixelRatio; |
| 132 | |
| 133 | const scissorX = clampInt(Math.floor(plotLeftDevice), 0, Math.max(0, canvasWidth)); |
| 134 | const scissorY = clampInt(Math.floor(plotTopDevice), 0, Math.max(0, canvasHeight)); |
| 135 | const scissorR = clampInt(Math.ceil(plotRightDevice), 0, Math.max(0, canvasWidth)); |
| 136 | const scissorB = clampInt(Math.ceil(plotBottomDevice), 0, Math.max(0, canvasHeight)); |
| 137 | const scissorW = Math.max(0, scissorR - scissorX); |
| 138 | const scissorH = Math.max(0, scissorB - scissorY); |
| 139 | |
| 140 | return { x: scissorX, y: scissorY, w: scissorW, h: scissorH }; |
| 141 | }; |
| 142 | |
| 143 | const IDENTITY_MAT4_F32 = new Float32Array([ |
| 144 | 1, 0, 0, 0, // col0 |