2

Here is the code from user manual:

> stops = mkStops [(gray, 0, 1), (white, 0.5, 1), (purple, 1, 1)]
> gradient = mkLinearGradient stops ((-0.5) ^& 0) (0.5 ^& 0) GradPad
> sq1 = square 1 # fillTexture  gradient
> sq2 = square 1 # fillTexture (gradient & _LG . lGradSpreadMethod .~ GradRepeat
>                                        & _LG . lGradStart .~ (-0.1) ^& 0
>                                        & _LG . lGradEnd .~ 0.1 ^& 0)
> sq3 = square 1 # fillTexture (gradient & _LG . lGradSpreadMethod .~ GradReflect
>                                        & _LG . lGradStart .~ (-0.1) ^& 0
>                                        & _LG . lGradEnd .~ 0.1 ^& 0)
>
> example = hcat' (with & sep .~ 0.25) [sq1, sq2, sq3]

Here is what I got:

enter image description here

Here is what it looks like in the manual:

enter image description here

They don't quite match.

ghc 7.8.3, OS X 10.10
diagrams 1.2
output: SVG
qed
  • 22,298
  • 21
  • 125
  • 196
  • 1
    Works for me. What output format are you going to? What haskell compiler, what version, what version of diagrams, what OS? – ja. Mar 25 '15 at 00:21

1 Answers1

1

It looks like mac's svg renderer doesn't support spread methods. Here's screen shot from and Chrome (OS X 10.9.5, Chrome version 37) with the same svg:

gradients

Tools like imagemagick don't render them at all but this is a bug in the SVG backend that should be fixed in the next version.

I've actually been working on manually implementing spread methods for another backend so we'll probably add an option in the svg backend for this too, for better compatibility.

The Rasterific and Cairo backend gradients should (mostly) work. (Cairo's svg output still doesn't work with Safari but it does with imagemagick)

cchalmers
  • 2,896
  • 1
  • 11
  • 11