Wibbles to bazier.

This commit is contained in:
David 2019-02-15 20:41:37 +01:00
commit 8cc7e76efc
2 changed files with 10 additions and 12 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 272 KiB

After

Width:  |  Height:  |  Size: 340 KiB

Before After
Before After

View file

@ -350,15 +350,15 @@ latex_basic = proc () -> do
text = latex "\\sum_{k=1}^\\infty {1 \\over k^2} = {\\pi^2 \\over 6}" text = latex "\\sum_{k=1}^\\infty {1 \\over k^2} = {\\pi^2 \\over 6}"
bezier :: Ani () bezier :: Ani ()
bezier = adjustSpeed 0.5 $ proc () -> do bezier = adjustSpeed 0.4 $ proc () -> do
emit -< rect_ [width_ "100%", height_ "100%", fill_ "black"] emit -< rect_ [width_ "100%", height_ "100%", fill_ "black"]
follow follow
[orderN [pointA, pointB] [ orderN [pointA, pointB]
,morph [pointA, pointA, pointB] [pointA, pointC, pointB] , morph [pointA, pointA, pointB] [pointA, pointC, pointB]
,orderN [pointA, pointC, pointB] , orderN [pointA, pointC, pointB]
,morph [pointA, pointC, pointB, pointB] [pointA, pointC, pointD, pointB] , morph [pointA, pointC, pointB, pointB] [pointA, pointC, pointD, pointB]
,orderN [pointA, pointC, pointD, pointB] , orderN [pointA, pointC, pointD, pointB]
,morph [pointA, pointC, pointD, pointB] [pointA, pointA, pointB, pointB]] -< () , morph [pointA, pointC, pointD, pointB] [pointA, pointA, pointB, pointB]] -< ()
where where
pointA = (70,130); pointB = (270,120); pointC = (30,30); pointD = (250,50) pointA = (70,130); pointB = (270,120); pointC = (30,30); pointD = (250,50)
@ -375,18 +375,16 @@ bezier = adjustSpeed 0.5 $ proc () -> do
orderN lst = defineAnimation $ proc () -> do orderN lst = defineAnimation $ proc () -> do
duration 2 -< () duration 2 -< ()
s <- signalOscillate 0 1 -< () s <- signalOscillate 0 1 -< ()
emit -< orderN' (map const lst) s emit -< primaryCircleAt =<< orderN' (map const lst) s <* mapM_ secondaryCircleAt lst
orderN' [a] s = do orderN' [a] s = do
renderPath $ take (round $ 1000*s) $ approxFnData 1000 $ \idx -> a idx renderPath $ take (round $ 1000*s) $ approxFnData 1000 $ \idx -> a idx
primaryCircleAt (a s) return (a s)
orderN' lst s = do orderN' lst s = do
forM_ (zip lst (tail lst)) $ \(a,b) -> renderPath $ forM_ (zip lst (tail lst)) $ \(a,b) -> renderPath $
approxFnData 1000 $ \idx -> approxFnData 1000 $ \idx ->
between (a s) (b s) idx between (a s) (b s) idx
let middlePoints = map (\(a,b) -> \idx -> between (a idx) (b idx) idx) (zip lst (tail lst)) let middlePoints = map (\(a,b) -> \idx -> between (a idx) (b idx) idx) (zip lst (tail lst))
mapM_ secondaryCircleAt $ map ($s) middlePoints orderN' middlePoints s <* mapM_ secondaryCircleAt (map ($s) middlePoints)
mapM_ secondaryCircleAt $ map ($s) lst
orderN' middlePoints s
secondaryCircleAt (x,y) = circle_ [num_ cx_ x, num_ cy_ y, num_ r_ 3, fill_ "green"] secondaryCircleAt (x,y) = circle_ [num_ cx_ x, num_ cy_ y, num_ r_ 3, fill_ "green"]
primaryCircleAt (x,y) = circle_ [num_ cx_ x, num_ cy_ y, num_ r_ 3, fill_ "red"] primaryCircleAt (x,y) = circle_ [num_ cx_ x, num_ cy_ y, num_ r_ 3, fill_ "red"]