From 78404ed56c12a0c57af9c40ef2150023991a146b Mon Sep 17 00:00:00 2001 From: "M. Sz" Date: Thu, 25 Feb 2021 09:33:47 +0100 Subject: [PATCH] cof: added Duration method --- d2common/d2fileformats/d2cof/helpers.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/d2common/d2fileformats/d2cof/helpers.go b/d2common/d2fileformats/d2cof/helpers.go index 0cc7f73b..0b3b7fb2 100644 --- a/d2common/d2fileformats/d2cof/helpers.go +++ b/d2common/d2fileformats/d2cof/helpers.go @@ -14,3 +14,14 @@ func (c *COF) SpeedToFPS() float64 { return fps } + +// Duration returns animation's duration +func (c *COF) Duration() float64 { + const ( + milliseconds = 1000 + ) + + frameDelay := milliseconds / c.SpeedToFPS() + + return float64(c.FramesPerDirection) * frameDelay +}