(samples: OnionSample[], W: number, H: number)
| 220 | } |
| 221 | |
| 222 | function stripBody(samples: OnionSample[], W: number, H: number): string { |
| 223 | if (samples.length === 0) return ""; |
| 224 | const { cols, cellW, cellH } = stripCells(samples.length, W, H); |
| 225 | let maxExt = 1; |
| 226 | for (const s of samples) |
| 227 | for (const p of s.q) maxExt = Math.max(maxExt, Math.hypot(p.x - s.c.x, p.y - s.c.y)); |
| 228 | const cellScale = (Math.min(cellW, cellH) * 0.62) / maxExt; |
| 229 | const last = samples.length - 1; |
| 230 | let out = ""; |
| 231 | samples.forEach((s, i) => { |
| 232 | const col = i % cols; |
| 233 | const row = Math.floor(i / cols); |
| 234 | const cc = { x: cellW * (col + 0.5), y: cellH * (row + 0.5) }; |
| 235 | const f = last <= 0 ? 0 : i / last; |
| 236 | out += `<rect ${attrs({ x: round(col * cellW + 3), y: round(row * cellH + 3), width: round(cellW - 6), height: round(cellH - 6), fill: "none", stroke: "#1c2531", "stroke-width": 1, rx: 8 })}/>`; |
| 237 | const corners = s.q.map((p) => ({ |
| 238 | x: cc.x + (p.x - s.c.x) * cellScale, |
| 239 | y: cc.y + (p.y - s.c.y) * cellScale, |
| 240 | })); |
| 241 | out += ghost(corners, cc, s.color, s.opacity, f); |
| 242 | out += text({ x: col * cellW + 12, y: row * cellH + 24 }, `${s.t}s`, timeColor(f), 16); |
| 243 | }); |
| 244 | return out; |
| 245 | } |
no test coverage detected