| 2 | import type { ChartGPUOptions, DataPoint, ChartGPUInstance } from '../../src/index'; |
| 3 | |
| 4 | const createWave = ( |
| 5 | count: number, |
| 6 | opts: Readonly<{ phase: number; amplitude: number; fn: 'sin' | 'cos' }> |
| 7 | ): ReadonlyArray<DataPoint> => { |
| 8 | const n = Math.max(2, Math.floor(count)); |
| 9 | const out: DataPoint[] = new Array(n); |
| 10 | |
| 11 | for (let i = 0; i < n; i++) { |
| 12 | const t = i / (n - 1); |
| 13 | const x = t * Math.PI * 2; |
| 14 | const base = opts.fn === 'sin' ? Math.sin(x + opts.phase) : Math.cos(x + opts.phase); |
| 15 | out[i] = [x, base * opts.amplitude] as const; |
| 16 | } |
| 17 | |
| 18 | return out; |
| 19 | }; |
| 20 | |
| 21 | const showError = (message: string): void => { |
| 22 | const el = document.getElementById('error'); |