Skip to content

Commit

Permalink
Merge branch 'release-0.14.6'. Refs #282.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanperez-keera committed Dec 8, 2023
2 parents c24510f + b226d26 commit ea668ec
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 11 deletions.
3 changes: 3 additions & 0 deletions yampa-test/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2023-12-07 Ivan Perez <[email protected]>
* Version bump (0.14.6) (#282).

2023-10-07 Ivan Perez <[email protected]>
* Version bump (0.14.5) (#278).
* Move test for consistency with module tested (#267).
Expand Down
4 changes: 2 additions & 2 deletions yampa-test/yampa-test.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ cabal-version: >= 1.10
build-type: Simple

name: yampa-test
version: 0.14.5
version: 0.14.6
author: Ivan Perez
maintainer: [email protected]
homepage: http://github.com/ivanperez-keera/Yampa
Expand Down Expand Up @@ -84,7 +84,7 @@ library
base >= 4 && < 5
, normaldistribution >= 1.1.0.1 && < 1.2
, QuickCheck >= 2.12 && < 2.15
, Yampa >= 0.14.5 && < 0.15
, Yampa >= 0.14.6 && < 0.15

default-language:
Haskell2010
Expand Down
7 changes: 7 additions & 0 deletions yampa/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2023-12-07 Ivan Perez <[email protected]>
* Version bump (0.14.6) (#282).
* Document HTML + WebAssembly backend in README (#34).
* Relax version bounds on deepseq (#280).
* Update and improve documentation of Diagrams example (#281).
* Thanks to @AntanasKal.

2023-10-07 Ivan Perez <[email protected]>
* Version bump (0.14.5) (#278).
* Define Yampa.FRP.Task.return in terms of pure (#276).
Expand Down
1 change: 1 addition & 0 deletions yampa/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ want. Existing backends include:
* WX (see wxHaskell)
* HTML Canvas via JS Dom (for an example, see [haskanoid's GHCJS branch](https://github.com/ivanperez-keera/haskanoid/blob/ghcjs/src/Display.hs))
* HTML5 Canvas via blank-canvas (see [yampa-canvas](https://github.com/ku-fpg/yampa-canvas))
* HTML5 with Web Assembly (Wasm) (for an example, see [yampa-wasm-example](https://github.com/AntanasKal/yampa-wasm-example))
* Gloss (see [yampa-gloss](https://github.com/ivanperez-keera/yampa-gloss))
* Diagrams (see [diagrams example](https://github.com/ivanperez-keera/Yampa/blob/develop/yampa/examples/Diagrams.hs))
* [Keera Hails](https://github.com/keera-studios/keera-hails/tree/master/keera-hails-reactive-yampa) (reactive programming framework with GTK, WX, Qt, Android, iOS and HTML support).
Expand Down
4 changes: 2 additions & 2 deletions yampa/Yampa.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ cabal-version: >= 1.10
build-type: Simple

name: Yampa
version: 0.14.5
version: 0.14.6
author: Henrik Nilsson, Antony Courtney
maintainer: Ivan Perez ([email protected])
homepage: https://github.com/ivanperez-keera/Yampa/
Expand Down Expand Up @@ -100,7 +100,7 @@ library
build-depends:
base < 6

, deepseq >= 1.3.0.1 && < 1.5
, deepseq >= 1.3.0.1 && < 1.6
, random >= 1.1 && < 1.3
, simple-affine-space >= 0.1 && < 0.3

Expand Down
29 changes: 22 additions & 7 deletions yampa/examples/Diagrams.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,43 +13,54 @@
--
-- Install diagrams with Cairo support, together with Yampa:
--
-- cabal sandbox init
-- cabal install Yampa diagrams -fcairo
-- cabal v1-sandbox init
-- cabal v1-install Yampa diagrams diagrams-cairo
--
-- Compile in a sandbox with:
--
-- cabal exec -- ghc --make examples/Diagrams.hs
-- cabal v1-exec -- ghc --make examples/Diagrams.hs
--
-- And run with:
--
-- ./examples/Diagrams -w 400 -h 400 -o output.gif

import Diagrams.Backend.Cairo.CmdLine
import Diagrams.Prelude
import Diagrams.Prelude hiding (Time)
import FRP.Yampa hiding (norm, ( # ), (*^))

main :: IO ()
main = mainWith $ take 60 frames

-- | Frames of the animation.
frames :: [(Diagram B, Int)]
frames = zip ((embed sfVF $ deltaEncode 1 $ repeat ())) (repeat 1)

-- | Signal producing the diagram at a point in time.
sfVF :: SF () (Diagram B)
sfVF = proc () -> do
t <- time -< ()
let diag = ( field t # translateY 0.05 # lc white
<> ( square 3.5 # lw none # alignBL))
returnA -< diag

-- | Field of arrows as it changes over time.
field :: Time -> Diagram B
field t = position $ zip points (arrows t)

locs = [(x, y) | x <- [0.1, 0.3 .. 3.25], y <- [0.1, 0.3 .. 3.25]]

-- | Arrow points as they change over time.
points :: [Point V2 Double]
points = map p2 locs

vectorField t (x, y) = r2 (sin (t + y + 1), sin (t + x + 1))
-- | Arrow locations as they change over time.
locs :: [(Double, Double)]
locs = [(x, y) | x <- [0.1, 0.3 .. 3.25], y <- [0.1, 0.3 .. 3.25]]

-- | Arrows as they change over time.
arrows :: Time -> [Diagram B]
arrows t = map (arrowAtPoint t) locs

-- | Diagram of a star at a given point in time and space.
arrowAtPoint :: Time -> (Double, Double) -> Diagram B
arrowAtPoint t (x, y) = arrowAt' opts (p2 (x, y)) (sL *^ vf) # alignTL
where
vf = vectorField t (x, y)
Expand All @@ -64,3 +75,7 @@ arrowAtPoint t (x, y) = arrowAt' opts (p2 (x, y)) (sL *^ vf) # alignTL
opts = (with & arrowHead .~ spike
& headLength .~ normalized hs
& shaftStyle %~ lwN sW)

-- | Direction vector depending on the time and the position in space.
vectorField :: Time -> (Double, Double) -> V2 Double
vectorField t (x, y) = r2 (sin (t + y + 1), sin (t + x + 1))

0 comments on commit ea668ec

Please sign in to comment.