Skip to content
This repository has been archived by the owner on Sep 28, 2023. It is now read-only.

Support for Haskell graphics libraries? #116

Open
bbarker opened this issue May 12, 2018 · 3 comments
Open

Support for Haskell graphics libraries? #116

bbarker opened this issue May 12, 2018 · 3 comments

Comments

@bbarker
Copy link

bbarker commented May 12, 2018

I'm curious if it is possible to employ other Haskell libraries, particularly graphics libraries (e.g. https://archives.haskell.org/projects.haskell.org/diagrams/ ) in some fashion (maybe this has already been done, if so, apologies).

I could actually see this mode of usage as being maybe a nice way to get away from things like TikZ, but maybe I'm being too hopeful - ultimately it is still probably desirable to support TikZ and PGF

@leftaroundabout
Copy link
Collaborator

There used to be an attempt of writing a TikZ backend for diagrams, but AFAIK it never really worked and is unsupported.

Practically speaking, I find the sensible thing is to render the diagrams to .pdf using the Cairo backend, and then includegraphics those files in the HaTeX document. This works quite smoothly and can be done inline if using HaTeX as LaTeXT IO.

@leftaroundabout
Copy link
Collaborator

(There's also a backend straight to .pdf, but this isn't up to date either.)

@leftaroundabout
Copy link
Collaborator

Concerning this subject, I wonder if it would be worthwhile to add some tooling to HaTeX that would make such including of automatically-generated files easier. I've implemented something like that in the yeamer library, which handles all the filename disambiguation behind the scenes and allows simply writing

import Presentation.Yeamer
import qualified Diagrams.Prelude as Dia
import qualified Diagrams.Backend.Cairo as Dia

myPresentation = do
     ...
     "other content"
     imageFromDiagram (
        Dia.circle 1 & Dia.lc Dia.red
      )
     "more other content"
     ...
...

imageFromDiagram :: Dia.Diagram Dia.Cairo -> Presentation
imageFromDiagram dia = imageFromFileSupplier "png"
           $ \tgtFile -> Dia.renderCairo tgtFile
                           (Dia.mkSizeSpec $ Just 640 Dia.^& Just 480) dia

@Daniel-Diaz Daniel-Diaz self-assigned this May 12, 2018
@Daniel-Diaz Daniel-Diaz removed their assignment May 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants