cga/Graphics/Diagram/Gif.hs
hasufell 55e2ddd500
DIAGRAM: small refactor
Update Diag type to play more nicely with GifDiags.
2014-10-25 23:54:07 +02:00

38 lines
1.2 KiB
Haskell

{-# OPTIONS_HADDOCK ignore-exports #-}
module Graphics.Diagram.Gif where
import Algebra.VectorTypes
import Algorithms.ConvexHull.GrahamScan
import Codec.Picture.Gif
import Data.Monoid
import Diagrams.Backend.Cairo
import Diagrams.Prelude hiding ((<>))
import Graphics.Diagram.Plotter
import Graphics.Diagram.Types
import Parser.Meshparser
-- |Return a list of tuples used by 'gifMain' to generate an animated gif.
gifDiag :: DiagProp -> [PT] -> [(Diagram Cairo R2, GifDelay)]
gifDiag p xs =
fmap ((\x -> (x, 50)) . (<> nonChDiag))
(upperHullList
<> fmap (<> last upperHullList) lowerHullList
<> [mkDiag (mconcat [convexHPText, convexHP, convexHLs])
p{ ct = True } (Object xs)])
where
upperHullList = mkGifDiag convexHStepsLs p purple grahamUHSteps xs
lowerHullList = mkGifDiag convexHStepsLs p orange grahamLHSteps xs
-- add the x-axis and the other default stuff
nonChDiag =
mconcat .
fmap (\x -> mkDiag x p (Object xs)) $
[coordPoints, plotterBG]
-- |Same as gifDiag, except that it takes a string containing the
-- mesh file content instead of the the points.
gifDiagS :: DiagProp -> MeshString -> [(Diagram Cairo R2, GifDelay)]
gifDiagS p = gifDiag p . meshToArr