| 9 | import type { GridArea } from '../../src/renderers/createGridRenderer'; |
| 10 | |
| 11 | const createSineWave = ( |
| 12 | count: number, |
| 13 | opts?: Readonly<{ phase?: number; amplitude?: number }> |
| 14 | ): ReadonlyArray<DataPoint> => { |
| 15 | const n = Math.max(2, Math.floor(count)); |
| 16 | const out: DataPoint[] = new Array(n); |
| 17 | const phase = opts?.phase ?? 0; |
| 18 | const amplitude = opts?.amplitude ?? 1; |
| 19 | |
| 20 | for (let i = 0; i < n; i++) { |
| 21 | const t = i / (n - 1); |
| 22 | const x = t * Math.PI * 2; |
| 23 | const y = Math.sin(x + phase) * amplitude; |
| 24 | out[i] = [x, y] as const; |
| 25 | } |
| 26 | |
| 27 | return out; |
| 28 | }; |
| 29 | |
| 30 | const showError = (message: string): void => { |
| 31 | const el = document.getElementById('error'); |