diagrams / diagrams-rasterific

Rasterific backend for diagrams
Other
15 stars 12 forks source link

Artifact when using trails + stroke #61

Closed DiegoNolan closed 4 years ago

DiegoNolan commented 4 years ago

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)]
Twinside commented 4 years ago

Could you add the output files? thanks

DiegoNolan commented 4 years ago

wyoming

wyoming.zip

Had to zip the SVG.

byorgey commented 4 years ago

I'm guessing this is probably a bug in Rasterific rather than in diagrams-rasterific specifically. @Twinside , any ideas?

Twinside commented 4 years ago

I agree that it's probably on Rasterific side, but I don't really have time to address the issue right now

Twinside commented 4 years ago

This should be fixed with Rasterific v0.7.5.1 . It was a corner case of degenerate coordinate protection introduced during a previous commit. The sanitization for stroking and filling is now separate.

byorgey commented 4 years ago

Great, thanks @Twinside ! @DiegoNolan , I'm going to close this issue, but feel free to reopen if it's not fixed for you.