Commit 52c36f7
Address PR feedback: speed-independent trail persistence with time-constant model
Replaces the draw-call-counter scope fade with a wall-clock-based
exponential decay. The user setting now means a literal trail
persistence in milliseconds, not an opaque alpha number.
Per @pfalstad on PR pfalstad#240:
- "vary alpha instead of the number of draw calls between fade outs"
- "should look the same regardless of the simulation speed setting"
- "It still seems too persistent even at the lowest setting"
Implementation:
alpha = 1 - exp(-elapsed_ms / trailPersistence)
This is the analytic solution for an exponential decay with time
constant `trailPersistence`. Same fade rate at 30fps or 144fps,
because elapsed wall-clock time appears in the exponent. The user
sees and sets the time constant directly (default 200 ms).
Range 0..2000 ms. Setting trailPersistence = 0 maps to alpha = 1
(instant erase, no trail at all) so "lowest setting" really is no
trail, addressing the "still too persistent" complaint.
Persisted per-scope as XML attribute "tp"; omitted when at the
default to keep file size small.
The MOSFET lambda part of the original PR pfalstad#240 has been superseded
by PR pfalstad#313 (MosfetModel class), so this PR is now scope-fade-only.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 7cf753f commit 52c36f7
File tree
2 files changed
+48
-11
lines changed- src/com/lushprojects/circuitjs1/client
2 files changed
+48
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
262 | 262 | | |
263 | 263 | | |
264 | 264 | | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
265 | 269 | | |
266 | 270 | | |
267 | 271 | | |
| |||
1054 | 1058 | | |
1055 | 1059 | | |
1056 | 1060 | | |
1057 | | - | |
1058 | | - | |
1059 | | - | |
1060 | | - | |
1061 | | - | |
1062 | | - | |
1063 | | - | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
1064 | 1077 | | |
1065 | | - | |
| 1078 | + | |
1066 | 1079 | | |
1067 | | - | |
1068 | 1080 | | |
1069 | 1081 | | |
1070 | 1082 | | |
| |||
2211 | 2223 | | |
2212 | 2224 | | |
2213 | 2225 | | |
| 2226 | + | |
| 2227 | + | |
2214 | 2228 | | |
2215 | 2229 | | |
2216 | 2230 | | |
| |||
2226 | 2240 | | |
2227 | 2241 | | |
2228 | 2242 | | |
| 2243 | + | |
2229 | 2244 | | |
2230 | 2245 | | |
2231 | 2246 | | |
| |||
Lines changed: 24 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
| 62 | + | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
| |||
518 | 519 | | |
519 | 520 | | |
520 | 521 | | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
521 | 536 | | |
522 | 537 | | |
523 | 538 | | |
| |||
625 | 640 | | |
626 | 641 | | |
627 | 642 | | |
628 | | - | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
629 | 651 | | |
630 | 652 | | |
631 | 653 | | |
| |||
0 commit comments