piet-0.1: A Piet interpreter

Language.Piet.Compiler

Contents

Description

This module implements the image processing part of this library. It is able to do basic image I/O and provides funcions for labelling images and extracting Piet-relevant information at the same time.

Synopsis

I/O

imgFromFileSource

Arguments

:: Maybe Int

Codel length or Nothing if unknown

-> FilePath

The image file location

-> IO (Either ImlibLoadError (Image Colour)) 

Load an Image holding Piet Colours from a given file. If the codel length is known, it should be passed as Just argument, otherwise, it is guessed from the file. Note that "codel length" means the edge length of the codels and not their size.

This function is not thread safe due to imlib2!

The "compiler"

compile :: Image Colour -> ProgramSource

Compile an Image Colour to a Piet Program.

Labelling

label4 :: Eq a => Image a -> (Image LabelKey, IntMap LabelInfo)Source

Label an image with 4-neighbourship and equivalence as neighbouring condition, which is label4With (==).

label4WithSource

Arguments

:: (a -> a -> Bool)

Decides whether two neighbouring pixels are adjacent.

-> Image a

The Image to be labelled.

-> (Image LabelKey, IntMap LabelInfo)

A mask Image (containing a key for every pixel) and a mapping from these keys to LabelInfo.

Labels an image with 4-neighbourship.