Skip to content

Commit 5cfbb20

Browse files
authored
Change frames per second (fps) from usize to f32 (#148)
* refactor(viewer): change fps type from usize to f32 for improved precision and update related methods * fix(viewer): correct formatting in fps calculation for better readability
1 parent 0717a23 commit 5cfbb20

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/viz/viewer.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub struct Viewer<'a> {
1717
image_height: usize,
1818
image_width: usize,
1919
#[cfg(feature = "video")]
20-
fps: usize,
20+
fps: f32,
2121
#[cfg(feature = "video")]
2222
video_encoder: Option<Encoder>,
2323
#[cfg(feature = "video")]
@@ -36,7 +36,7 @@ impl Default for Viewer<'_> {
3636
image_height: 0,
3737
image_width: 0,
3838
#[cfg(feature = "video")]
39-
fps: 25,
39+
fps: 25.0,
4040
#[cfg(feature = "video")]
4141
video_encoder: None,
4242
#[cfg(feature = "video")]
@@ -150,7 +150,7 @@ impl Viewer<'_> {
150150
)?;
151151
self.position = self
152152
.position
153-
.aligned_with(Time::from_nth_of_a_second(self.fps))
153+
.aligned_with(Time::from_secs(1.0 / self.fps))
154154
.add();
155155
}
156156

@@ -243,7 +243,7 @@ impl Viewer<'_> {
243243
}
244244

245245
#[cfg(feature = "video")]
246-
pub fn with_fps(mut self, x: usize) -> Self {
246+
pub fn with_fps(mut self, x: f32) -> Self {
247247
self.fps = x;
248248
self
249249
}

0 commit comments

Comments
 (0)