reactive-fieldtrip 0.0.2 → 0.0.3
raw patch · 3 files changed
+22/−20 lines, 3 files
Files
- README +4/−2
- reactive-fieldtrip.cabal +1/−1
- src/Test.hs +17/−17
README view
@@ -1,5 +1,6 @@-This library [1] connects '''reactive''' [2] (a functional reactive-programming library) and '''FieldTrip''' [3] (a functional 3D library).+The reactive-fieldtrip library [1] connects reactive [2] (a functional+reactive programming library) and FieldTrip [3] (a functional 3D library).+It's a simple extension of reactive-glut [4]. Please share any comments & suggestions on the discussion (talk) page at [1].@@ -16,3 +17,4 @@ [1] http://haskell.org/haskellwiki/reactive-fieldtrip [2] http://haskell.org/haskellwiki/reactive [3] http://haskell.org/haskellwiki/FieldTrip+[4] http://haskell.org/haskellwiki/reactive-glut
reactive-fieldtrip.cabal view
@@ -1,5 +1,5 @@ Name: reactive-fieldtrip-Version: 0.0.2+Version: 0.0.3 Cabal-Version: >= 1.2 Synopsis: Connect Reactive and FieldTrip Category: Graphics, FRP
src/Test.hs view
@@ -53,8 +53,9 @@ -- Reverse text on left button press revTxt :: String -> Anim2-revTxt str ui = utext <$> accumLB str reverse ui+revTxt str = (fmap.fmap) utext (accumLB str reverse) +-- revTxt str ui = utext <$> accumLB str reverse ui -- revTxt = (fmap.fmap.fmap) utext (flip accumLB reverse) rotTxt :: Double -> Geometry2@@ -69,7 +70,7 @@ f = (uscale2 (0.5::Float) *%) . utext . show spin :: Anim3-spin = spinningG $+spin = const . spinningG $ -- usphere torusPair -- flatG txt@@ -79,7 +80,7 @@ where tor = torus 1 (2/5) f :: Col -> R -> Geometry3- f col dx = plasmat col (move3X dx tor)+ f col dx = materialG (plastic col) (move3X dx tor) -- Start at zero with a velocity of one. Negate velocity on each event occurrence. reverseVel :: (UI -> Event a) -> Anim Double@@ -109,22 +110,24 @@ -- Drop a ball from the mouse on each left button press. ldrops :: Anim3-ldrops ui =- drops' (leftButtonPressed ui `snapshot_` mouseMotion ui)- (framePass ui)+ldrops = liftA2 drops' (liftA2 snapshot_ leftButtonPressed mouseMotion)+ framePass +-- ldrops ui =+-- drops' (leftButtonPressed ui `snapshot_` mouseMotion ui)+-- (framePass ui)+ -- Place a ball on each event occurrence place :: Event (Vector3 Double) -> Behavior Geometry3 place starts = monoidB (g <$> starts) where- g start = f <$> spinningG torusPair (error "blort!")- where f = (translate3 start *%)+ g start = (translate3 start *%) <$> spinningG torusPair -- Drop a ball from the mouse on each left button press. lplace :: Anim3-lplace ui = place (leftButtonPressed ui `snapshot_` mouseMotion ui)+lplace = place <$> liftA2 snapshot_ leftButtonPressed mouseMotion --- lplace = place . liftA2 snapshot_ leftButtonPressed mouseMotion+-- lplace ui = place (leftButtonPressed ui `snapshot_` mouseMotion ui) @@ -135,14 +138,11 @@ where f (mx,my) = vector3 mx my 0 -plasmat :: Col -> Filter3-plasmat col = materialG (plastic col)--spinningG :: Geometry3 -> Anim3-spinningG g env = liftA2 (*%) (spinning env) (pure g)+spinningG :: Geometry3 -> Behavior Geometry3+spinningG g = liftA2 (*%) spinning (pure g) -spinning :: Anim (Transform3 Double)-spinning = const (xf . (*2) <$> time)+spinning :: Behavior (Transform3 Double)+spinning = xf . (*2) <$> time where xf t = translate3 (Vector3 (0::Double) 0 (3*sin (-t/5))) `mappend` rotate3 t (Vector3 0.1 0.2 0.3)