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

Function computePlotScissorDevicePx

src/renderers/createPieRenderer.ts:123–141  ·  view source on GitHub ↗
(
  gridArea: GridArea
)

Source from the content-addressed store, hash-verified

121};
122
123const 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
143const IDENTITY_MAT4_F32 = new Float32Array([
144 1, 0, 0, 0, // col0

Callers 1

prepareFunction · 0.70

Calls 1

clampIntFunction · 0.70

Tested by

no test coverage detected