Implement arcs with variable width and color

This commit is contained in:
2023-01-11 00:00:02 +00:00
parent 44f767841a
commit 471c6fec7e
11 changed files with 116 additions and 44 deletions
+36
View File
@@ -2,10 +2,12 @@ module Dodge.Render.ShapePicture (
worldSPic,
) where
import Picture.Test
import Dodge.Viewpoints
import Dodge.Render.Label
import Dodge.WorldEvent.ThingsHit
import Control.Lens
--import Control.Monad (guard)
import Data.Foldable
import qualified Data.Graph.Inductive as FGL
import qualified Data.Map.Strict as M
@@ -53,12 +55,46 @@ worldSPic cfig w =
<> foldup floorItemSPic (filtOn _flItPos _floorItems)
<> foldup btSPic (filtOn _btPos _buttons)
<> foldup mcSPic (filtOn _mcPos _machines)
<> aimDelaySweep cfig w
<> anyTargeting cfig w
where
foldup = foldMap'
filtOn f g = IM.filter (pointIsClose . f) (g (_lWorld (_cWorld w)))
pointIsClose = cullPoint cfig w
aimDelaySweep :: Configuration -> World -> SPic
aimDelaySweep cfig w = fromMaybe mempty $ do
cr <- w ^? cWorld . lWorld . creatures . ix 0
-- aimstatus <- cr ^? crStance . posture
-- guard (aimstatus == Aiming)
return $ noShape $ drawSweep cr cfig w
drawSweep :: Creature -> Configuration -> World -> Picture
drawSweep cr cfig w = fromMaybe mempty $ do
--a <- safeArgV (mwp -.- p)
return $ winScale cfig
$ setLayer FixedCoordLayer
$ uncurryV translate (worldPosToScreen campos p)
-- $ thickArcFull (rot + a) 1 white (rot + _crDir cr) 1 white (dist mwp p * campos ^. camZoom)
-- $ arc (rot + a) (rot + _crDir cr) (dist mwp p * campos ^. camZoom)
$ color white (circle 100)
-- <> arcTest (3*pi/4) 100 green 0 1 red 100
<> arcTest 0 5 green (3*pi/4) 50 red 100 white
-- <> f green 0 (pi/2) 100
-- <> f red 2 3 100
<> f blue 4 4.5 100 white
-- <> f 0 2 120 <> f 0 3 140 <> f 0 4 160 <> f 1 0 180 <> f 2 0 200
-- <> f 3 0 220 <> f 4 0 240
-- <> f (-0.5) 0.5 260 <> f 0.5 (-0.5) 280
where
f col a b c = arcTest a 25 col b 1 red c
--f a b c = thickArc a b c 5
--rot = campos ^. camRot
p = _crPos cr
campos = w ^. cWorld . camPos
--theinput = w ^. input
--mwp = mouseWorldPos theinput campos
anyTargeting :: Configuration -> World -> SPic
anyTargeting cfig w = fromMaybe mempty $ do
tt <- cr ^? crTargeting . ctType . _Just