Files
loop/src/Dodge/RadarSweep/Draw.hs
T

40 lines
1.1 KiB
Haskell

module Dodge.RadarSweep.Draw (
drawRadarSweep,
) where
import Control.Lens
import Data.Maybe
import Dodge.Data.RadarSweep
import Geometry
import Picture
-- I have taken shortcuts in determining whether this is drawn or not wrt to the
-- linked ARHUD: it needs to have existed at the sweeps original creation, then
-- the sweep is drawn
drawRadarSweep :: RadarSweep -> Picture
drawRadarSweep pt
| isJust (pt ^. rsAR) =
setLayer DebugLayer $
fold
[ colHelper 0.1 $ uncurryV translate p $ thickCircle r 15
, colHelper 0.06 $ uncurryV translate p $ thickCircle (r -5) 5
, colHelper 0.03 $ uncurryV translate p $ thickCircle (r -10) 5
]
| otherwise = mempty
where
col = rsObjectColor $ _rsObject pt
p = _rsPos pt
r = _rsRad pt
colHelper y = color (withAlpha (y * globalAlpha) col)
globalAlpha
| x > 10 = 1
| otherwise = fromIntegral x / 10
x = _rsTimer pt
rsObjectColor :: ObjectType -> Color
rsObjectColor ob = case ob of
OTWall -> red
OTCreature -> green
OTItem -> blue
_ -> yellow