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
8
votes
1 answer

How to control scale invariance?

I am trying to put several diagrams together in a kind of a table. I think this is called "index print", photography people do that when they have to review many photographs at once. Anyway, this is the code: main :: IO () main = mainWith @(Diagram…
Ignat Insarov
  • 4,660
  • 18
  • 37
8
votes
2 answers

How do I use the diagrams library with GTK drawables?

I'm trying to learn how to draw diagrams using the diagrams library and the Cairo / GTK backend. I've got a blank window to appear, but my drawing won't render. What am I doing wrong? module Main where import Control.Monad.Trans (liftIO) import…
Paul Johnson
  • 17,438
  • 3
  • 42
  • 59
7
votes
1 answer

Fix arrowShaft (Diagrams Library)

I've made a data storage symbol using B.difference and B.union. The one with the red dot in the middle. dataStorage :: Diagram B dataStorage = (strokePath $ B.difference Winding combined block1) # translateX (-0.3) where block1 = (circle 0.5) …
5
votes
1 answer

Setting id and class with the haskell diagrams package

I am working with the diagrams package for haskell, and I am using the SVG backend. I embed the SVG markup directly into an HTML document, so that the graph as a part of a web page. I have built a pretty cool looking bar graph, and I would like to…
5
votes
2 answers

Understanding type variables that only appear in the return type

I'm having some trouble understanding how to understand and use type variables that only appear in the return type of a function. I'm trying to use diagrams-cairo to compare two diagrams, pixel by pixel. The renderToList function has the…
Noel M
  • 15,812
  • 8
  • 39
  • 47
5
votes
1 answer

Haskell Diagrams double lined arrows

I'm working now on my library for Bachelor thesis and I need Your help for making new line type. Bellow there is code for single line, double head arrow: <-> . I would like to ask if there is ability to make from line (line = trailFromOffsets…
Darius
  • 71
  • 2
5
votes
1 answer

Haskell Diagrams: How can I make the text bigger?

I'm using the diagrams haskell drawing framework. The code below is intended to produce an orange hexagon with the text "(0,0)" superimposed on it. Unfortunately, the text is tiny. I've tried to make it bigger by modifying the size of the rect, but…
mhwombat
  • 8,026
  • 28
  • 53
4
votes
1 answer

How to define a Diagrams backend that combines several primitive backends

I would like to make the same program use two different Diagrams backends, notably diagrams-rasterific to generate PNGs, and diagrams-svg to generate SVGs, from the same diagram. Since Diagrams seems to be designed around using a single backend, I'm…
robx
  • 2,221
  • 1
  • 14
  • 31
4
votes
0 answers

How do you make a self-referential arrow with diagrams?

I would like to do something like this: p = p2 (0,0) shaft = arc xDir (-5/6 @@ turn) example = ( arrowBetween' (with & arrowShaft .~ shaft) p p) But, of course, I get an error: "Scale by zero! Halp!" I understand why this doesn't work with the…
Joshua Meyers
  • 619
  • 1
  • 8
  • 17
4
votes
2 answers

Add svg attributes in diagrams

I would like to add tooltips (or hovering behavior) on SVG diagrams generated by diagrams. Is there a way to add custom properties to a diagram , or worst comes to the worst be able to set and id to things, so they can be referred to in Javascript.
mb14
  • 22,276
  • 7
  • 60
  • 102
3
votes
1 answer

Haskell Diagrams: arrows with fixed orientation

I need to draw arrows between two arbitrary "nodes". The arrow ends needs to enter or exit the nodes from one of the four cardinal directions: N, S, E, W. data Dir = N | S | E | W deriving (Eq, Ord, Show) cir, circles :: Diagram B cir =…
cdupont
  • 1,138
  • 10
  • 17
3
votes
1 answer

Is there a container type in Haskell Diagrams?

I am trying to map out some data in Diagrams. I am completely new to Diagrams, but I essentially want to have a rectangle, that grows when I put other diagrams atop of it. I have scoured the docs, but havn't found anything. Does there exist such a…
Chris Wohlert
  • 610
  • 3
  • 12
3
votes
1 answer

How to make line as thick as circle?

I want to make a rounded line with a width equal to the diameter of a circle. After much trial and error this seems to produce the wanted output. import Diagrams.Prelude import Diagrams.Backend.Cairo.CmdLine main = mainWith example path =…
peer
  • 4,171
  • 8
  • 42
  • 73
3
votes
1 answer

Custom font for Text in Haskell Diagrams

I'm using Diagrams library to generate some text with a custom font. Looking at the documentation for Text it is not clear how can one specify particular .ttf font file? I tried using different .ttf files like in the example below, but no one…
Roman
  • 2,079
  • 4
  • 35
  • 53
3
votes
0 answers

Haskell Diagrams crop image

I'd like to be able to draw a bunch of shapes in Diagrams and crop the picture to a fixed size, leaving parts of the shapes in view (i.e. not completely occluding the shape) I can't seem to find a way to do this. I found bounding boxes, but it seems…
Charles Durham
  • 1,707
  • 11
  • 17
1
2 3 4