cga/Graphics/Diagram/Gif.hs
hasufell 984ed40c63
Port to diagrams >1.3
# Conflicts:
#	Algebra/Vector.hs
#	CG2.cabal
#	Graphics/Diagram/Core.hs
#	Graphics/Diagram/Gif.hs
#	Graphics/Diagram/Gtk.hs
#	Test/Vector.hs
2015-05-21 02:14:15 +02:00

40 lines
1.3 KiB
Haskell

{-# OPTIONS_HADDOCK ignore-exports #-}
module Graphics.Diagram.Gif where
import Algebra.Vector
import Algorithms.GrahamScan
import Codec.Picture.Gif
import qualified Data.ByteString.Char8 as B
import Data.Monoid
import Diagrams.Backend.Cairo
import Diagrams.Prelude hiding ((<>))
import Graphics.Diagram.AlgoDiags
import Graphics.Diagram.Core
import Graphics.Diagram.Plotter
import Parser.Meshparser
-- |Return a list of tuples used by 'gifMain' to generate an animated gif.
gifDiag :: DiagProp -> [P2 Double] -> [(Diagram Cairo, GifDelay)]
gifDiag p xs =
fmap ((\x -> (x, 50)) . (<> nonChDiag))
(upperHullList
<> fmap (<> last upperHullList) lowerHullList
<> [mkDiag (mconcat [convexHPText, convexHP, convexHLs])
p{ showCoordText = True } [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 [xs])
$ [coordPoints, plotterBG]
-- |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, GifDelay)]
gifDiagS p = gifDiag p . filterValidPT p . meshToArr