mirror of
https://github.com/reanimate/reanimate.git
synced 2026-09-11 16:12:20 +00:00
Wrap CubicBezier with more convenient types. (#122)
This commit is contained in:
parent
a062eed0d6
commit
78a5b15eca
12 changed files with 381 additions and 565 deletions
|
|
@ -6,28 +6,22 @@ module Main
|
|||
)
|
||||
where
|
||||
|
||||
import Reanimate
|
||||
import Reanimate.Builtin.Documentation
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text as T
|
||||
import Graphics.SvgTree hiding (Point, Text, height)
|
||||
import Linear.Metric
|
||||
import Linear.V2
|
||||
import Linear.Vector
|
||||
import Linear.Metric
|
||||
import Graphics.SvgTree hiding ( Text
|
||||
, Point
|
||||
, height
|
||||
)
|
||||
import Data.Text ( Text )
|
||||
import qualified Data.Text as T
|
||||
import Reanimate
|
||||
import Reanimate.Builtin.Documentation
|
||||
import Reanimate.Internal.CubicBezier
|
||||
import Text.Printf
|
||||
import Geom2D.CubicBezier ( QuadBezier(..)
|
||||
, evalBezier
|
||||
, Point(..)
|
||||
)
|
||||
|
||||
main :: IO ()
|
||||
main = reanimate $ sceneAnimation $ do
|
||||
newSpriteSVG_ $ mkBackgroundPixel rtfdBackgroundColor
|
||||
newSpriteSVG_ static
|
||||
dotPath <- newVar (QuadBezier (Point 0 0) (Point 0 0) (Point 0 0))
|
||||
dotPath <- newVar (QuadBezier (V2 0 0) (V2 0 0) (V2 0 0))
|
||||
dotParam <- newVar 0
|
||||
newSprite_ $ redDot <$> (evalBezier <$> unVar dotPath <*> unVar dotParam)
|
||||
let moveDot a b = do
|
||||
|
|
@ -37,15 +31,15 @@ main = reanimate $ sceneAnimation $ do
|
|||
tweenVar dotParam 5 $ \v -> fromToS v 1 . curveS 2
|
||||
wait 1
|
||||
wait 1
|
||||
moveDot (Point 0 1) (Point 4 2)
|
||||
moveDot (Point (-1) 0) (Point (-4) 3)
|
||||
moveDot (Point (0) 0) (Point (-4) (-3))
|
||||
moveDot (Point (0) 0) (Point (5) (-2))
|
||||
moveDot (Point (6) 2) (Point 2 1)
|
||||
moveDot (Point (0) 0) (Point 0 0)
|
||||
moveDot (V2 0 1) (V2 4 2)
|
||||
moveDot (V2 (-1) 0) (V2 (-4) 3)
|
||||
moveDot (V2 (0) 0) (V2 (-4) (-3))
|
||||
moveDot (V2 (0) 0) (V2 (5) (-2))
|
||||
moveDot (V2 (6) 2) (V2 2 1)
|
||||
moveDot (V2 (0) 0) (V2 0 0)
|
||||
|
||||
redDot :: Point Double -> SVG
|
||||
redDot (Point x y) = translate x y $ mkGroup
|
||||
redDot :: V2 Double -> SVG
|
||||
redDot (V2 x y) = translate x y $ mkGroup
|
||||
[ translate 0 (-0.5) $ scale 0.5 $ outlinedText $ T.pack $ printf "%.1f,%.1f" x y
|
||||
, withFillColor "red" $ mkCircle 0.1
|
||||
]
|
||||
|
|
|
|||
Loading…
Reference in a new issue