Music.Theory.Diagram.Grid

Contents

Description

Functions for drawing grid and table structure common in music theory and in compositions such as Morton Feldman's durational grid music of the 1950's.

Synopsis

# Grid

type R = DoubleSource

Real number, synonym for Double.

type P = (R, R)Source

Point given as pair of R.

type C = (R, R, R)Source

Red, green and blue colour triple.

type L = (Int, Int)Source

Cell location as row and column indices.

type Cell = (L, C, String)Source

Cell

type Grid = [Cell]Source

Grid

grid :: P -> (R, R) -> (Int, Int) -> [P]Source

Given (x,y) upper-left co-ordinate of grid, (w,h) cell dimensions, and (r,c) grid dimensions, make list of upper-left co-ordinates of cells.

grid (10,10) (50,10) (2,2) == [(10,10),(60,10),(10,20),(60,20)]

grid_pt :: (R, R) -> (R, R) -> L -> PSource

Variant on grid that constructs a single point.

map (grid_pt (10,10) (50,10)) [(0,0),(1,1)] == [(10,10),(60,20)]

displace :: (R, R) -> P -> PSource

displace (2,3) (1,1) == (3,4)

mk_bbox :: (Int, Int) -> (R, R)Source

Make a bounding box from row and column dimensions.

# Table

type Table_Cell = ([Attr], [Content])Source

A table cell is an Attr and Content duple.

type Table = (Caption, [[Table_Cell]])Source

Table of row order Table_Cells.

simple_table :: Caption -> [[Content]] -> TableSource

Construct a Table with one Content per cell.

simple_table_class :: Caption -> [[(String, Content)]] -> TableSource

Construct a Table with one Content per cell, and an associated class.

build_table_m :: Caption -> (Int, Int) -> Build_F -> TableSource

Build a table of (rows,columns) dimensions given a function from (row,column) to Maybe Table_Cell. If the function is Nothing the cell is skipped, becase another cell has claimed it's locations with colspan or rowspan.

build_table :: Caption -> (Int, Int) -> ((Int, Int) -> Table_Cell) -> TableSource

Build a table of (rows,columns) dimensions given a function from (row,column) to Table_Cell.

Render Table as HTML table.

type Table_Set = [Table]Source

A set of related tables.

Render a Table_Sets in a div with class table-set.

page :: Maybe FilePath -> [Table_Set] -> StringSource

Render set of Table_Sets as HTML.

to_html :: FilePath -> Maybe FilePath -> [Table_Set] -> IO ()Source

Write set of Table_Sets to HTML file.