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