Refactor, try to limit dependencies

This commit is contained in:
2022-07-28 00:59:56 +01:00
parent 8aa5c17ab9
commit 160560af5f
418 changed files with 15104 additions and 13342 deletions
+52 -48
View File
@@ -1,44 +1,44 @@
module Dodge.Picture.SizeInvariant
where
import Dodge.Data
--import Dodge.Base
module Dodge.Picture.SizeInvariant where
import Data.Maybe
import Dodge.Base.Window
import Dodge.Data.Universe
import Geometry
import Picture
import Data.Maybe
fixedSizePicAt
:: Picture
-> Point2
-> World
-> Picture
fixedSizePicAt pic p w
= setLayer DebugLayer
. setDepth 20
. translate x y
. scale theScale theScale
$ pic
fixedSizePicAt ::
Picture ->
Point2 ->
World ->
Picture
fixedSizePicAt pic p w =
setLayer DebugLayer
. setDepth 20
. translate x y
. scale theScale theScale
$ pic
where
campos = _cameraViewFrom (_cWorld w)
v = p -.- campos
theScale = 1 / _cameraZoom (_cWorld w)
(V2 x y) = campos +.+ v
fixedSizePicClamp
:: Int -- ^ horizontal border
-> Int -- ^ vertical border
-> Picture
-> Point2
-> Configuration
-> World
-> Picture
fixedSizePicClamp xbord ybord pic p cfig w
= setLayer DebugLayer
. setDepth 20
. translate x y
. scale theScale theScale
$ pic
fixedSizePicClamp ::
-- | horizontal border
Int ->
-- | vertical border
Int ->
Picture ->
Point2 ->
Configuration ->
World ->
Picture
fixedSizePicClamp xbord ybord pic p cfig w =
setLayer DebugLayer
. setDepth 20
. translate x y
. scale theScale theScale
$ pic
where
r = negate $ _cameraRot (_cWorld w)
z = _cameraZoom (_cWorld w)
@@ -47,21 +47,24 @@ fixedSizePicClamp xbord ybord pic p cfig w
theScale = 1 / _cameraZoom (_cWorld w)
(V2 x y) = campos +.+ rotateV (negate r) (V2 xr' yr')
(V2 xr yr) = rotateV r v
xr' = absClamp ((halfWidth cfig - fromIntegral xbord) / z) xr
xr' = absClamp ((halfWidth cfig - fromIntegral xbord) / z) xr
yr' = absClamp ((halfHeight cfig - fromIntegral ybord) / z) yr
fixedSizePicClampArrow
:: Float -- ^ horizontal border
-> Float -- ^ vertical border
-> Picture
-> Point2
-> Configuration
-> World
-> Picture
fixedSizePicClampArrow xbord ybord pic p cfig w = pictures
[ setLayer DebugLayer . translate x y . scale theScale theScale $ pic
, setLayer DebugLayer . color white . setDepth 20 $ arrowPic
]
fixedSizePicClampArrow ::
-- | horizontal border
Float ->
-- | vertical border
Float ->
Picture ->
Point2 ->
Configuration ->
World ->
Picture
fixedSizePicClampArrow xbord ybord pic p cfig w =
pictures
[ setLayer DebugLayer . translate x y . scale theScale theScale $ pic
, setLayer DebugLayer . color white . setDepth 20 $ arrowPic
]
where
winps = screenPolygon cfig w
bords = screenPolygonBord xbord ybord cfig w
@@ -74,8 +77,9 @@ fixedSizePicClampArrow xbord ybord pic p cfig w = pictures
campos = _cameraCenter (_cWorld w)
theScale = 1 / _cameraZoom (_cWorld w)
absClamp
:: Float -- ^ clamping value, assumed positive
-> Float
-> Float
absClamp ::
-- | clamping value, assumed positive
Float ->
Float ->
Float
absClamp maxVal x = max (negate maxVal) $ min maxVal x