diff --git a/src/drawer.rs b/src/drawer.rs index 8cacb30..0bc2c88 100644 --- a/src/drawer.rs +++ b/src/drawer.rs @@ -248,6 +248,10 @@ impl BoardDrawer { self.size } + pub fn flip(&self) -> bool { + self.flip + } + pub fn image_buffer(&self) -> RgbaImage { ImageBuffer::new(self.size, self.size) } diff --git a/src/giffer.rs b/src/giffer.rs index 0daf885..790000f 100644 --- a/src/giffer.rs +++ b/src/giffer.rs @@ -603,18 +603,13 @@ impl Visitor for PGNGiffer { log::debug!("Building frame for board number: {}", n); log::debug!("Board width: {}, height: {}", b.width(), b.height()); - let turn = n / 2; + let turn = if n == 0 { n } else { (n - 1) / 2 }; - let mut white_clock = self.clocks.white.get(turn); + let white_clock = self.clocks.white.get(turn); let mut black_clock = self.clocks.black.get(turn); - if n == (total_frames - 1) { - if white_clock.is_none() { - white_clock = self.clocks.white.get(turn - 1); - } - if black_clock.is_none() { - black_clock = self.clocks.black.get(turn - 1); - } + if turn > 0 && n % 2 != 0 { + black_clock = self.clocks.black.get(turn - 1); } if white_clock.is_some()