Move pair to V2
This commit is contained in:
@@ -5,13 +5,13 @@ module Dodge.Base.Coordinate (
|
||||
worldPosToResOffset,
|
||||
) where
|
||||
|
||||
import Dodge.WindowSize
|
||||
import Linear
|
||||
import Dodge.Data.Config
|
||||
import Control.Lens
|
||||
import Dodge.Data.Camera
|
||||
import Dodge.Data.Config
|
||||
import Dodge.Data.Input
|
||||
import Dodge.WindowSize
|
||||
import Geometry
|
||||
import Linear
|
||||
|
||||
{- | Transform world coordinates to scaled screen coordinates.
|
||||
- These have to be scaled according to the size of the window to get actual screen positions.
|
||||
@@ -25,14 +25,14 @@ worldPosToScreen cam =
|
||||
. ((cam ^. camZoom) *^)
|
||||
. (-.- (cam ^. camCenter))
|
||||
|
||||
-- gets the position from the bottom left in "world res" "pixels"
|
||||
-- gets the position from the bottom left in world-resolution "pixels"
|
||||
worldPosToResOffset :: Config -> Camera -> Point2 -> Point2
|
||||
worldPosToResOffset cfig cam p = (worldPosToScreen cam p & each %~ f)
|
||||
+ 0.5 *^ (uncurry V2 (getWindowSize _gr_world_res cfig::(Int,Int)) & each %~ fromIntegral)
|
||||
worldPosToResOffset cfig cam p =
|
||||
(worldPosToScreen cam p & each %~ f)
|
||||
+ 0.5 *^ ((getWindowSize _gr_world_res cfig :: V2 Int) & each %~ fromIntegral)
|
||||
where
|
||||
f x = applyResFactorF (cfig ^. gr_world_res) x
|
||||
|
||||
|
||||
-- | The mouse position in world coordinates.
|
||||
mouseWorldPos :: Input -> Camera -> Point2
|
||||
mouseWorldPos inp cam = screenToWorldPos cam (inp ^. mousePos)
|
||||
|
||||
Reference in New Issue
Block a user