MCPcopy Create free account
hub / github.com/ChartGPU/ChartGPU / computePlotScissorDevicePx

Function computePlotScissorDevicePx

src/renderers/createScatterRenderer.ts:137–155  ·  view source on GitHub ↗
(
  gridArea: GridArea
)

Source from the content-addressed store, hash-verified

135};
136
137const 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
157export function createScatterRenderer(device: GPUDevice, options?: ScatterRendererOptions): ScatterRenderer {
158 let disposed = false;

Callers 1

prepareFunction · 0.70

Calls 1

clampIntFunction · 0.70

Tested by

no test coverage detected