never executed always true always false
    1 {-|
    2 Module      : Reanimate.Builtin.Documentation
    3 Copyright   : Written by David Himmelstrup
    4 License     : Unlicense
    5 Maintainer  : lemmih@gmail.com
    6 Stability   : experimental
    7 Portability : POSIX
    8 
    9 This module contains convenience functions used in documention
   10 GIFs for a consistent look and feel.
   11 
   12 -}
   13 module Reanimate.Builtin.Documentation where
   14 
   15 import Reanimate.Animation
   16 import Reanimate.Svg
   17 import Reanimate.Raster
   18 import Reanimate.Constants
   19 import Codec.Picture
   20 
   21 -- | Default environment for API documentation GIFs.
   22 docEnv :: Animation -> Animation
   23 docEnv = mapA $ \svg -> mkGroup
   24   [ mkBackground "white"
   25   , withFillOpacity 0 $
   26     withStrokeWidth 0.1 $
   27     withStrokeColor "black" (mkGroup [svg]) ]
   28 
   29 -- | <<docs/gifs/doc_drawBox.gif>>
   30 drawBox :: Animation
   31 drawBox = mkAnimation 2 $ \t ->
   32   partialSvg t $ pathify $
   33   mkRect (screenWidth/2) (screenHeight/2)
   34 
   35 -- | <<docs/gifs/doc_drawCircle.gif>>
   36 drawCircle :: Animation
   37 drawCircle = mkAnimation 2 $ \t ->
   38   partialSvg t $ pathify $
   39   mkCircle (screenHeight/3)
   40 
   41 -- | <<docs/gifs/doc_drawProgress.gif>>
   42 drawProgress :: Animation
   43 drawProgress = mkAnimation 2 $ \t ->
   44   mkGroup
   45   [ mkLine (-screenWidth/2*widthP,0)
   46            (screenWidth/2*widthP,0)
   47   , translate (-screenWidth/2*widthP + screenWidth*widthP*t) 0 $
   48     withFillOpacity 1 $ mkCircle 0.5 ]
   49   where
   50     widthP = 0.8
   51 
   52 -- | Render a full-screen view of a color-map.
   53 showColorMap :: (Double -> PixelRGB8) -> SVG
   54 showColorMap f = center $ scaleToSize screenWidth screenHeight $ embedImage img
   55   where
   56     width = 256
   57     height = 1
   58     img = generateImage pixelRenderer width height
   59     pixelRenderer x _y = f (fromIntegral x / fromIntegral (width-1))
   60 
   61 -- | Default background color for videos on reanimate.rtfd.io
   62 rtfdBackgroundColor :: PixelRGBA8
   63 rtfdBackgroundColor = PixelRGBA8 252 252 252 0xFF