Files
loop/src/Dodge/ScreenPos.hs
T
2023-05-14 22:22:21 +01:00

20 lines
588 B
Haskell

module Dodge.ScreenPos where
import Control.Lens
import Dodge.Data.Config
import Dodge.Data.ScreenPos
import Geometry.Data
import Picture.Base
fromTopLeft :: Point2 -> ScreenPos
fromTopLeft (V2 x y) = ScreenPos (V2 (-0.5) 0.5) (V2 x (- y))
translateScreenPos :: Configuration -> ScreenPos -> Picture -> Picture
translateScreenPos cfig = uncurryV translate . screenPosAbs cfig
screenPosAbs :: Configuration -> ScreenPos -> Point2
screenPosAbs cfig sp = sp ^. spScreenOff * V2 w h + sp ^. spPixelOff
where
w = fromIntegral $ cfig ^. windowX
h = fromIntegral $ cfig ^. windowY