log2life

Feed log lines to sdl2-life as Life 1.05 patterns
git clone https://www.brianlane.com/git/log2life
Log | Files | Refs | README

commit b5467bbde7719aa9a1642af126e561d8e14c7207
parent 2fd252fa3ad3e7616c7b4b3b94a2fbc192d929e3
Author: Brian C. Lane <bcl@brianlane.com>
Date:   Fri, 25 Nov 2022 16:14:58 -0800

Run stdin in realtime and playback using uS for more resolution

Diffstat:
Mmain.go | 5++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/main.go b/main.go @@ -61,6 +61,9 @@ func main() { var err error if filename == "-" { f = os.Stdin + + // When feeding log lines we don't want to delay + cfg.Speed = 0 } else { _, err = os.Stat(filename) if err != nil { @@ -87,7 +90,7 @@ func main() { // Replay the logfile in realtime when speed = 1.0 noTime := time.Time{} if lastTime != noTime { - delay := time.Duration(timestamp.Sub(lastTime).Seconds()*1/cfg.Speed) * time.Second + delay := time.Duration(float64(timestamp.Sub(lastTime).Microseconds())*1/cfg.Speed) * time.Microsecond fmt.Printf("delaying %s\n", delay) time.Sleep(delay) }