-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add duration parameter #20
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, I quite like the name duration
.
ternimal.rs
Outdated
@@ -251,6 +253,10 @@ fn main() { | |||
// Hide cursor while printing canvas to avoid flickering | |||
print!("\x1B[?25l{}\x1B[?25h\n", output); | |||
|
|||
if duration >= 0.0 && time > duration { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check probably belongs at the start of the rendering loop. Otherwise we are rendering another frame even though the elapsed time has already exceeded duration
. Although in that case, we would exit the loop when the cursor is placed at the top of the canvas, which creates other problems... Not sure what the best solution is here.
I also don't think a duration of zero should be applied. If only a single frame is desired, this should be achieved using a separate frames
parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved the check (and the cursor reset by necessity) to the beginning of the loop, only downside is this will cause a duration that's greater than 0 but very small to not draw any frames, which feels a bit wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see an issue with this: If we have already spent more time than our budget, we need to exit. That part is exactly as it should be IMO.
What I don't like is that a duration of zero is accepted, which never makes sense. The default duration should be zero, meaning "run forever".
ternimal.rs
Outdated
@@ -92,6 +92,8 @@ fn main() { | |||
arg_var!(speed, 30.0, 0.0, 1000.0); | |||
// Animation frames per second | |||
arg_var!(fps, 30.0, 0.1, 600.0); | |||
// Duration of model simlation in seconds (if this is less than 0, run forever) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in "simulation".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
d88f864
to
11b47b6
Compare
Not super happy with the name of the parameter, but let me know if this works or how to tweak it so it does.
Fixes #19