Questions tagged [haskell-diagrams]

Diagrams is a powerful, flexible, declarative domain-specific language for creating vector graphics, using the Haskell programming language.

Diagrams is a powerful, flexible, declarative domain-specific language for creating vector graphics, using the Haskell programming language.

diagrams.github.io

57 questions
3
votes
0 answers

Haskell Diagrams program draws circle but does not fill circle with colour

I have written the following program: {-# LANGUAGE NoMonomorphismRestriction #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE GADTs #-} import Diagrams.Prelude import Diagrams.Backend.SVG.CmdLine main = mainWith (my_diagram :: Diagram…
user1023733
  • 805
  • 5
  • 14
3
votes
2 answers

Margin of a Haskell diagrams SVG file

I am trying this diagrams example: funs = map (flip (^)) [2..6] visualize f = stroke' (with & vertexNames .~ [[0 .. 6 :: Int]] ) (regPoly 7 1) # lw none # showLabels …
qed
  • 22,298
  • 21
  • 125
  • 196
2
votes
1 answer

How can I compile and run this Haskell 'diagrams' program?

The program below, diagram1.hs, is from the PDF "What I Wish I Knew When Learning Haskell" by Stephen Diehl; see the chapter titled "Graphics". I am using MacOS Ventura 13.4.1 (c) (22F770820d) My shell is zsh The project1 folder was completely…
R. Adams
  • 31
  • 3
2
votes
1 answer

Haskell GHCJS with Diagrams gives error: no C compiler provided for this platform

I am trying to build a POC, using Reflex and Diagrams. I am using WSL2 with Ubuntu-20.04. I've used the Reflex-stone template, which builds fine. I then add diagrams-lib to the dependency list, and get this…
Chris Wohlert
  • 610
  • 3
  • 12
2
votes
0 answers

How to add command line parameters to a diagrams animation?

With "image" diagrams I can just pass a function that expects parameters (here pDiag) to mainWith and append neccessary parameters to the command like so: stack exec circle-diagram-exe -- -o circle.png -w 800 9 module DiagramsWithParameters…
peer
  • 4,171
  • 8
  • 42
  • 73
2
votes
1 answer

Haskell - Expose hidden package permanently

I am a beginner when it comes to Haskell and I have been following the quickstart tutorial for diagrams. I installed Haskell with ghcup and diagrams with cabal install diagrams --lib (the tutorial mentions cabal sandbox init, but apparently this is…
kunberg
  • 57
  • 5
2
votes
2 answers

How to combine shapes via set operations?

I would like to subtract one shape from another, and then combine the resulting shape with another shape. In my example a square is to be clipped in half and that clipped version is to be extended by a half circle to the right. So I subtract one…
peer
  • 4,171
  • 8
  • 42
  • 73
2
votes
2 answers

ray tracing and finding the normal vector to the surface at the intersection point

When doing a ray trace with rayTraceP, I can find the point where a ray intersects with a diagram. > rayTraceP (p2 (0, 0)) (r2 (1, 0)) ((p2 (1,-1) ~~ p2 (1,1)) Just (p2 (1.0, 0.0)) I want to use this to find not only the "collision point", but also…
Alex Knauth
  • 8,133
  • 2
  • 16
  • 31
2
votes
1 answer

Load external image in Haskell Diagrams

So I have this doubt. I already have code that works with local (embedded) image files, but now I need to load an external image instead. Dumb replacing with loadImageExt didn't help: productImageIO :: IO (Diagram B) productImageIO = do res <-…
Roman
  • 2,079
  • 4
  • 35
  • 53
2
votes
1 answer

Haskell Diagrams Graphviz Gtk Display alignment and scaling

I want to display a graph layed out by graphviz (via Data.GraphViz) in a Gtk window. The code I have does not automatically center the graph or size the diagram. I have setup a github repo with an example (see src/Main.hs at…
sarva
  • 77
  • 8
2
votes
1 answer

How to place latex-like mathematical formulas (e.g. via mathjax) in Haskell Diagrams?

I am attempting to place latex-style math formulas into a haskell diagram. The documentation pages http://projects.haskell.org/diagrams/doc/manual.html#essential-concepts and http://projects.haskell.org/diagrams/doc/tutorials.html suggest that one…
mherzl
  • 5,624
  • 6
  • 34
  • 75
2
votes
1 answer

Haskell Diagrams: Why does text not have length or width?

I would like to create a text box that I can set to have a particular width and height. However, the text box that I create appears to not have a width and height in the first place. E.g. the following code: main = do putStrLn $ show $ width $…
mherzl
  • 5,624
  • 6
  • 34
  • 75
2
votes
2 answers

How to combine `annularWedge` and `wedge` from Haskell's diagrams package?

It turns out that the annularWedge function of the diagrams package cannot take a radius of 0 for the inner radius. You must use wedge instead. To me, an inner radius of 0 is just the degenerate case of annularWedge and should behave like wedge, so…
rityzmon
  • 1,945
  • 16
  • 26
2
votes
1 answer

a bezier function that takes 4 args in haskell

I am trying to make a bezier function that takes 4 args: > import Diagrams.Backend.SVG.CmdLine > import Diagrams.Prelude > import Control.Applicative > bezier4 x1 c1 c2 x2 = bezier3 (c1 ^-^ x1) (c2 ^-^ x1) (x2 ^-^ x1) # translate x1 > lineBtwPoints…
qed
  • 22,298
  • 21
  • 125
  • 196
2
votes
1 answer

Why doesn't this diagrams code produce expected result?

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…
qed
  • 22,298
  • 21
  • 125
  • 196