cga/Graphics/Diagram/Gif.hs

40 lines
1.3 KiB
Haskell
Raw Normal View History

2014-10-10 15:40:08 +00:00
{-# OPTIONS_HADDOCK ignore-exports #-}
module Graphics.Diagram.Gif where
import Algebra.Vector(PT)
import Algorithms.GrahamScan
2014-10-10 15:40:08 +00:00
import Codec.Picture.Gif
import qualified Data.ByteString.Char8 as B
2014-10-14 19:24:21 +00:00
import Data.Monoid
2014-10-10 15:40:08 +00:00
import Diagrams.Backend.Cairo
2014-10-14 19:24:21 +00:00
import Diagrams.Prelude hiding ((<>))
import Graphics.Diagram.AlgoDiags
import Graphics.Diagram.Core
2014-10-10 15:40:08 +00:00
import Graphics.Diagram.Plotter
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{ showCoordText = True } [xs]])
2014-10-10 15:40:08 +00:00
where
upperHullList = mkGifDiag convexHStepsLs p purple grahamUHSteps xs
lowerHullList = mkGifDiag convexHStepsLs p orange grahamLHSteps xs
2014-10-10 15:40:08 +00:00
-- add the x-axis and the other default stuff
nonChDiag =
mconcat .
fmap (\x -> mkDiag x p [xs]) $
[coordPoints, plotterBG]
2014-10-10 15:40:08 +00:00
-- |Same as gifDiag, except that it takes a string containing the
-- mesh file content instead of the the points.
gifDiagS :: DiagProp -> B.ByteString -> [(Diagram Cairo R2, GifDelay)]
gifDiagS p = gifDiag p . filterValidPT p . meshToArr