| 111 | }; |
| 112 | |
| 113 | const createAreaVertices = (data: ResolvedAreaSeriesConfig['data']): Float32Array => { |
| 114 | // Triangle-strip expects duplicated vertices: |
| 115 | // p0,p0,p1,p1,... and WGSL uses vertex_index parity to swap y to baseline for odd indices. |
| 116 | const n = data.length; |
| 117 | const out = new Float32Array(n * 2 * 2); // n * 2 vertices * vec2<f32> |
| 118 | |
| 119 | let idx = 0; |
| 120 | for (let i = 0; i < n; i++) { |
| 121 | const { x, y } = getPointXY(data[i]); |
| 122 | out[idx++] = x; |
| 123 | out[idx++] = y; |
| 124 | out[idx++] = x; |
| 125 | out[idx++] = y; |
| 126 | } |
| 127 | |
| 128 | return out; |
| 129 | }; |
| 130 | |
| 131 | export function createAreaRenderer(device: GPUDevice, options?: AreaRendererOptions): AreaRenderer { |
| 132 | let disposed = false; |