Git Product home page Git Product logo

diagrams-input'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-input's People

Contributors

byorgey avatar hansroland avatar igormoreno avatar jbransen avatar kasbah avatar tkvogt avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

diagrams-input's Issues

Scale if rx,ry,xAxisRot are such that there is no solution

I thought I'd open an issue for this as it's marked as TODO in the code anyway and I have started working on this seperately.

If you do a cabal run in my project though you can see that the second property won't pass quickcheck. Sometimes this is due to floating point errors (which seem to exceed ieee754) but sometimes there are NaNs in the result which indicates there is no solution although I think I scale rx,ry as described.

Just wondering if you had any ideas and also if you would be interested to use my implementation if I get it to work.

Width / height of SVG not taken into account

When reading in an SVG with loadImageEmbedded the width and height of the SVG seem to be ignored. When reading an SVG and then asking the diagrams library for the width and height, the reported numbers seem to be the bounding box of the objects in the SVG, not the size of the full image. Is this a bug or is this on purpose?

On a related note, after upgrading to GHC 8 my diagrams look a bit different, and I think that it is related to the width/height of the svg components being reported differently, but I am not 100% sure.

Incorrect path parsing

I have the following path:

<!-- https://fontawesome.com/icons/flag?style=solid CC-BY -->
<path fill="Indigo" d="M349.565 98.783C295.978 98.783 251.721 64 184.348 64c-24.955 0-47.309 4.384-68.045 12.013a55.947 55.947 0 0 0 3.586-23.562C118.117 24.015 94.806 1.206 66.338.048 34.345-1.254 8 24.296 8 56c0 19.026 9.497 35.825 24 45.945V488c0 13.255 10.745 24 24 24h16c13.255 0 24-10.745 24-24v-94.4c28.311-12.064 63.582-22.122 114.435-22.122 53.588 0 97.844 34.783 165.217 34.783 48.169 0 86.667-16.294 122.505-40.858C506.84 359.452 512 349.571 512 339.045v-243.1c0-23.393-24.269-38.87-45.485-29.016-34.338 15.948-76.454 31.854-116.95 31.854z"></path>

Firefox renders it like this:
image

But with this library I get this:
image

It looks like it stops at "C118.117 24.015 94.806 1.206 66.338.048". According to the spec, this is actually valid and should be parsed as 66.338 0.048! 😮

Similarly, for the string "M 0.6.5", the first coordinate of the "moveto" consumes the characters "0.6" and stops upon encountering the second decimal point because the production of a "coordinate" only allows one decimal point. The result is that the first coordinate will be "0.6" and the second coordinate will be ".5".

text support

This is something that a lot of SVG renderers have not implemented. But it is used in some SVGs. Luckily I can learn a lot from svg-tree, because it's implemented there.

Full CSS support

Some SVG images use CSS to set colors. Apart from this haven't seen more advanced uses of CSS. A minimal CSS support was added. But a complete implementation of CSS would of course be nice. Maybe this becomes a topic when we render HTML pages.

Curve interpolation not as good as SVGPath's

Using the below function on this test.svg.

pathToPoints :: String -> [[(Double,Double)]]
pathToPoints = map (map unp2) . concat . (map pathVertices) . commandsToTrails . commands . Just . pack

I get something that looks like this.

Imgur

With the old SVGPath I get something that looks like this.

Imgur

Maybe I shouldn't be using pathVertices?

<use>-tag working

The -tag references tags (mostly from inside the -tag) to reuse objects. Viewbox and preserveAspectRatio from the referenced object have to be considered

The example in `Diagrams.SVG.ReadSVG` doesn't type-check.

The main part of the example is:

main = do
   diagramFromSVG  <- readSVGFile "svgs/web.svg"
   mainWith $ diagramFromSVG

The error is:

Main.hs:12:22: error:
    • Couldn't match type ‘N b0’ with ‘Place’
        arising from a use of ‘readSVGFile’
      The type variable ‘b0’ is ambiguous
    • In a stmt of a 'do' block:
        diagramFromSVG <- readSVGFile "svgs/web.svg"
      In the expression:
        do diagramFromSVG <- readSVGFile "svgs/web.svg"
           mainWith $ diagramFromSVG
      In an equation for ‘main’:
          main
            = do diagramFromSVG <- readSVGFile "svgs/web.svg"
                 mainWith $ diagramFromSVG

The function readSVGFilereturns an Either String (Diagram B) but
the function mainWith expects a plain Diagram B.

A working example is:

{-# LANGUAGE OverloadedStrings, ScopedTypeVariables #-}

module Main where
import Diagrams.SVG.ReadSVG
import Diagrams.Prelude
import Diagrams.Backend.SVG.CmdLine
import System.Environment
import Filesystem.Path.CurrentOS
import Diagrams.SVG.Attributes (PreserveAR(..), AlignSVG(..), Place(..), MeetOrSlice(..))

main = do
   diagramFromSVG :: Either String (Diagram B) <- readSVGFile "svgs/web.svg"
   case diagramFromSVG of
    Left msg      -> error ("readSVGFile returned " <> msg)
    Right diagram -> mainWith $ diagram

It needs a type hint for diagramFromSVG.

Examples from the documentation of a library should work without any changes.

Verions used:

  • GHC: The Glorious Glasgow Haskell Compilation System, version 9.2.2
  • diagrams-input: 0.1

Use svg-tree?

@Twinside has a new svg-tree package for loading/serialising SVG files. It might be nice to use it here so this package would only need to do the Document -> Diagram conversion.

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.