Git Product home page Git Product logo

diagrams-reflex's Introduction

Build Status

diagrams is a full-featured framework and domain-specific language (embedded in Haskell) for creating declarative vector graphics and animations.

This package is just a convenient wrapper around the diagrams-core, diagrams-lib, diagrams-svg, and diagrams-contrib packages, so they can be installed with a single cabal install --lib diagrams command.

The package also comes with flags to enable six different backends. The native SVG backend is enabled by the -fsvg flag and is enabled by default. If you don't want it, you must explicitly disable it with -f-svg.

The native postscript backend is disabled by default but can be enabled by the -fps flag.

The cairo backend is disabled by default but can be selected with the -fcairo flag. In addition, the GTK backend is based on the cairo backend (but split into a separate package to make installing the cairo backend easier). It can be selected with the fgtk flag.

The native rasterific backend which is disabled by default but can be selected with the -frasterific flag.

The native canvas backend which is disabled by default but can be selected with the -fcanvas flag.

Installation

cabal update && cabal install --lib diagrams

or, to get the postscript backend in addition to the SVG backend:

cabal update && cabal install --lib -fps diagrams

or, to get the cairo backend in addition to the SVG backend:

cabal update && cabal install gtk2hs-buildtools && cabal install --lib -fcairo diagrams

Reporting bugs

Issue trackers for all diagrams-related repositories are hosted under the diagrams organization on github. If you know the specific package containing the bug, report it in the issue tracker specific to that package (for example, diagrams-lib). Otherwise, just report the issue in the issue tracker for the general diagrams repository.

Further reading

For more information, including a gallery of examples, tutorial, and user manual, see the diagrams website. For help, join the #diagrams IRC channel on Freenode or the mailing list.

diagrams-reflex's People

Contributors

bergey avatar byorgey avatar c-nixon avatar hamishmack avatar mightybyte avatar mulderr avatar o1lo01ol1o avatar qrilka avatar zarybnicky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

diagrams-reflex's Issues

Font size and scale does nothing for texts

fontSize and scale doesn't affect font size. Example is modified Follow.hs example:

{-# LANGUAGE RecursiveDo #-}
{-# LANGUAGE FlexibleContexts #-}

module Main where

import Diagrams.Prelude as D
import Diagrams.Backend.Reflex as DR
import Reflex as R
import Reflex.Dom as R

main :: IO ()
main = mainWidget app

app :: MonadWidget t m => m ()
app = mdo
  -- svgDyn :: Dynamic t (m (DiaEv Any))
  svgDyn <- mapDyn (reflexDia $ def & sizeSpec .~ dims2D 500 1000) diaDyn
  -- pos :: Event (V2 Double)
  pos <- switchPromptly never <$> fmap diaMousemovePos =<< dyn svgDyn
  -- diaDyn :: Dynamic (Diagram B)
  diaDyn <- holdDyn (mkDia . p2 $ (0, -1000)) (mkDia <$> pos)
  return ()

-- TODO generalize and move into diagrams-lib
constrain :: (InSpace v n a, Enveloped a, HasBasis v, Num n, Ord (v n)) =>
             a -> Point v n -> Point v n
constrain a p = maybe p c $ getCorners box where
  c (l,h) = max l (min h p)
  box = boundingBox a

mkDia :: P2 Double -> Diagram B
mkDia p = arr <> c <> back where
  arr = arrowBetween'
    (def & arrowHead .~ dart & arrowTail .~ quill )
    origin p'
  c = moveTo p' $ fontSize 20 $ D.text "Hello" # fc green
  p' = constrain back p
back = vcat [ square 1000 # fc cyan, square 1000 # fc yellow ]

Update to reflex-0.5

Is anyone working on updating this to reflex-0.5 and reflex-dom-0.4? I'm interested in using the library, but am using the newer libraries

build errors both nix and stack approaches

Tried to build both with stack and Nix under Ubuntu 17.10. Unfortunately both tools designed to provide consistent builds under different environments fails. Tried to build under OSX with Nix approach hanging my laptot and stack approach showing the same errors. Here is the output for Ubuntu 17.10:

Building with stack I get:

stack build --install-ghc

... stripped out lots of build output...

Warning: No remote package servers have been specified. Usually you would have
one specified in the config file.
Choosing modular solver.
Resolving dependencies...
In order, the following would be installed:
Cabal-1.22.4.0 (new package)
/home/ali/.ghcjs/x86_64-linux-0.2.0-7.10.2/ghcjs/ghcjs-boot$ [cabal]: /home/ali/.stack/snapshots/x86_64-linux-nopie/lts-3.6/7.10.2/bin/cabal "--config-
file" "/home/ali/.ghcjs/x86_64-linux-0.2.0-7.10.2/ghcjs/cabalBootConfig" "--ignore-sandbox" "install" "./boot/cabal/Cabal" "--global" "--ghcjs" "--one-
shot" "--avoid-reinstalls" "--builddir" "dist" "--with-compiler" "/home/ali/.stack/programs/x86_64-linux/ghcjs-0.2.0.20160112_ghc-7.10.2/src/.stack-wor
k/install/x86_64-linux-nopie/lts-3.6/7.10.2/bin/ghcjs" "--with-hc-pkg" "/home/ali/.stack/programs/x86_64-linux/ghcjs-0.2.0.20160112_ghc-7.10.2/src/.sta
ck-work/install/x86_64-linux-nopie/lts-3.6/7.10.2/bin/ghcjs-pkg" "--prefix" "/home/ali/.ghcjs/x86_64-linux-0.2.0-7.10.2/ghcjs" "--enable-documentation"
"--haddock-html" "--haddock-hyperlink-source" "--enable-shared" "--enable-library-profiling" "--root-cmd" "/home/ali/.ghcjs/x86_64-linux-0.2.0-7.10.2/
ghcjs/run.sh"
/home/ali/.stack/snapshots/x86_64-linux-nopie/lts-3.6/7.10.2/bin/cabal --config-file /home/ali/.ghcjs/x86_64-linux-0.2.0-7.10.2/ghcjs/cabalBootConfig -
-ignore-sandbox install ./boot/cabal/Cabal --global --ghcjs --one-shot --avoid-reinstalls --builddir dist --with-compiler /home/ali/.stack/programs/x86
_64-linux/ghcjs-0.2.0.20160112_ghc-7.10.2/src/.stack-work/install/x86_64-linux-nopie/lts-3.6/7.10.2/bin/ghcjs --with-hc-pkg /home/ali/.stack/programs/x
86_64-linux/ghcjs-0.2.0.20160112_ghc-7.10.2/src/.stack-work/install/x86_64-linux-nopie/lts-3.6/7.10.2/bin/ghcjs-pkg --prefix /home/ali/.ghcjs/x86_64-li
nux-0.2.0-7.10.2/ghcjs --enable-documentation --haddock-html --haddock-hyperlink-source --enable-shared --enable-library-profiling --root-cmd /home/ali
/.ghcjs/x86_64-linux-0.2.0-7.10.2/ghcjs/run.sh
Warning: No remote package servers have been specified. Usually you would have
one specified in the config file.
Resolving dependencies...

... stripped out lots of build output...

Configuring Cabal-1.22.4.0...
setup: dist/: does not exist
Failed to install Cabal-1.22.4.0
cabal: Error: some packages failed to install:
Cabal-1.22.4.0 failed during the configure step. The exception was:
ExitFailure 1
ghcjs-boot: error running: /home/ali/.stack/snapshots/x86_64-linux-nopie/lts-3.6/7.10.2/bin/cabal --config-file /home/ali/.ghcjs/x86_64-linux-0.2.0-7.10.2/ghcjs/cabalBootConfig --ignore-sandbox install ./boot/cabal/Cabal --global --ghcjs --one-shot --avoid-reinstalls --builddir dist --with-compiler /home/ali/.stack/programs/x86_64-linux/ghcjs-0.2.0.20160112_ghc-7.10.2/src/.stack-work/install/x86_64-linux-nopie/lts-3.6/7.10.2/bin/ghcjs --with-hc-pkg /home/ali/.stack/programs/x86_64-linux/ghcjs-0.2.0.20160112_ghc-7.10.2/src/.stack-work/install/x86_64-linux-nopie/lts-3.6/7.10.2/bin/ghcjs-pkg --prefix /home/ali/.ghcjs/x86_64-linux-0.2.0-7.10.2/ghcjs --enable-documentation --haddock-html --haddock-hyperlink-source --enable-shared --enable-library-profiling --root-cmd /home/ali/.ghcjs/x86_64-linux-0.2.0-7.10.2/ghcjs/run.sh
exit status: 1
stderr: Warning: No remote package servers have been specified. Usually you would have
one specified in the config file.
setup: dist/: does not exist
cabal: Error: some packages failed to install:
Cabal-1.22.4.0 failed during the configure step. The exception was:
ExitFailure 1

Booting GHCJS (this will take a long time) ...Process exited with ExitFailure 1: /home/ali/.stack/programs/x86_64-linux/ghcjs-0.2.0.20160112_ghc-7.10.2/src/.stack-work/install/x86_64-linux-nopie/lts-3.6/7.10.2/bin/ghcjs-boot --clean

Building with Nix I get:

work-on ./ghcjs.nix ./.

... stripped out lots of build output...
Building doctest-0.11.4...
Preprocessing library doctest-0.11.4...
[ 1 of 16] Compiling Util ( src/Util.hs, dist/build/Util.js_o )
[ 2 of 16] Compiling Sandbox ( src/Sandbox.hs, dist/build/Sandbox.js_o )
[ 3 of 16] Compiling Paths_doctest ( dist/build/autogen/Paths_doctest.hs, dist/build/Paths_doctest.js_o )
[ 4 of 16] Compiling PackageDBs ( src/PackageDBs.hs, dist/build/PackageDBs.js_o )
[ 5 of 16] Compiling Location ( src/Location.hs, dist/build/Location.js_o )

src/Location.hs:5:1: error:
Failed to load interface for ‘SrcLoc’
Use -v to see a list of the files searched for.

src/Location.hs:6:1: error:
Failed to load interface for ‘SrcLoc’
Use -v to see a list of the files searched for.

src/Location.hs:7:1: error:
Failed to load interface for ‘FastString’
Use -v to see a list of the files searched for.
builder for ‘/nix/store/vnaqijjzck0csj4xggqii4r7g6njnqnv-doctest-0.11.4.drv’ failed with exit code 1
cannot build derivation ‘/nix/store/wr02svxxixzjjkhnlhy3yafhsawc7cq1-ghcjs-0.2.0-with-packages.drv’: 1 dependencies couldn't be built
error: build of ‘/nix/store/wr02svxxixzjjkhnlhy3yafhsawc7cq1-ghcjs-0.2.0-with-packages.drv’ failed
/home/ali/.nix-profile/bin/nix-shell: failed to build all dependencies
It looks like a problem occurred. Please submit an issue at https://github.com/reflex-frp/reflex-platform/issues - include ../reflex-platform/work-on.log to provide more information

CI for Nix

Now that #9 is in, CI should be asked to build the examples.

stack setup

Hi,

I cloned the master and id tried build with stack, but i'm stuck in 'stack setup'

This is my output:

...
Extracting  ghcjs-0.2.0\lib\etc\runner.manifest
Extracting  ghcjs-0.2.0\lib\etc\runner.rc
Extracting  ghcjs-0.2.0\lib\etc\template.html

Everything is Ok

Folders: 25
Files: 118
Size:       51301933
Compressed: 51407360
...\AppData\Local\Programs\stack\x86_64-windows\ghcjs-0.2.0.2016011
2_ghc-7.10.2\src-tmp33848\ghcjs-0.2.0.20160112\: renameDirectory: does not exist
 (No such file or directory)

Do you have any idea?
Thx,
Zoltán Kelemen

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.