Use gifs to improve documentation. (#21)

Former-commit-id: 40e5ccedcf5d1ca8f0d5cc373ba3b3c4cc2d6c6a
This commit is contained in:
David Himmelstrup 2019-09-28 21:35:42 +08:00 committed by GitHub
commit dfd52961ae
50 changed files with 512 additions and 129 deletions

View file

@ -29,7 +29,7 @@ run out.
-}
main :: IO ()
main = reanimate $ pauseAtEnd 2
(animate $ const $ mkBackground "black") `sim`
(animate $ const $ mkBackground "black") `parA`
drawBox
drawBox :: Animation
@ -38,9 +38,9 @@ drawBox = mkAnimation 5 $ \t ->
[ withFillColor "white" $
translate 0 (-70) $
scale 2 $ center $ latex "Baker's Algorithm"
, let s = signalFromList [(0.7, signalFlat 0), (1, signalLinear)] t
d = signalFromList [(0.7, signalFlat 0), (1, signalLinear)] t
draw = signalFromList [(0.5, signalLinear), (1, signalFlat 1)] t
, let s = fromListS [(0.7, constantS 0), (1, id)] t
d = fromListS [(0.7, constantS 0), (1, id)] t
draw = fromListS [(0.5, id), (1, constantS 1)] t
mlc = MemoryLineChart
{ mlcWidth = 230
, mlcHeight = 50 + s*50
@ -59,7 +59,7 @@ highlightBox = mkAnimation 2 $ \t ->
boxY = negate mlcHeight / 2
mlcWidth = 230
mlcHeight = 50
s = signalFromList [(0.0, signalFlat 0), (1, signalBell 2)] t
s = fromListS [(0.0, constantS 0), (1, bellS 2)] t
in
withStrokeColor "white" $
withStrokeWidth (0.5 + s) $

View file

@ -23,7 +23,7 @@ import System.Random
import System.Random.Shuffle
fixed :: Tree -> Animation -> Animation
fixed svg ani = animate (const svg) `sim` ani
fixed svg ani = animate (const svg) `parA` ani
digitWidth = 25
digitCount = 10
@ -53,7 +53,7 @@ main = reanimate $ fixed bg $ pauseAtEnd 1 $
-- msg = "Eve"
glyphs = lowerTransformations $ scale 3 $ pathify $ center $ latexAlign msg
fillText = mkAnimation 1 $ \t ->
let sat = signalFromTo 0 0.7 signalLinear t in
let sat = fromToS 0 0.7 t in
withFillColor "white" $ withStrokeColor "white" $ withStrokeWidth (0.4 * (1-t)) $
withFillOpacity t glyphs
-- withSubglyphs [0] (withFillColorPixel $ toRGBString sat 0.0) $
@ -146,7 +146,7 @@ renderSortElement SortElement{..} t
| t > sortElementStartTime + sortElementDuration =
translate (fromIntegral sortElementEndPosition * digitWidth) 0 sortElementTree
| otherwise =
let pos = signalCurve 2 $ (t - sortElementStartTime) / sortElementDuration
let pos = curveS 2 $ (t - sortElementStartTime) / sortElementDuration
from = sortElementStartPosition
to = sortElementEndPosition
linear = fromIntegral from + (fromIntegral (to-from))*pos