chalkboard-0.2: Combinators for building and processing 2D images.

Portability ghc unstable Andy Gill

Graphics.Chalkboard.Board

Description

Boards are the principal type for our images. The are conceptually functions from 2D coordinates to values, typically a color.

Common Boards include

• Board Bool -- A masking Board, or region.
• Board RGB -- Color Board
• Board (Alpha RGB) -- A Color Board with alpha (transparency) values.
• Board (Maybe a) -- A Board with binary transparency.
• Board (Maybe Color) -- A Color Board with binary transparency.
• Board Point -- A Board (or field) of Point values.

Synopsis

# The Board datatype

data Board a Source

'''Board''' is our primary data type, an infinite flat surface (or R2 field) of values. Conceptually, Board a = Point -> a.

Instances

 Functor Board Applicative Board Scale (Board a) Over c => Over (Board c)

# looking up a point on the Board.

lookup :: Board a -> (R, R) -> aSource

# Creating Boards.

coord field or Board, where each point is its own coordinate in R2.

maskFor :: (Point, Point) -> Board BoolSource

build a rectangle mask or region.

build a circular mask or region, with a circle of radius R, and center Point.

# Translations on a Board.

scale :: Scale c => R -> c -> cSource

scaleXY :: (R, R) -> Board a -> Board aSource

A non-overloaded version of scale which takes a independent x and y coordinate.

move :: (R, R) -> Board a -> Board aSource

move a Board by specified vector.

rotate :: Radian -> Board a -> Board aSource

rotate the Board.

crop :: Board Bool -> Board a -> Board (Maybe a)Source

crop crops a Board, based on a masking Board.

class Functor f => Applicative f where

A functor with application.

Instances should satisfy the following laws:

identity
pure id <*> v = v
composition
pure (.) <*> u <*> v <*> w = u <*> (v <*> w)
homomorphism
pure f <*> pure x = pure (f x)
interchange
u <*> pure y = pure (\$ y) <*> u
ignore left value
u *> v = pure (const id) <*> u <*> v
ignore right value
u <* v = pure const <*> u <*> v

The Functor instance should satisfy

fmap f x = pure f <*> x

If f is also a Monad, define pure = return and (<*>) = ap.

Minimal complete definition: pure and <*>.

Methods

pure :: a -> f a

Lift a value.

(<*>) :: f (a -> b) -> f a -> f b

Sequential application.

(*>) :: f a -> f b -> f b

Sequence actions, discarding the value of the first argument.

(<*) :: f a -> f b -> f a

Sequence actions, discarding the value of the second argument.

Instances

 Applicative [] Applicative IO Applicative ZipList Applicative STM Applicative Maybe Applicative Board Applicative ((->) a) Applicative (Either e) Monoid a => Applicative ((,) a) Monoid m => Applicative (Const m) Monad m => Applicative (WrappedMonad m) Arrow a => Applicative (WrappedArrow a b)