Module

Reactor.Graphics.CoordinateSystem

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

This module provies a wrapper that signalizes whether the wrapped contents (usually points in space) should be taken relative to the rendering canvas (i.e. they are in 'pts') or relative to the grid (i.e. they are in 'cells').

#wrt Source

wrt :: forall a b. a -> (a -> CoordinateSystem b) -> CoordinateSystem b

With respect to. Used to wrap things in a coordinate system in a more pleasant way than what would be possible with the constructors. For example

{ x: 1, y: 1 } `wrt` grid == RelativeToGrid { x: toNumber 1, y: toNumber 1}

#canvas Source

canvas :: forall a. a -> CoordinateSystem a

To be used with wrt, usually { some record }wrt` canvas.

#grid Source

grid :: forall a b. HMap (Int -> Number) a b => a -> CoordinateSystem b

To be used with wrt, usually { some record }wrtgrid. Automatically converts the numbers in{ some record }fromInttoNumber`.

#relativeToGrid Source

relativeToGrid :: forall a b. HMap (Number -> Int) a b => Number -> CoordinateSystem a -> b

Mostly for internal use.

#withCoords Source

withCoords :: forall a b. CoordinateSystem a -> (a -> b) -> b

Unwrap the wrapped thing and pass it to a function.

#Point Source

type Point = { x :: Number, y :: Number }

#moveUp Source

moveUp :: CoordinateSystem Point -> CoordinateSystem Point

A simple helper functions that subtracts 1 from the y coordinate.

#moveDown Source

moveDown :: CoordinateSystem Point -> CoordinateSystem Point

A simple helper functions that adds 1 to the y coordinate.

#moveLeft Source

moveLeft :: CoordinateSystem Point -> CoordinateSystem Point

A simple helper functions that subtracts 1 from the x coordinate.

#moveRight Source

moveRight :: CoordinateSystem Point -> CoordinateSystem Point

A simple helper functions that adds 1 to the x coordinate.