Note that there are some explanatory texts on larger screens.

plurals
  1. POImage drawing library for Haskell?
    primarykey
    data
    text
    <p>I'm working on a Haskell program for playing spatial games: I have a graph of a bunch of "individuals" playing the Prisoner's Dilemma, but only with their immediate neighbors, and copying the strategies of the people who do best.</p> <p>I've reached a point where I need to draw an image of the world, and this is where I've hit problems. Two of the possible geometries are easy: if people have four or eight neighbors each, then I represent each one as a filled square (with color corresponding to strategy) and tile the plane with these. However, I also have a situation where people have six neighbors (hexagons) or three neighbors (triangles).</p> <p>My question, then, is: <strong>what's a good Haskell library for creating images and drawing shapes on them?</strong> I'd prefer that it create PNGs, but I'm not incredibly picky. I was originally using <a href="http://hackage.haskell.org/packages/archive/gd/3000.4.0/doc/html/Graphics-GD.html" rel="noreferrer">Graphics.GD</a>, but it only exports bindings to functions for drawing points, lines, arcs, ellipses, and non-rotated rectangles, which is not sufficient for my purposes (unless I want to draw hexagons pixel by pixel*). I looked into using <code>foreign import</code>, but it's proving a bit of a hassle (partly because the polygon-drawing function requires an array of <code>gdPoint</code> structs), and given that my requirements may grow, it would be nice to use an in-Haskell solution and not have to muck about with the FFI (though if push comes to shove, I'm willing to do that). Any suggestions?</p> <p>* That <em>is</em> also an option, actually; any tips on how to do that would also be appreciated, though I think a library would be easier.</p> <p><strong>EDIT:</strong> Thank you all so much for your suggestions. Unfortunately, I wasn't able to get all of gtk2hs's required libraries to build, which ruled out a lot of solutions. For a variety of reasons, after I tried all your answers, failed to install a number of libraries and found that others could not do what I wanted, I ended up deciding to just export more of an FFI for libgd and used that instead.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload