Git Product home page Git Product logo

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

Contributors

acowley avatar bergey avatar byorgey avatar cchalmers avatar fryguybob avatar hsyl20 avatar jeffreyrosenbluth avatar lrworth avatar prikhi avatar robx avatar ryanglscott avatar twinside avatar

Stargazers

 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

diagrams-rasterific's Issues

two shades of black

I'm trying to switch out the diagrams backend of https://github.com/robx/puzzle-draw from cairo to rasterific. Works fine, but this introduces some artifacts in the output that seem like a bug.

In the example below, the thin grid lines are 1 pixel wide solid black lines. At the grid vertices, there is one pixel of color #0d0d0d, which used to be solid black with cairo. The grid lines are constructed from individual segments between vertices, with default linecap, that end nicely on pixel centers. I can fix this shade of black by change the linecap to square, but that breaks the dashing (for some other puzzle types), so I'd prefer to avoid that. I'd be happy to break this down to a more reduced example if necessary.

This is with diagrams-rasterific 1.4 and rasterific 0.7.2.1.

lits-example

Bumping dependencies to Rasterific 0.4

Hi,

I've updated the Rasterific & FontyFruity recently, and I was wondering about bumping the dependencies of diagrams-rasterific. As I didn't manage to get it to build, I didn't put a pull request together but I'd gladly offer some help.

Crash due to out of memory

Please to refer to diagrams/diagrams-lib#282 for more details. The following program when used with the rasterific backend makes the program go out of memory and finally getting killed (Linux) or crashing the system (Mac OS X).

