2014-10-10 15:40:08 +00:00
|
|
|
{-# OPTIONS_HADDOCK ignore-exports #-}
|
|
|
|
|
|
|
|
module Graphics.Diagram.Gif where
|
|
|
|
|
|
|
|
import Algebra.VectorTypes
|
|
|
|
import Codec.Picture.Gif
|
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 ((<>))
|
2014-10-10 15:40:08 +00:00
|
|
|
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 =
|
2014-10-13 17:53:33 +00:00
|
|
|
fmap ((\x -> (x, 100)) . (<> nonChDiag)) .
|
2014-10-10 15:40:08 +00:00
|
|
|
flip (++)
|
2014-10-14 19:24:21 +00:00
|
|
|
[mkDiag (convexHPText <>
|
2014-10-13 18:14:50 +00:00
|
|
|
convexHP)
|
2014-10-13 01:25:22 +00:00
|
|
|
p xs <> lastUpperHull <> lastLowerHull] $
|
|
|
|
(lowerHullList ++ ((<> lastLowerHull) <$> upperHullList))
|
2014-10-10 15:40:08 +00:00
|
|
|
where
|
2014-10-13 18:14:50 +00:00
|
|
|
upperHullList = convexUHStepsLs p xs
|
2014-10-13 00:58:18 +00:00
|
|
|
lastUpperHull = last upperHullList
|
2014-10-13 18:14:50 +00:00
|
|
|
lowerHullList = convexLHStepsLs p xs
|
2014-10-13 00:58:18 +00:00
|
|
|
lastLowerHull = last lowerHullList
|
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,
|
|
|
|
xAxis,
|
|
|
|
yAxis,
|
|
|
|
grid,
|
|
|
|
whiteRectB]
|
|
|
|
|
|
|
|
|
|
|
|
-- |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
|