forked from hanshoglund/animator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsketch.hs
executable file
·37 lines (26 loc) · 889 Bytes
/
sketch.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
{-# LANGUAGE
OverloadedStrings, NoMonomorphismRestriction, BangPatterns,
MultiParamTypeClasses, FlexibleInstances,
StandaloneDeriving, DeriveFunctor, DeriveFoldable, GeneralizedNewtypeDeriving #-}
module Main where
import Data.Semigroup
import Control.Applicative
import Foreign.JavaScript
import Web.Graphics.Processing
mouseX = fmap fst mouseS
mouseY = fmap snd mouseS
always = pure
fill = fillA
scale = scaleA
circle = circleA
oscCircle x c =
style . shape $ circle
where
shape = scale $ (sin $ timeS / 600 * x * tau) * (mouseY/600)
style = fill $ always $ c `withOpacity` 0.3
mouseCircle x c = style . shape $ circle
where
style = fill (always $ c `withOpacity` 0.3)
shape = scale (negate $ mouseX / 600 * x)
test = oscCircle 11 red <> mouseCircle 1 blue
main = runAnimation test "main-canvas"