Wibbles to the voice_* examples.

Former-commit-id: e4f9c7e35d428e7e76ac5ce4fc01d200cf7c183d
This commit is contained in:
David Himmelstrup 2020-05-23 22:22:52 +08:00
commit 0d778646c1
2 changed files with 21 additions and 20 deletions

View file

@ -18,15 +18,13 @@ main :: IO ()
main = reanimate $ sceneAnimation $ do
newSpriteSVG_ $ mkBackgroundPixel rtfdBackgroundColor
waitOn $ forM_ (splitTranscript transcript) $ \(svg, tword) -> fork $ do
highlighted <- newVar 0
newSprite_ $ do
v <- unVar highlighted
pure $ centerUsing (latex $ transcriptText transcript) $ masked
(wordKey tword)
v
svg
(withFillColor "grey" $ mkRect 1 1)
(withFillColor "black" $ mkRect 1 1)
let render v = centerUsing (latex $ transcriptText transcript) $ masked
(wordKey tword)
v
svg
(withFillColor "grey" $ mkRect 1 1)
(withFillColor "black" $ mkRect 1 1)
highlighted <- simpleVar render 0
wait (wordStart tword)
let dur = wordEnd tword - wordStart tword
tweenVar highlighted dur $ \v -> fromToS v 1

View file

@ -15,20 +15,19 @@ transcript :: Transcript
transcript = loadTranscript "voice_triggers.txt"
transformer :: SVG -> SVG
transformer = scale 1 . translate (-4) 0 . centerUsing (latex $ transcriptText transcript)
transformer =
translate (-4) 0 . centerUsing (latex $ transcriptText transcript)
main :: IO ()
main = reanimate $ sceneAnimation $ do
newSpriteSVG_ $ mkBackgroundPixel rtfdBackgroundColor
waitOn $ forM_ (splitTranscript transcript) $ \(svg, tword) -> do
highlighted <- newVar 0
void $ newSprite $ do
v <- unVar highlighted
pure $ transformer $ masked (wordKey tword)
v
svg
(withFillColor "grey" $ mkRect 1 1)
(withFillColor "black" $ mkRect 1 1)
let render v = transformer $ masked (wordKey tword)
v
svg
(withFillColor "grey" $ mkRect 1 1)
(withFillColor "black" $ mkRect 1 1)
highlighted <- simpleVar render 0
let dur = wordEnd tword - wordStart tword
fork $ do
wait (wordStart tword)
@ -45,11 +44,15 @@ main = reanimate $ sceneAnimation $ do
_ -> return ()
wait 2
where
wordKey tword = T.unpack (wordReference tword) ++ show (wordStartOffset tword)
wordKey tword =
T.unpack (wordReference tword) ++ show (wordStartOffset tword)
highlight dur img =
play
$ animate
(\t -> translate (screenWidth / 4) 0 $ scale t $ scaleToHeight 4 $ center img)
(\t ->
translate (screenWidth / 4) 0 $ scale t $ scaleToHeight 4 $ center
img
)
# signalA (bellS 2)
# setDuration dur