this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Circuit drawing fixes and wave fade effect

- Fix zigzag segment count (off-by-one: segs = count*2-1)
- Rework source resistor wiring: explicit lead lines, tighter zigzag
- Reduce zigzag amplitude for cleaner look (8→5 for Rg, 6→5 for RL)
- Fade completed waves over time (FADE_DURATION=4τ, floor at 0.08 alpha)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

+13 -5
+13 -5
render.js
··· 80 80 line(ctx, x0, y0, start.x, start.y); 81 81 line(ctx, end.x, end.y, x1, y1); 82 82 83 - const segs = zigZagCount * 2; 83 + const segs = zigZagCount * 2 - 1; 84 84 const segLen = (len - 2 * lead) / segs; 85 85 ctx.beginPath(); 86 86 ctx.moveTo(start.x, start.y); ··· 140 140 ctx.strokeStyle = theme.ink; 141 141 142 142 // Top and bottom wires 143 - line(ctx, xSourceL, yTop, xSwitch - 18, yTop); 144 143 line(ctx, xSwitch + 18, yTop, xTL0, yTop); 145 144 line(ctx, xTL1, yTop, xLoad, yTop); 146 145 line(ctx, xLoad, yTop, xRight, yTop); ··· 159 158 label(ctx, "Vg", vsx - 38, vsy - 20, theme.muted); 160 159 161 160 // Source resistor Rg 162 - const r0 = xSourceL + 20, r1 = xSwitch - 20; 163 - drawResistor(ctx, r0, yTop, r1, yTop, 8, 8, theme); 161 + const r0 = xSourceL + 20, r1 = xSwitch - 30; 162 + line(ctx, xSourceL, yTop, r0, yTop); 163 + drawResistor(ctx, r0, yTop, r1, yTop, 5, 8, theme); 164 + line(ctx, r1, yTop, xSwitch - 18, yTop); 164 165 label(ctx, "Rg", (r0 + r1) / 2 - 10, yTop - 22, theme.muted); 165 166 166 167 drawSwitch(ctx, xSwitch, yTop, tn, theme); ··· 177 178 ctx.strokeStyle = theme.ink; 178 179 ctx.lineWidth = 2; 179 180 line(ctx, xLoad, yTop, xLoad, rlTop); 180 - drawResistor(ctx, xLoad, rlTop, xLoad, rlBot, 6, 8, theme); 181 + drawResistor(ctx, xLoad, rlTop, xLoad, rlBot, 5, 8, theme); 181 182 line(ctx, xLoad, rlBot, xLoad, yBot); 182 183 label(ctx, "RL", xLoad + 10, (yTop + yBot) / 2, theme.muted); 183 184 ··· 369 370 { color: theme.accent2, dash: [8, 4, 2, 4] }, // dash-dot pink 370 371 ]; 371 372 373 + const FADE_DURATION = 4; // τ_d units over which a completed wave fades 374 + const FADE_MIN = 0.08; // floor so ghost is still barely visible 375 + 372 376 for (let i = 0; i < launched.length; i++) { 373 377 const wf = launched[i]; 374 378 const style = waveStyles[i % waveStyles.length]; 379 + const completedAt = wf.launch + 1; 380 + const alpha = TLUtils.clamp(1 - (tn - completedAt) / FADE_DURATION, FADE_MIN, 1); 381 + ctx.globalAlpha = alpha; 375 382 ctx.setLineDash(style.dash); 376 383 if (smooth) { 377 384 drawSampledWave(ctx, xOfZ, y1, (z) => waveVoltageAt(wf, z, riseTimeTau), style.color, 2.0); ··· 379 386 drawPiecewise(ctx, xOfZ, y1, segmentsForWave(wf), style.color, 2.0); 380 387 } 381 388 ctx.setLineDash([]); 389 + ctx.globalAlpha = 1; 382 390 } 383 391 drawFrontMarkers(top1, bot1, launched.filter((wf) => wf.u < 1).map((wf) => wf.front)); 384 392