hmt-diagrams-0.15: Haskell Music Theory Diagrams

Safe HaskellSafe-Inferred
LanguageHaskell98

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 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 :: (Enum a, Num a) => (a, a) -> (a, a) -> (Int, Int) -> [[(a, a)]] Source

Given (x,y) upper-left co-ordinate of grid, (w,h) cell dimensions, and (r,c) grid dimensions, make array 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 -> P Source

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 -> P Source

Displace P (pointwise addition).

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

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

Make a bounding box from row and column dimensions.

Table (HTML)

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

A table cell is an Attr and Content duple.

type Caption = [Content] Source

A table caption.

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

Table of row order Table_Cells.

simple_table :: Caption -> [[Content]] -> HTML_Table Source

Construct a Table with one Content per cell.

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

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

type Build_F = (Int, Int) -> Maybe Table_Cell Source

A function from (row,column) to Maybe Table_Cell

build_table_m :: Caption -> (Int, Int) -> Build_F -> HTML_Table Source

Build a table of (rows,columns) dimensions given a builder function. 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) -> HTML_Table Source

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

table :: HTML_Table -> Content Source

Render Table as HTML table.

type HTML_Table_Set = [HTML_Table] Source

A set of related tables.

table_set :: HTML_Table_Set -> Content Source

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

page :: Maybe FilePath -> [HTML_Table_Set] -> String Source

Render set of Table_Sets as HTML.

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

Write set of Table_Sets to HTML file.