module Kwpicture:sig..end
Implemented as list of columns.
Author(s): Keith Waclena
type t
val nil : tval pic : ?c:char -> int * int -> tpic ?c (h,w): create a picture of height h and witdh w consisting of c characters.
The null picture (0,0) is valid, but (0,w) and (h,0) are impossible.
Example: pic ~c:'.' (3,3) yields:
... ... ...
c : the character the picture will consist of (default: ' ' (space))val height : t -> intheight pic: return height of picture.val width : t -> intwidth pic: return width of picture.val copy : int -> t -> t listcopy n pic: return a list consisting of n copies of picture p.val row : string -> trow str: convert a string of length n to a 1xn picture representing that
string as a single row.val col : string -> tcol str: convert string str to a (String.length str)x1 picture
representing that string as a single column.val above : t -> t -> tabove a b: return a picture consisting of pictures a and b
on top of each other (a above b).
Example: above (row "--+") (row "*==") yields:
--+ *==
val beside : t -> t -> tbeside a b: return a picture consisting of pictures a and b
beside each other (a on the left).
Example: let x = above (row "--+") (row "*==") in beside x x yields:
--+--+ *==*==
val stack : t list -> tstack pics: return a picture consisting of all the pictures in the list,
set each above the other (first picture on top).
Example: stack (copy 4 (row "--+")) yields:
--+ --+ --+ --+
val spread : t list -> tspread pics: return a picture consisting of all the pictures in the list,
set each beside the other (first picture on the left).
Example: spread (copy 3 (stack (copy 4 (row "--+")))) yields:
--+--+--+ --+--+--+ --+--+--+ --+--+--+
val flipH : t -> tflipH pic: flip the picture horizontally (i.e. left becomes right).
Example: beside (above (row "---") (row "---")) (above (row "+++") (row "+++")) yields:
---+++ ---+++and
flipH (beside (above (row "---") (row "---")) (above (row "+++") (row "+++"))) yields:
+++--- +++---
val flipV : t -> tflipV pic: flip the picture vertically (i.e. make it upside-down).
Example: above (row "---") (row "+++") yields:
--- +++and
flipV (above (row "---") (row "+++")) yields:
+++ ---
val block : int -> t list -> tblock n pics: return the picture consisting of the pictures in pics taken n at a time.
Example: block 3 (copy 12 (row "--+")) yields:
--+--+--+ --+--+--+ --+--+--+ --+--+--+
val blockT : int -> t list -> tblockT n pics: the transpose of block n pics.
Example: blockT 3 (copy 12 (row "--+")) yields:
--+--+--+--+ --+--+--+--+ --+--+--+--+
type position =
| |
NW |
| |
N |
| |
NE |
| |
W |
| |
C |
| |
E |
| |
SW |
| |
S |
| |
SE |
val frame : ?c:char -> position -> int * int -> t -> tframe ?c pos (h,w) p: return the picture consisting of p set in the
an h x w picture (i.e. a background of c's). The position pos
determines where p is positioned:
------------ -NW--N---NE- ------------ ------------ -W---C---E-- ------------ ------------ -SW--S---SE- ------------
Example: frame ~c:'.' NW (4,5) (pic ~c:'+' (2,3)) yields:
+++.. +++.. ..... .....
c : the character the background will consist of (default: ' ' (space))val to_string : t -> stringto_string pic: convert picture p to a string.val display : ?h:char -> ?v:char -> t -> tdisplay p: put a border around picture p to make it easy to see the extent of the picture.h : horizontal frame character (default: '-')v : vertical frame character (default: '|')val print : t -> unitprint pic: convenience function to print a picture to stdout.