ExTbpMonty.Core.Png (ExTbpMonty.Core v0.1.0)

Copy Markdown View Source

A PNG of pixels this port already has.

Monty's worlds answer depth, colour and semantic id as images, and a page that shows them needs a bitmap. A 64 × 64 frame drawn as SVG is four thousand rectangles; drawn as PNG it is a few hundred bytes and the browser does the work.

Only what a frame needs is implemented: 8-bit greyscale (depth) and 8-bit colour (rgba), one filter, one deflate stream. :zlib and :erlang.crc32 are the standard library, so this is a file format rather than a dependency.

Summary

Functions

A greyscale PNG of rows, each a list of values from 0 (black) to 255.

A colour PNG of rows, each a list of [r, g, b] from 0 to 255.

Types

rows()

@type rows() :: [[number()]]

Functions

greyscale(rows)

@spec greyscale(rows()) :: binary()

A greyscale PNG of rows, each a list of values from 0 (black) to 255.

Depth is drawn this way: one channel, because there is one number per pixel.

rgb(rows)

@spec rgb([[[number()]]]) :: binary()

A colour PNG of rows, each a list of [r, g, b] from 0 to 255.