Use V2 instead of tuples and rename 'sceneAnimation' to 'scene'. (#165)

This commit is contained in:
David Himmelstrup 2020-09-19 22:17:51 +08:00 committed by GitHub
commit d37e71ca94
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
68 changed files with 140 additions and 214 deletions

View file

@ -7,101 +7,10 @@ import Reanimate
import Reanimate.Builtin.Documentation
import Reanimate.Scene
import Control.Lens
import Linear.V2
main :: IO ()
{-
main = reanimate $ docEnv $ mapA (withFillOpacity 1) $ sceneAnimation $ do
cam <- newObject Camera
newSpriteSVG_ $ withStrokeWidth (defaultStrokeWidth*0.5) $ mkGroup
[ mkLine (0, screenBottom) (0, screenTop)
, mkLine (screenLeft, 0) (screenRight, 0)
]
box <- newObject $ Rectangle 1 1
cameraAttach cam box
oModify box $ oContext .~ withFillColor "green"
oModify box $ oMargin .~ (0,0,0,0)
oModify box $ oLeftX .~ 0
oModify box $ oBottomY .~ 0
oModify box $ oContext .~ withStrokeWidth 0
box2 <- newObject $ Rectangle 1 1
cameraAttach cam box2
oModify box2 $ oContext .~ withFillColor "blue"
oModify box2 $ oMargin .~ (0,0,0,0)
oModify box2 $ oCenterXY .~ (-2,2)
oModify box2 $ oContext .~ withStrokeWidth 0
dot <- newObject $ Circle 0.05
cameraAttach cam dot
oModify dot $ oContext .~ withFillColor "red"
oModify dot $ oMargin .~ (0,0,0,0)
oModify dot $ oCenterXY .~ (0.5,0.5)
oModify dot $ oContext .~ withStrokeWidth 0
dot2 <- newObject $ Circle 0.05
cameraAttach cam dot2
oModify dot2 $ oContext .~ withFillColor "red"
oModify dot2 $ oMargin .~ (0,0,0,0)
oModify dot2 $ oCenterXY .~ (-2,2)
oModify dot2 $ oContext .~ withStrokeWidth 0
oShow box
oShow box2
oShow dot
oShow dot2
wait 1
cameraSetFocus cam (0.5, 0.5)
waitOn $ do
fork $ cameraPan cam 1 (0.5, 0.5)
fork $ cameraZoom cam 1 2
wait 1
cameraSetFocus cam (-2,2)
cameraZoom cam 0.5 1.5
cameraZoom cam 0.5 2
wait 1
-- cameraSetFocus cam (-0.5,0.5)
waitOn $ do
fork $ cameraPan cam 1 (-2, 2)
fork $ cameraZoom cam 1 0.5
-- oTweenS cam 2 $ \t -> do
-- oScale %= \v -> fromToS v 3 t
-- cameraSetFocus cam (0.5,0.5)
-- oTweenS cam 1 $ \t -> do
-- oScale %= \v -> fromToS v 1 t
-- wait 4
-- oTweenS cam 2 $ \t -> do
-- oScaleOrigin .= (fromToS 0.5 (-2) t, fromToS 0.5 2 t)
-- oScale .= fromToS 2 1 t
-- oTranslate . _1 %= \v -> fromToS v (-2) t
-- oTranslate . _2 %= \v -> fromToS v 2 t
{-
Origin: (-2,2)
Translate: (3, -1)
New origin: (0.5, 0.5)
(0.5, 0.5)
(0.5+2, 0.5-2)
(2.5, -1.5) origin move
(2.5*3, -1.5*3)
(7.5, -4.5) scale
(7.5-2, -4.5+2)
(5.5, -2.5) origin move back
(5.5-3, -2.5+1)
(2.5, -1.5) translate
(0.5-2.5, 0.5-(-1.5))
(-2, 2)
-}
wait 1
-}
main = reanimate $ docEnv $ mapA (withFillOpacity 1) $ sceneAnimation $ do
main = reanimate $ docEnv $ mapA (withFillOpacity 1) $ scene $ do
cam <- newObject Camera
txt <- newObject $ center $ latex "Fixed (non-cam)"
@ -141,4 +50,4 @@ main = reanimate $ docEnv $ mapA (withFillOpacity 1) $ sceneAnimation $ do
waitOn $ do
fork $ cameraZoom cam 3 1
waitOn $ do
fork $ cameraPan cam 1 (0,0)
fork $ cameraPan cam 1 (V2 0 0)