algebra-driven-design-0.1.0.1: Companion library for the book Algebra-Driven Design by Sandy Maguire
Safe HaskellNone
LanguageHaskell2010

ADD.Tiles.Functor

Synopsis

Tiles and their observations

data Tile a Source #

Instances

Instances details
Monad Tile Source # 
Instance details

Defined in ADD.Tiles.Functor

Methods

(>>=) :: Tile a -> (a -> Tile b) -> Tile b #

(>>) :: Tile a -> Tile b -> Tile b #

return :: a -> Tile a #

Functor Tile Source # 
Instance details

Defined in ADD.Tiles.Functor

Methods

fmap :: (a -> b) -> Tile a -> Tile b #

(<$) :: a -> Tile b -> Tile a #

Applicative Tile Source # 
Instance details

Defined in ADD.Tiles.Functor

Methods

pure :: a -> Tile a #

(<*>) :: Tile (a -> b) -> Tile a -> Tile b #

liftA2 :: (a -> b -> c) -> Tile a -> Tile b -> Tile c #

(*>) :: Tile a -> Tile b -> Tile b #

(<*) :: Tile a -> Tile b -> Tile a #

Show (Tile t) Source # 
Instance details

Defined in ADD.Tiles.Functor

Methods

showsPrec :: Int -> Tile t -> ShowS #

show :: Tile t -> String #

showList :: [Tile t] -> ShowS #

Semigroup a => Semigroup (Tile a) Source # 
Instance details

Defined in ADD.Tiles.Functor

Methods

(<>) :: Tile a -> Tile a -> Tile a #

sconcat :: NonEmpty (Tile a) -> Tile a #

stimes :: Integral b => b -> Tile a -> Tile a #

Monoid a => Monoid (Tile a) Source # 
Instance details

Defined in ADD.Tiles.Functor

Methods

mempty :: Tile a #

mappend :: Tile a -> Tile a -> Tile a #

mconcat :: [Tile a] -> Tile a #

Arbitrary a => Arbitrary (Tile a) Source # 
Instance details

Defined in ADD.Tiles.Functor

Methods

arbitrary :: Gen (Tile a) #

shrink :: Tile a -> [Tile a] #

rasterize Source #

Arguments

:: forall a. Int

resulting width

-> Int

resulting heigeht

-> Tile a 
-> Compose ZipList ZipList a

the resulting "pixels" in row-major order

Rasterize a Tile down into a row-major representation of its constituent "pixels". For a version that emits a list of lists directly, see rasterize'.

rasterize' Source #

Arguments

:: Int

resulting width

-> Int

resulting heigeht

-> Tile a 
-> [[a]]

the resulting "pixels" in row-major order

Like rasterize, but with a more convenient output type.

toImage Source #

Arguments

:: Int

resulting width

-> Int

resulting height

-> Tile Color 
-> Image PixelRGBA8 

Like rasterize, but into a format that can be directly saved to disk as an image.

Tile constructors

empty :: Tile Color Source #

The empty, fully transparent Tile.

cw :: Tile a -> Tile a Source #

Rotate a Tile clockwise.

ccw :: Tile a -> Tile a Source #

Rotate a Tile counterclockwise.

flipH :: Tile a -> Tile a Source #

Mirror a Tile horizontally.

flipV :: Tile a -> Tile a Source #

Mirror a Tile vertically.

beside :: Tile a -> Tile a -> Tile a Source #

Place the first Tile to the left of the second. Each Tile will receive half of the available width, but keep their full height.

rows :: Monoid a => [Tile a] -> Tile a Source #

Like above, but repeated. Every element in the list will take up a proportional height of the resulting Tile.

above :: Tile a -> Tile a -> Tile a Source #

Place the first Tile above the second. Each Tile will receive half of the available height, but keep their full width.

cols :: Monoid a => [Tile a] -> Tile a Source #

Like beside, but repeated. Every element in the list will take up a proportional width of the resulting Tile.

behind :: Tile Color -> Tile Color -> Tile Color Source #

Place the first Tile behind the second. The result of this operation is for transparent or semi-transparent pixels in the second argument to be blended via over with those in the first.

quad :: Tile a -> Tile a -> Tile a -> Tile a -> Tile a Source #

Place four Tiles in the four quadrants. The first argument is the top-left; the second is the top-right; third: bottom left; fourth: bottom right.

quads :: (a -> a) -> Tile (a -> a) Source #

Like quad, but constructs a Tile of endomorphisms. The given function is called one more time for each quadrant, starting clockwise from the top-left.

swirl :: Tile a -> Tile a Source #

A quad where the given Tile is rotated via cw once more per quadrant.

nona :: Monoid a => Tile a -> Tile a -> Tile a -> Tile a Source #

Puts a frame around a Tile. The first argument is the straight-edge border for the top of the frame. The second argument should be for the top-right corner. The third argument is the Tile that should be framed.

Special tiles

haskell :: Tile Color Source #

The Haskell logo.

Colors and their observations

redChannel :: Color -> Double Source #

Extract the red channel from a Color.

greenChannel :: Color -> Double Source #

Extract the green channel from a Color.

blueChannel :: Color -> Double Source #

Extract the blue channel from a Color.

alphaChannel :: Color -> Double Source #

Extract the alpha channel from a Color.

Color constructors

pattern Color :: Double -> Double -> Double -> Double -> Color Source #

 

invert :: Color -> Color Source #

Inverts a Color by negating each of its color channels, but leaving the alpha alone.

mask :: Color -> Color -> Color Source #

Copy the alpha channel from the first Color and the color channels from the second Color.

over :: Color -> Color -> Color Source #

Blends a Color using standard alpha compositing.

Orphan instances

Semigroup Color Source # 
Instance details

Methods

(<>) :: Color -> Color -> Color #

sconcat :: NonEmpty Color -> Color #

stimes :: Integral b => b -> Color -> Color #

Monoid Color Source # 
Instance details

Methods

mempty :: Color #

mappend :: Color -> Color -> Color #

mconcat :: [Color] -> Color #

Arbitrary PixelRGBA8 Source # 
Instance details

CoArbitrary PixelRGBA8 Source # 
Instance details

Methods

coarbitrary :: PixelRGBA8 -> Gen b -> Gen b #