Skip to content

Commit

Permalink
Use frameRate over frames to configure SlideLeft
Browse files Browse the repository at this point in the history
  • Loading branch information
jaspervdj committed Oct 12, 2023
1 parent d21cc6d commit 163b6fe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ Supported transitions `type`s:

Arguments:

- `frames`: number of frames to use. Defaults to 24.
- `frameRate`: number of frames per second. Defaults to 24.
- `duration`: duration of the animation in seconds. Defaults to 1.

Trivia
Expand Down
11 changes: 6 additions & 5 deletions lib/Patat/Transition/SlideLeft.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import Patat.Transition.Internal

--------------------------------------------------------------------------------
data Config = Config
{ cDuration :: Maybe (A.FlexibleNum Double)
, cFrames :: Maybe (A.FlexibleNum Int)
{ cDuration :: Maybe (A.FlexibleNum Double)
, cFrameRate :: Maybe (A.FlexibleNum Int)
}


Expand All @@ -31,10 +31,11 @@ slideLeft config (Size rows cols) initial final _rgen =
fmap (\f -> (f, Duration delay)) $
frame 0 :| map frame [1 .. frames - 1]
where
duration = fromMaybe 1 $ A.unFlexibleNum <$> cDuration config
frames = fromMaybe 24 $ A.unFlexibleNum <$> cFrames config
duration = fromMaybe 1 $ A.unFlexibleNum <$> cDuration config
frameRate = fromMaybe 24 $ A.unFlexibleNum <$> cFrameRate config

delay = duration / fromIntegral (frames + 1)
frames = round $ duration * fromIntegral frameRate :: Int
delay = duration / fromIntegral (frames + 1)

frame :: Int -> Matrix
frame idx = V.create $ do
Expand Down

0 comments on commit 163b6fe

Please sign in to comment.