Skip to content

Instantly share code, notes, and snippets.

@irisyupingren
Created February 20, 2020 21:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save irisyupingren/aea8716904ea511dd1f66ffa6c382918 to your computer and use it in GitHub Desktop.
Save irisyupingren/aea8716904ea511dd1f66ffa6c382918 to your computer and use it in GitHub Desktop.
reanimateEG
#!/usr/bin/env stack
-- stack runghc --package reanimate
{-# LANGUAGE OverloadedStrings #-}
module Main(main) where
import Reanimate
pitch = [71.0,71.0,71.0,73.0,74.0,73.0,71.0,74.0,73.0,66.0,71.0,69.0,71.0,71.0,71.0,73.0,74.0,73.0,71.0,74.0,76.0,78.0,78.0,80.0,81.0,83.0,83.0,76.0,81.0,83.0,85.0,86.0,85.0,76.0,78.0,76.0,81.0,83.0,85.0,86.0,85.0,81.0,83.0,76.0,81.0,83.0,81.0,81.0,81.0,81.0,81.0,83.0,81.0,69.0,69.0,71.0,73.0,69.0,76.0,74.0,73.0,74.0,73.0,69.0,69.0,69.0,71.0,73.0,71.0,69.0,76.0,74.0,73.0,74.0,73.0,69.0,76.0,78.0,80.0,81.0,81.0,81.0,83.0,83.0,81.0,80.0,81.0,83.0,83.0,76.0,81.0,83.0,81.0,81.0,81.0,81.0,81.0,83.0,85.0]
on = [0.0,4.5,5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.75,9.5,15.5,16.0,20.5,21.0,21.5,22.0,22.5,23.0,23.5,24.0,24.75,25.5,31.0,32.0,35.0,35.5,37.5,38.0,38.5,39.0,39.5,40.0,41.5,43.0,45.5,46.0,46.5,47.0,47.5,48.0,49.5,51.0,54.5,55.0,55.5,56.0,56.75,57.5,58.25,59.0,59.75,60.5,62.5,63.0,63.5,64.0,69.5,70.0,70.5,71.0,71.5,72.0,73.0,73.5,79.0,80.0,81.0,81.5,85.5,86.0,86.5,87.0,87.5,88.0,89.0,89.5,92.0,93.75,94.5,95.25,96.0,99.0,99.5,111.0,111.5,112.0,115.0,115.5,118.5,119.0,119.5,120.0,120.75,121.5,122.25,123.0,123.75,124.5]
dur = [4.0,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.75,0.75,2.5,0.5,4.0,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.75,0.75,2.5,1.0,3.0,0.5,2.0,0.5,0.5,0.5,0.5,0.5,1.5,1.5,2.5,0.5,0.5,0.5,0.5,0.5,1.5,1.5,3.5,0.5,0.5,0.5,0.75,0.75,0.75,0.75,0.75,0.75,2.0,0.5,0.5,0.5,4.0,0.5,0.5,0.5,0.5,0.5,1.0,0.5,2.5,1.0,1.0,0.5,2.5,0.5,0.5,0.5,0.5,0.5,1.0,0.5,2.5,1.75,0.75,0.75,0.75,3.0,0.5,0.5,0.5,0.5,3.0,0.5,0.5,0.5,0.5,0.5,0.75,0.75,0.75,0.75,0.75,0.75,2.5]
transitionTime :: Double
transitionTime = 1
main :: IO ()
main = reanimate $
transitions fadeInE fadeOutE transitionTime
(zipWith3 animateCircleR dur on pitch)
animateCircleR :: Double -> Double -> Double -> Animation
animateCircleR dur x y = mkSegment dur $ \t -> mkCircle2 0.5 (x / 100) ((y - 72) / 12)
mkSegment :: Double -> (Time -> SVG) -> Animation
mkSegment dur gen = mkAnimation dur $ \t -> env $
mkGroup [translate (- (screenWidth) * ( t * 0.25)) 0 $ gen t]
env :: SVG -> SVG
env =
withStrokeColor "red" .
withFillColor "black" .
withStrokeWidth (defaultStrokeWidth*2)
@lemmih
Copy link

lemmih commented Feb 21, 2020

What is 'mkCircle2' ?

@lemmih
Copy link

lemmih commented Feb 21, 2020

Try this:

import Reanimate.Animation

main :: IO ()
main = reanimate $ parA (staticFrame 0 $ mkBackground "black") $
                   transitions fadeInE fadeOutE transitionTime
                       (zipWith3 animateCircleR dur on pitch)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment