Module

Reactor.Graphics.Drawing

Package
purescript-grid-reactors
Repository
Eugleo/purescript-grid-reactors

This module provides the means of producing a drawing of the reactor's world. The drawing is then rendered on canvas. Currently, only grid-based drawings are supported.

#Drawing Source

type Drawing = DrawingM Unit

DrawingM is usually too general; our drawing-contructing functions don't need to return anything. Internal implementation detail.

Usually, constructing a drawing will look something like this.

drawTwoPoints :: CoordinateSystem Point -> CoordinateSystem Point -> Drawing
drawTwoPoints blueXY redXY = do
  fill Color.blue400 $ cell blueXY
  fill Color.red400 $ cell redXY

#DrawingM Source

newtype DrawingM a

A free monad for DrawingF that enables you to use do-notation when constructing drawings. Internal implementation detail.

Constructors

Instances

#DrawingF Source

data DrawingF a

A DSL for constructing drawings. Currently, only filled shapes are supported. Mostly for internal use. Most of the time, you construct a drawing by calling the different helper functions, like fill, instead of manually constructing a DrawingF.

Constructors

Instances

#fill Source

fill :: Color -> Shape -> Drawing

Fill a shape with a color.

#mapOver Source

mapOver :: forall a. Grid a -> (a -> Maybe Color) -> Drawing

Produce a drawing from a grid. For each cell in the grid, call the supplied function to obtain its color.

#mapOverWithIndex Source

mapOverWithIndex :: forall a. Grid a -> ({ x :: Int, y :: Int } -> a -> Maybe Color) -> Drawing

Produce a drawing from a grid. For each cell in the grid, call the supplied function to obtain its color. The function receives not only the value of the cell, but also its index.

#Size Source

type Size = { height :: Number, width :: Number }

#cell Source

cell :: CoordinateSystem Point -> Shape

A 1-square cell on the given point in the grid.