{-# LANGUAGE NoMonomorphismRestriction #-}

import Diagrams.Prelude
import Diagrams.Backend.SVG.CmdLine

main = mainWith (arr :: Diagram B)

arr :: Diagram B
arr = arrowAt' (with & arrowShaft .~ (square 1)) (p2 (0, 0)) (r2 (1, 1))

Add a built in serif font

The work on charts made me realize that we should have a serif font that has full support for
greek letters and other unicode characters that are useful for charts and diagrams in gerneral.
This should be in addition to the already included sans serif font. We should use the Font attribute
so that the user can switch between serif and sans serif.

Enveloped text

We should be able to create a Text module that exports a RasterificText primitive along with
a convenience function rasterificText to create enveloped test using the FontyFruity function,
stringBoundingBox. We will also need a renderable instance.

Add Ability to Customize PDF DPI

This line fixes the DPI of PDF files to 96.

It'd be nice to have the ability to customize this, maybe through a renderPDFWithDPI function?

If there is interest in supporting this, I will submit a PR.

Text is positioned on bottom edge of bounding box, not on baseline

When Text alignment is BaselineText, the local origin, from Diagrams' point of view, is on the baseline. In the Renderable instance for Text, refY should be the vertical distance from the top of the string to the baseline, not the height of the bounding box. (At least, I think Rasterific & FontyFruity place the origin & axes that way.)

This was reported in timbod7/haskell-chart#65 which has some supporting images.

The Cairo Backend is pretty similar to Rasterific in this area. Pango provides a function to locate the baseline; I'm not sure if FontyFruity does yet. SVG is quite different.

disappearing dashes at low resolution

After switching from diagrams-cairo, I've noticed some gaps in dashed circles, compare robx/puzzle-draw#32

The first two below are fine, then some dashes start disappearing in a way that seems wrong:

test-dashing-100
test-dashing-80
test-dashing-50
test-dashing-40

These were rendered by the following code:

dia :: Diagram B
dia = bgFrame 0.15 white $
    circle 0.35 # lwG (1/40) # dashingG [1/20, 1/20] 0


sizeSpec :: Double -> SizeSpec V2 Double
sizeSpec w = mkSizeSpec2D (Just w) Nothing

main :: IO ()
main = do
  renderRasterific "test-dashing-100.png" (sizeSpec 100) dia
  renderRasterific "test-dashing-80.png" (sizeSpec 80) dia
  renderRasterific "test-dashing-50.png" (sizeSpec 50) dia
  renderRasterific "test-dashing-40.png" (sizeSpec 40) dia

PDF output seems to stroke things it shouldn't

Not quite sure what this is, or whether this should be filed against rasterific proper. Anyhow:

I see frames in PDF output that shouldn't be there.

rasterific png:
doppelblock-example

old cairo pdf, top left corner:
screen shot 2018-03-07 at 20 44 14

rasterific pdf, top left corner:
screen shot 2018-03-07 at 20 44 03

The rasterific version has a frame around the whole diagram, as well as around the gray area. (That is placed using frame.) But also the text seems a lot heavier (using SVGFonts, stroked with lwG 0), as if the path was stroked after all.

(As an extra issue, the PDF comes out square, but maybe that's me passing the wrong options? Happy to file a separate issue for that if you want.)

Returned transformation from adjustDia doesn't map (0,0) to any of the diagrams bounding corners

See this IRC transcript:

ocharles: Can anyone make any sense of this? https://gist.github.com/ocharles/2c36ebc4eadae5602479ead97cb9917e I'm translating pixel coordinates back into diagram space, but ending up with a flipped y

ocharles: in that paste, see the "traceShowM" lines where I show the bounding box of my diagram, and then apparently map the (0,0) pixel of the rendered diagram to something completely outside that bounding box

ocharles: I see this in the rasterific backend: "adjustDia c opts d = adjustDia2D sizeSpec c opts (d # reflectY)" I wonder if that has something to do with it

ocharles: As a work around, I'm currently flipping the y axis on the result of calls to papply atm and then things do line up correctly

byorgey: ocharles: yeah, it probably has to do with the reflectY in the backend, which is done since many backends have the positive y-axis pointing downwards, but diagrams has it pointing upwards

Artifact when using trails + stroke

The combination of trails and strokeTrail produces artifacts in the rasterific backend but not the SVG backend. There are lines going across the fill for the PNG but the SVG is completely solid. I've attached a minimal example below.


{-# LANGUAGE FlexibleContexts          #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE TypeFamilies              #-}
module Artifact where

import           Data.Aeson
import           Data.Vector                 (Vector)
import qualified Data.Vector                 as V
import           Diagrams.Backend.Rasterific
import           Diagrams.Backend.SVG
import           Diagrams.Prelude


test :: IO ()
test = do
  renderSVG "wyoming.svg" (dims (V2 1000 1000)) mkDia
  renderRasterific "wyoming.png" (dims (V2 1000 1000)) mkDia


mkDia = (map p2 pts)
        # fromVertices
        # closeTrail
        # strokeTrail
        # fc blue
        # bgFrame 1 white


pts :: [(Double, Double)]
pts = [(-109.050076,41.000659),(-109.173682,41.000859),(-109.231985,41.002059),(-109.250735,41.001009),(-109.500694,40.999127),(-109.534926,40.998143),(-109.676421,40.998395),(-109.713877,40.998266),(-109.715409,40.998191),(-109.854302,40.997661),(-109.855299,40.997614),(-109.97553,40.997912),(-109.999838,40.99733),(-110.000708,40.997352),(-110.006495,40.997815),(-110.121639,40.997101),(-110.125709,40.99655),(-110.237848,40.995427),(-110.250709,40.996089),(-110.375714,40.994947),(-110.500718,40.994746),(-110.539819,40.996346),(-110.715026,40.996347),(-110.750727,40.996847),(-111.046723,40.997959),(-111.046551,41.251716),(-111.0466,41.360692),(-111.046264,41.377731),(-111.045789,41.565571),(-111.046689,42.001567),(-111.047109,42.142497),(-111.047107,42.148971),(-111.047058,42.182672),(-111.047097,42.194773),(-111.047074,42.280787),(-111.04708,42.34942),(-111.046801,42.504946),(-111.046017,42.582723),(-111.043564,42.722624),(-111.044135,42.874924),(-111.043959,42.96445),(-111.043957,42.969482),(-111.043924,42.975063),(-111.044129,43.018702),(-111.044206,43.022614),(-111.044034,43.024581),(-111.044034,43.024844),(-111.044033,43.026411),(-111.044094,43.02927),(-111.043997,43.041415),(-111.044058,43.04464),(-111.044063,43.046302),(-111.044086,43.054819),(-111.044117,43.060309),(-111.04415,43.066172),(-111.044162,43.068222),(-111.044143,43.072364),(-111.044235,43.177121),(-111.044266,43.177236),(-111.044232,43.18444),(-111.044168,43.189244),(-111.044229,43.195579),(-111.044617,43.31572),(-111.045706,43.659112),(-111.04588,43.681033),(-111.046118,43.684902),(-111.046051,43.685812),(-111.04611,43.687848),(-111.046421,43.722059),(-111.046435,43.726545),(-111.04634,43.726957),(-111.046715,43.815832),(-111.046515,43.908376),(-111.046917,43.974978),(-111.047349,43.999921),(-111.049077,44.020072),(-111.048751,44.060403),(-111.048751,44.060838),(-111.048633,44.062903),(-111.048452,44.114831),(-111.049119,44.124923),(-111.049695,44.353626),(-111.049148,44.374925),(-111.049216,44.435811),(-111.049194,44.438058),(-111.048974,44.474072),(-111.055208,44.624927),(-111.055511,44.725343),(-111.056416,44.749928),(-111.056888,44.866658),(-111.055629,44.933578),(-111.056207,44.935901),(-111.055199,45.001321),(-111.044275,45.001345),(-110.785008,45.002952),(-110.761554,44.999934),(-110.750767,44.997948),(-110.705272,44.992324),(-110.552433,44.992237),(-110.547165,44.992459),(-110.48807,44.992361),(-110.402927,44.99381),(-110.362698,45.000593),(-110.342131,44.999053),(-110.324441,44.999156),(-110.28677,44.99685),(-110.199503,44.996188),(-110.110103,45.003905),(-110.026347,45.003665),(-110.025544,45.003602),(-109.99505,45.003174),(-109.875735,45.003275),(-109.798687,45.002188),(-109.75073,45.001605),(-109.663673,45.002536),(-109.574321,45.002631),(-109.386432,45.004887),(-109.375713,45.00461),(-109.269294,45.005283),(-109.263431,45.005345),(-109.103445,45.005904),(-109.08301,44.99961),(-109.062262,44.999623),(-108.578484,45.000484),(-108.565921,45.000578),(-108.500679,44.999691),(-108.271201,45.000251),(-108.249345,44.999458),(-108.238139,45.000206),(-108.218479,45.000541),(-108.14939,45.001062),(-108.000663,45.001223),(-107.997353,45.001565),(-107.750654,45.000778),(-107.608854,45.00086),(-107.607824,45.000929),(-107.49205,45.00148),(-107.351441,45.001407),(-107.13418,45.000109),(-107.125633,44.999388),(-107.105685,44.998734),(-107.084939,44.996599),(-107.074996,44.997004),(-107.050801,44.996424),(-106.892875,44.995947),(-106.888773,44.995885),(-106.263586,44.993788),(-105.928184,44.993647),(-105.914258,44.999986),(-105.913382,45.000941),(-105.848065,45.000396),(-105.038405,45.000345),(-105.025266,45.00029),(-105.019284,45.000329),(-105.01824,45.000437),(-104.765063,44.999183),(-104.759855,44.999066),(-104.72637,44.999518),(-104.665171,44.998618),(-104.663882,44.998869),(-104.470422,44.998453),(-104.470117,44.998453),(-104.250145,44.99822),(-104.057698,44.997431),(-104.055914,44.874986),(-104.056496,44.867034),(-104.055963,44.768236),(-104.055963,44.767962),(-104.055934,44.72372),(-104.05587,44.723422),(-104.055777,44.700466),(-104.055938,44.693881),(-104.05581,44.691343),(-104.055892,44.543341),(-104.055927,44.51773),(-104.055389,44.249983),(-104.054487,44.180381),(-104.05495,43.93809),(-104.055077,43.936535),(-104.055488,43.853477),(-104.055138,43.750421),(-104.055133,43.747105),(-104.054902,43.583852),(-104.054885,43.583512),(-104.05484,43.579368),(-104.055032,43.558603),(-104.054786,43.503072),(-104.054766,43.428914),(-104.054614,43.390949),(-104.054403,43.325914),(-104.054218,43.30437),(-104.053884,43.297047),(-104.053876,43.289801),(-104.053127,43.000585),(-104.052863,42.754569),(-104.052809,42.749966),(-104.052583,42.650062),(-104.052741,42.633982),(-104.052586,42.630917),(-104.052775,42.61159),(-104.052775,42.610813),(-104.053107,42.499964),(-104.052776,42.25822),(-104.052793,42.249962),(-104.053125,42.249962),(-104.052761,42.170278),(-104.052547,42.166801),(-104.053001,42.137254),(-104.052738,42.133769),(-104.0526,42.124963),(-104.052954,42.089077),(-104.052967,42.075004),(-104.05288,42.021761),(-104.052729,42.016318),(-104.052699,41.998673),(-104.052761,41.994967),(-104.05283,41.9946),(-104.052856,41.975958),(-104.052734,41.973007),(-104.052991,41.914973),(-104.052931,41.906143),(-104.053026,41.885464),(-104.052774,41.733401),(-104.052913,41.64519),(-104.052945,41.638167),(-104.052975,41.622931),(-104.052735,41.613676),(-104.052859,41.592254),(-104.05254,41.564274),(-104.052531,41.552723),(-104.052584,41.55265),(-104.052692,41.541154),(-104.052686,41.539111),(-104.052476,41.522343),(-104.052478,41.515754),(-104.05234,41.417865),(-104.05216,41.407662),(-104.052287,41.393307),(-104.052687,41.330569),(-104.052324,41.321144),(-104.052476,41.320961),(-104.052568,41.316202),(-104.052453,41.278202),(-104.052574,41.278019),(-104.052666,41.275251),(-104.053514,41.157257),(-104.053142,41.114457),(-104.053083,41.104985),(-104.053025,41.090274),(-104.053177,41.089725),(-104.053097,41.018045),(-104.053158,41.016809),(-104.053249,41.001406),(-104.066961,41.001504),(-104.086068,41.001563),(-104.10459,41.001543),(-104.123586,41.001626),(-104.211473,41.001591),(-104.214191,41.001568),(-104.214692,41.001657),(-104.467672,41.001473),(-104.497058,41.001805),(-104.497149,41.001828),(-104.675999,41.000957),(-104.829504,40.99927),(-104.855273,40.998048),(-105.254779,40.99821),(-105.256527,40.998191),(-105.277138,40.998173),(-105.724804,40.99691),(-105.730421,40.996886),(-106.061181,40.996999),(-106.217573,40.997734),(-106.321165,40.999123),(-106.386356,41.001144),(-106.391852,41.001176),(-106.43095,41.001752),(-106.437419,41.001795),(-106.439563,41.001978),(-106.453859,41.002057),(-106.857773,41.002663),(-107.000606,41.003444),(-107.241194,41.002804),(-107.367443,41.003073),(-107.625624,41.002124),(-107.918421,41.002036),(-108.046539,41.002064),(-108.181227,41.000455),(-108.250649,41.000114),(-108.500659,41.000112),(-108.526667,40.999608),(-108.631108,41.000156),(-108.884138,41.000094),(-109.050076,41.000659)]

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.