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

Function computePlotClipRect

src/renderers/createCandlestickRenderer.ts:80–103  ·  view source on GitHub ↗
(
  gridArea: GridArea
)

Source from the content-addressed store, hash-verified

78};
79
80const computePlotClipRect = (
81 gridArea: GridArea
82): { readonly left: number; readonly right: number; readonly top: number; readonly bottom: number; readonly width: number; readonly height: number } => {
83 const { left, right, top, bottom, canvasWidth, canvasHeight, devicePixelRatio } = gridArea;
84
85 const plotLeft = left * devicePixelRatio;
86 const plotRight = canvasWidth - right * devicePixelRatio;
87 const plotTop = top * devicePixelRatio;
88 const plotBottom = canvasHeight - bottom * devicePixelRatio;
89
90 const plotLeftClip = (plotLeft / canvasWidth) * 2.0 - 1.0;
91 const plotRightClip = (plotRight / canvasWidth) * 2.0 - 1.0;
92 const plotTopClip = 1.0 - (plotTop / canvasHeight) * 2.0; // flip Y
93 const plotBottomClip = 1.0 - (plotBottom / canvasHeight) * 2.0; // flip Y
94
95 return {
96 left: plotLeftClip,
97 right: plotRightClip,
98 top: plotTopClip,
99 bottom: plotBottomClip,
100 width: plotRightClip - plotLeftClip,
101 height: plotTopClip - plotBottomClip,
102 };
103};
104
105const computePlotScissorDevicePx = (
106 gridArea: GridArea

Callers 1

prepareFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected