Add file
This commit is contained in:
@@ -0,0 +1,13 @@
|
|||||||
|
{-# LANGUAGE StrictData #-}
|
||||||
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
|
module Dodge.Data.ScreenPos
|
||||||
|
where
|
||||||
|
|
||||||
|
import Geometry.Data
|
||||||
|
import Control.Lens
|
||||||
|
|
||||||
|
data ScreenPos = ScreenPos
|
||||||
|
{ _spScreenOff :: Point2
|
||||||
|
, _spPixelOff :: Point2
|
||||||
|
}
|
||||||
|
makeLenses ''ScreenPos
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
module Dodge.ScreenPos where
|
||||||
|
|
||||||
|
import Dodge.Base.Window
|
||||||
|
import Dodge.Data.Config
|
||||||
|
import Dodge.Data.ScreenPos
|
||||||
|
import Geometry.Data
|
||||||
|
import Picture.Base
|
||||||
|
import Control.Lens
|
||||||
|
|
||||||
|
fromTopLeft :: Point2 -> ScreenPos
|
||||||
|
fromTopLeft (V2 x y) = ScreenPos (V2 (-0.5) 0.5) (V2 x (- y))
|
||||||
|
|
||||||
|
translateScreenPos :: Configuration -> ScreenPos -> Picture -> Picture
|
||||||
|
translateScreenPos cfig sp = translate x y
|
||||||
|
where
|
||||||
|
V2 x y = sp ^. spScreenOff * V2 hw hh + sp ^. spPixelOff
|
||||||
|
hw = halfWidth cfig
|
||||||
|
hh = halfHeight cfig
|
||||||
Reference in New Issue
Block a user