Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ccraciun
Copy link

@ccraciun ccraciun commented Nov 1, 2018

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

Copy link
Owner

@p-e-w p-e-w left a 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 {
Copy link
Owner

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.

Copy link
Author

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.

Copy link
Owner

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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in "simulation".

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@ccraciun ccraciun force-pushed the cos.params.duration branch from d88f864 to 11b47b6 Compare November 13, 2018 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants