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

Perenthenses problem in progress bar draw formula #526

Closed
rubik83 opened this issue Sep 15, 2020 · 3 comments · Fixed by #527
Closed

Perenthenses problem in progress bar draw formula #526

rubik83 opened this issue Sep 15, 2020 · 3 comments · Fixed by #527

Comments

@rubik83
Copy link
Contributor

rubik83 commented Sep 15, 2020

I think there is a perenthenses problem in this formula

https://github.com/hecrj/iced/blob/4f2962d73f3bdeeca8a11817e404c45e91e2c2cc/graphics/src/widget/progress_bar.rs#L39

May be :
((value - range_start) / (range_end - range_start)).max(1.0)
Instead of :
((value - range_start) / (range_end - range_start).max(1.0))

@rubik83
Copy link
Contributor Author

rubik83 commented Sep 15, 2020

Another problem is that you have to use the min () function to give a maximum limit to a value
The correct formula may be :
((value - range_start) / (range_end - range_start)).min(1.0)

@rubik83
Copy link
Contributor Author

rubik83 commented Sep 15, 2020

One way to reproduce the problem is to create a progress bar with the range [0.0; 0.2] and the value 0.1

@rubik83
Copy link
Contributor Author

rubik83 commented Sep 15, 2020

If the goal was to prevent a division by 0 it would be better to use EPSILON :
((value - range_start) / (range_end - range_start).max(f32::EPSILON))

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 a pull request may close this issue.

1 participant