Module Graph.XDotDraw

Parses xdot drawing operations

See dot documentation to understand the drawing operations

Types

type pos = float * float

Dot layout coordinates

type width = float

Dimensions

type height = float
type size = int
type align =
| Left
| Center
| Right

Text alignment

type style_attr =
| Filled
| Invisible
| Diagonals
| Rounded
| Dashed
| Dotted
| Solid
| Bold
| StyleString of string

Style attributes

type operation =
| Filled_ellipse of pos * width * height
| Unfilled_ellipse of pos * width * height
| Filled_polygon of pos array
| Unfilled_polygon of pos array
| Polyline of pos array
| Bspline of pos array
| Filled_bspline of pos array
| Text of pos * align * width * string
| Fill_color of string
| Pen_color of string
| Font of float * string
| Style of style_attr list

Drawing operations

val string_scale_size : fontMeasure:(fontName:string -> fontSize:int -> string -> int * int) -> string -> float -> string -> width * height

string_scale_size ~fontMeasure font font_size text. Interpolates the font metrics we have to use to draw the given text with the given font but preserving the bounding box of the text even with a proportional font. For a fixed width font the result is font_size*font_size.

Parsing and drawing state

Parses an xdot drawing attribute

val parse : string -> operation list

Some drawing operations modify the following drawing state (pen_color, font and style).

type draw_state = private {
mutable fill_color : string;
mutable pen_color : string;
mutable font : float * string;
mutable style : style_attr list;
}
val draw_with : (draw_state -> operation -> unit) -> operation list -> unit

Iterates on the drawing operations and updates the implicit drawing state

Miscellaneous

val normalize_color : string -> string

Reads the color string and converts to rgb if in an another format