willdonnelly / pastel

A composable image generation library for Haskell

This URL has Read+Write access

pastel /
name age message
directory Graphics/ Loading commit data...
file LICENSE
file Main.hs
file README.mkd
file Setup.hs
file pastel.cabal
README.mkd

Pastel - A Fast, Composable Image Library

Pastel is an image generation and manipulation library written in Haskell. It is designed for speed and library integration, as well as elegance of use.

Getting Started With Pastel

The main functionality of the library is imported as Graphics.Pastel. Additionally, support for an output method will need to be imported from Graphics.Pastel.<Method>, where <Method> is one of:

  • GD

  • GTK

  • WX

Pastel models a drawing as a function from a coordinate in a 2D plane to a color value. Complex drawings can be created by applying various graphics primitives simpler drawings.

The simplest drawing is a blank, solid-color canvas. A canvas can be created with the canvas function, which has type Color -> Drawing. Other shapes can be drawn on the canvas through function composition.

For example, circle blue $ canvas white will create an image of a blue circle on top of a white canvas.

Some basic primitives include circle, square, gradientLinear, and gradientRadial. All of these primitives require a color as an argument. Some basic transformations include zoom, scale, rotate, and translate.

Displaying Images

The Graphics.Pastel.GTK library will be used here for example purposes. The function naming convention for the other methods should be obvious.

There are two ways of displaying images with Pastel. The drawGTK function will take two arguments, a resolution and a drawing, and return a GTK Pixbuf which can be converted to an image and drawn to a window.

For simple testing purposes, though, you will want to use the testGTK function. This function handles the complexity of creating a GTK window and drawing the image. It takes the same arguments as the drawGTK function.

Pastel Roadmap

Pastel is still a work in progress. Current plans for the library include:

  • Learn more about separating IO modules from the rest of the library, so it can be built without GTK / WX / GD if desired.

  • Upload to hackage

  • Win32 Support

  • Image file loading support (if Graphics.GD ever gets a gdImageGetPixel function to match gdImageSetPixel)

  • Improve performance of primitives