20 lines
574 B
Haskell
20 lines
574 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 :: Config -> ScreenPos -> Picture -> Picture
|
|
translateScreenPos cfig = uncurryV translate . screenPosAbs cfig
|
|
|
|
screenPosAbs :: Config -> ScreenPos -> Point2
|
|
screenPosAbs cfig sp = sp ^. spScreenOff * V2 w h + sp ^. spPixelOff
|
|
where
|
|
w = fromIntegral $ cfig ^. windowX
|
|
h = fromIntegral $ cfig ^. windowY
|