Skip to content
Snippets Groups Projects
Verified Commit 0b7a0e6e authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Solve some arithmetic issues

parent 102909b8
Branches
No related tags found
No related merge requests found
...@@ -2,9 +2,8 @@ use std::fs::File; ...@@ -2,9 +2,8 @@ use std::fs::File;
use std::io::BufWriter; use std::io::BufWriter;
use std::path::PathBuf; use std::path::PathBuf;
use anyhow::{bail, format_err, Error}; use anyhow::{bail, Error, format_err};
use image::{DynamicImage, ImageOutputFormat, RgbImage}; use image::{DynamicImage, ImageOutputFormat, RgbImage};
use media_time::MediaTime; use media_time::MediaTime;
use webvtt::{WebVTTCue, WebVTTFile}; use webvtt::{WebVTTCue, WebVTTFile};
...@@ -150,16 +149,22 @@ impl SpritesheetManager { ...@@ -150,16 +149,22 @@ impl SpritesheetManager {
} }
pub fn end_frame(&mut self, timestamp: MediaTime) { pub fn end_frame(&mut self, timestamp: MediaTime) {
let prev_image = if self.current_image > 0 {
self.current_image - 1
} else {
0
};
self.metadata.add(WebVTTCue::new( self.metadata.add(WebVTTCue::new(
self.last_timestamp, self.last_timestamp,
timestamp, timestamp,
format!( format!(
"{}_{}.{}#xywh={},{},{},{}", "{}_{}.{}#xywh={},{},{},{}",
self.name, self.name,
self.spritesheet_index(self.current_image - 1), self.spritesheet_index(prev_image),
self.ending(), self.ending(),
self.x(self.current_image - 1), self.x(prev_image),
self.y(self.current_image - 1), self.y(prev_image),
self.sprite_width, self.sprite_width,
self.sprite_height self.sprite_height
), ),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment