Files
loop/src/Dodge/SmoothScroll.hs
T
2023-03-26 23:00:43 +01:00

38 lines
1015 B
Haskell

module Dodge.SmoothScroll where
import Control.Lens
import Dodge.Data.Input
-- this is fairly arbitrary, translated across from smooth scrolling on scopes
calcSmoothScroll :: Int -> Int -> Int
calcSmoothScroll y
| y >= 3 = max 0 . (+ 100)
| y >= 2 = max 0 . (+ 10)
| y >= 1 = max 0 . (+ 1)
| y >= 0 = id
| y >= (-1) = min 0 . subtract 1
| y >= (-2) = min 0 . subtract 10
| otherwise = min 0 . subtract 100
getSmoothScrollValue :: Input -> Int
getSmoothScrollValue theinput = case theinput ^. smoothScrollAmount of
x
| x > 10 -> 3
| x > 5 -> 2
| x > 0 -> 1
| x == 0 -> 0
| x >= (-5) -> -1
| x >= (-10) -> -2
| otherwise -> -3
-- this is fairly arbitrary, translated across from smooth scrolling on scopes
advanceSmoothScroll :: (Ord a, Num a) => a -> a
advanceSmoothScroll y
| y >= 20 = y - 3
| y >= 10 = y - 2
| y > 0 = y - 1
| y == 0 = 0
| y > (-10) = y + 1
| y > (-20) = y+2
| otherwise = y+3