MCPcopy Index your code
hub / github.com/ChartGPU/ChartGPU / prepare

Function prepare

src/renderers/createLineRenderer.ts:176–200  ·  view source on GitHub ↗
(seriesConfig, dataBuffer, xScale, yScale, xOffset = 0)

Source from the content-addressed store, hash-verified

174 };
175
176 const prepare: LineRenderer['prepare'] = (seriesConfig, dataBuffer, xScale, yScale, xOffset = 0) => {
177 assertNotDisposed();
178
179 currentVertexBuffer = dataBuffer;
180 currentVertexCount = seriesConfig.data.length;
181
182 const { xMin, xMax, yMin, yMax } = computeDataBounds(seriesConfig.data);
183 const { a: ax, b: bx } = computeClipAffineFromScale(xScale, xMin, xMax);
184 const { a: ay, b: by } = computeClipAffineFromScale(yScale, yMin, yMax);
185
186 // When the vertex buffer packs x as (x - xOffset) (to preserve Float32 precision for large
187 // domains like epoch-ms), fold the offset back into the affine's intercept in f64 on CPU:
188 // clipX = ax * (x - xOffset) + (bx + ax * xOffset)
189 const bxAdjusted = bx + ax * xOffset;
190 writeTransformMat4F32(vsUniformScratchF32, ax, bxAdjusted, ay, by);
191 writeUniformBuffer(device, vsUniformBuffer, vsUniformScratchBuffer);
192
193 const [r, g, b, a] = parseSeriesColorToRgba01(seriesConfig.color);
194 const opacity = clamp01(seriesConfig.lineStyle.opacity);
195 fsUniformScratchF32[0] = r;
196 fsUniformScratchF32[1] = g;
197 fsUniformScratchF32[2] = b;
198 fsUniformScratchF32[3] = clamp01(a * opacity);
199 writeUniformBuffer(device, fsUniformBuffer, fsUniformScratchF32);
200 };
201
202 const render: LineRenderer['render'] = (passEncoder) => {
203 assertNotDisposed();

Callers

nothing calls this directly

Calls 7

writeUniformBufferFunction · 0.90
assertNotDisposedFunction · 0.70
computeDataBoundsFunction · 0.70
writeTransformMat4F32Function · 0.70
parseSeriesColorToRgba01Function · 0.70
clamp01Function · 0.70

Tested by

no test coverage detected