prefilter drawing elements

This commit is contained in:
nek0 2019-03-07 15:13:40 +01:00
parent b2e9af5efd
commit 8ec9f9cb6f

View file

@ -615,10 +615,36 @@ drawMap = do
closePath ctx closePath ctx
fillColor ctx (rgb 255 255 255) fillColor ctx (rgb 255 255 255)
fill ctx fill ctx
void $ sequence $ parMap rpar (\(i, ls) -> void $ sequence $ parMap rpar let coordList = concatMap
(\(j, t) -> drawTile ud ctx (partposanims M.! (i, j)) pr pc i j t) (\(i, ls) -> Prelude.map
(reverse $ zip [1..] ls)) (\(j, t) -> ((i, j), t))
(zip [1..] (toLists mat)) (reverse $ zip [1..] ls)
)
(zip [1..] (toLists mat))
filterList = Prelude.filter
(\((frow, fcol), tile) ->
((realToFrac (sx frow fcol) > -tileWidth &&
realToFrac (sy frow fcol) > -tileHeight) &&
((realToFrac (sx frow fcol) :: Double) < 1280 &&
(realToFrac ((sy frow fcol)- (74 - (realToFrac tileHeight :: CFloat))) :: Double) < 720))
)
coordList
!posanimList = Prelude.map
(\((row, col), tile) -> ((row, col), tile, partposanims M.! (row, col)))
filterList
sx row col = realToFrac $ 640 + ((fromIntegral col - pc) +
(fromIntegral row - pr)) * (tileWidth / 2) :: CFloat
sy row col = realToFrac $ 360 - (tileHeight / 2) + ((fromIntegral row - pr) -
(fromIntegral col - pc)) * (tileHeight / 2) :: CFloat
void $ sequence $ parMap rpar
(\((row, col), tile, posanim) ->
drawTile ud ctx posanim pr pc row col tile
)
posanimList
-- void $ sequence $ parMap rpar (\(i, ls) -> void $ sequence $ parMap rpar
-- (\(j, t) -> drawTile ud ctx (partposanims M.! (i, j)) pr pc i j t)
-- (reverse $ zip [1..] ls))
-- (zip [1..] (toLists mat))
mapM_ (\(V2 sr sc, pa, perc) -> when pa $ do mapM_ (\(V2 sr sc, pa, perc) -> when pa $ do
let lx = realToFrac $ 640 + ((sc - pc) + let lx = realToFrac $ 640 + ((sc - pc) +
(sr - pr)) * (tileWidth / 2) :: CFloat (sr - pr)) * (tileWidth / 2) :: CFloat
@ -658,24 +684,21 @@ drawTile
-> Maybe ImgId -> Maybe ImgId
-> IO () -> IO ()
drawTile ud ctx posanims pr pc row col img = drawTile ud ctx posanims pr pc row col img =
when ((realToFrac x > -tileWidth && realToFrac y > -tileHeight) && do
((realToFrac x :: Double) < 1280 && let (bef, beh) = L.partition delimiter sorted
(realToFrac (y - (74 - (realToFrac tileHeight :: CFloat))) :: Double) < 720)) $ save ctx
do mapM_ drawAnim beh
let (bef, beh) = L.partition delimiter sorted maybe (return ()) (draw ud x (y - 42) 64 74 fact)
save ctx ((assetImages ud Map.!) <$> case img of
mapM_ drawAnim beh Just ImgEmpty -> Nothing
maybe (return ()) (draw ud x (y - 42) 64 74 fact) _ -> img
((assetImages ud Map.!) <$> case img of )
Just ImgEmpty -> Nothing mapM_ drawAnim bef
_ -> img restore ctx
) -- when (floor pr == row && floor pc == col) $ do
mapM_ drawAnim bef -- A.logIO A.Debug ("sorted: " ++ show sorted)
restore ctx -- A.logIO A.Debug ("beh: " ++ show beh)
-- when (floor pr == row && floor pc == col) $ do -- A.logIO A.Debug ("bef: " ++ show bef)
-- A.logIO A.Debug ("sorted: " ++ show sorted)
-- A.logIO A.Debug ("beh: " ++ show beh)
-- A.logIO A.Debug ("bef: " ++ show bef)
where where
delimiter (V2 nr nc, as, mbnds) = delimiter (V2 nr nc, as, mbnds) =
animFloats (asId as) || animFloats (asId as) ||