mirror of
https://github.com/reanimate/reanimate.git
synced 2026-09-14 09:32:22 +00:00
Add goo filter example.
This commit is contained in:
parent
3527952da8
commit
6f986eca03
3 changed files with 53 additions and 0 deletions
|
|
@ -24,6 +24,7 @@ Live coding playground: https://lemmih.github.io/reanimate/
|
||||||
The example gifs are displayed at 25 fps. The source code for many of these examples are available
|
The example gifs are displayed at 25 fps. The source code for many of these examples are available
|
||||||
on the live coding playground.
|
on the live coding playground.
|
||||||
|
|
||||||
|

|
||||||

|

|
||||||

|

|
||||||

|

|
||||||
|
|
|
||||||
BIN
gifs/goo.gif
Normal file
BIN
gifs/goo.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 MiB |
|
|
@ -751,3 +751,55 @@ drawSunflower = mkAnimation 10 $ do
|
||||||
sunflower n = frame 4 $ position $ take n $ zip mkCoords florets
|
sunflower n = frame 4 $ position $ take n $ zip mkCoords florets
|
||||||
where
|
where
|
||||||
florets = [ floret (sqrt (fromIntegral i)) | i <- [1 ..]]
|
florets = [ floret (sqrt (fromIntegral i)) | i <- [1 ..]]
|
||||||
|
|
||||||
|
mkFilter :: String -> [FilterElement] -> Filter
|
||||||
|
mkFilter ident fe = defaultSvg & filterChildren .~ fe & attrId .~ Just ident
|
||||||
|
|
||||||
|
gooEffect :: Animation
|
||||||
|
gooEffect = mkAnimation 5 $ do
|
||||||
|
s <- oscillate $ signal 0 3
|
||||||
|
emit $ mkBackground "black"
|
||||||
|
emit $ FilterTree $ mkFilter "blur"
|
||||||
|
[FEGaussianBlur $ defaultSvg
|
||||||
|
& gaussianBlurStdDeviationX .~ Num dev
|
||||||
|
& filterResult .~ Just "blur"
|
||||||
|
] & filterWidth .~ pure (Percent 3)
|
||||||
|
& filterX .~ pure (Percent (-1))
|
||||||
|
& filterHeight .~ pure (Percent 3)
|
||||||
|
& filterY .~ pure (Percent (-1))
|
||||||
|
emit $ FilterTree $ mkFilter "goo"
|
||||||
|
[FEGaussianBlur $ defaultSvg
|
||||||
|
& gaussianBlurStdDeviationX .~ Num dev
|
||||||
|
& filterResult .~ Just "blur"
|
||||||
|
,FEColorMatrix $ defaultSvg
|
||||||
|
& colorMatrixType .~ Matrix
|
||||||
|
& colorMatrixValues .~ "1 0 0 0 0 \
|
||||||
|
\0 1 0 0 0 \
|
||||||
|
\0 0 1 0 0 \
|
||||||
|
\0 0 0 " ++ show (sharpness*2) ++ " -" ++ show sharpness
|
||||||
|
& filterResult .~ pure "goo"
|
||||||
|
,FEComposite $ defaultSvg
|
||||||
|
& compositeIn .~ pure SourceGraphic
|
||||||
|
& compositeIn2 .~ pure (SourceRef "goo")
|
||||||
|
& compositeOperator .~ CompositeAtop
|
||||||
|
] & filterHeight .~ pure (Percent 3)
|
||||||
|
& filterY .~ pure (Percent (-1))
|
||||||
|
emit $ translate 0 (-radius*2) $ withFillColor "red" $ mkGroup
|
||||||
|
[ translate (s*(-radius)) 0 circ
|
||||||
|
, translate (s*radius) 0 circ
|
||||||
|
]
|
||||||
|
emit $ withFillColor "red" $ mkGroup
|
||||||
|
[ translate (s*(-radius)) 0 circ
|
||||||
|
, translate (s*radius) 0 circ
|
||||||
|
]
|
||||||
|
& filterRef .~ pure (Ref "blur")
|
||||||
|
emit $ translate 0 (radius*2) $ withFillColor "red" $ set filterRef (pure $ Ref "goo")
|
||||||
|
$ mkGroup [ translate (s*(-radius)) 0 circ
|
||||||
|
, translate (s*radius) 0 circ ]
|
||||||
|
where
|
||||||
|
sharpness = 60
|
||||||
|
dev = 10
|
||||||
|
radius = 25
|
||||||
|
circ = CircleTree $ defaultSvg
|
||||||
|
& circleCenter .~ (Num 0, Num 0)
|
||||||
|
& circleRadius .~ Num radius
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue