Module Make64.Svg

Utilities for writing (and reading) simple SVGs, for use in debugging and quick visualization.

Configuration Types

module Color : sig ... end

Describing colours with which to paint paths and draw text.

val color : ?alpha:float -> Color.color -> Color.t

color ?alpha c

Create a colour with the transparency alpha (default = 0.8). Alias to Color.make.

type coords

coordinate label styling (font, color, and size)

val coords : ?font:string -> ?size:int -> ?color:Color.t -> unit -> coords

coords ?font ?size ?color ()

Create a coordinate display style to be given to write, which will apply to any paint artists with show_coords=true. Defaulting to 11pt Verdana in solid black.

Artists

Declarative construction of artists to be applied to an svg in the order that they are supplied to write.

type artist

An element to be written to svg (text, paths, or filled polygons)

Drawing Text

val text : ?size:int -> ?color:Color.t -> V.t -> string -> artist

text ?size ?color v s

Draw the text s with the given color (default Black) and size (default 11) at the position v.

Painting Paths

val paint : ?closed:bool -> ?fill_rule:fill_rule -> ?show_coords:bool -> ?width:float -> ?brush:Color.t -> ?pen:Color.t -> ('cpp, 'ctr) t -> artist

paint ?closed ?fill_rule ?show_coords ?width ?brush ?pen path

Draw a path or filled polygon (depending on closed, which defaults to true, and fill_rule (defaults to `NonZero)). width and pen set the thickness and color of the outline respectively, while brush governs the filling color. Point coordinates will be drawn if a show_coords is provided, otherwise they will be left off.

Debug Helpers

val subject : ?closed:bool -> ?fill_rule:fill_rule -> ('cpp, 'ctr) t -> artist

subject ?closed ?fill_rule path

paint subject path(s) with default Clipper2 pen and brush settings.

val clip : ?fill_rule:fill_rule -> ('cpp, 'ctr) t -> artist

clip ?fill_rule path

paint clipping path(s) with default Clipper2 pen and brush settings.

val solution : ?closed:bool -> ?fill_rule:fill_rule -> ?show_coords:bool -> ('cpp, 'ctr) t -> artist

solution ?closed ?fill_rule ?show_coords path

paint solution path(s) with default Clipper2 pen and brush settings.

IO

val write : ?max_width:int -> ?max_height:int -> ?margin:int -> ?coords:coords -> string -> artist list -> (unit, string) Stdlib.result

write path artists

Write the list of artists (see text and paint) in sequence to an svg file at path.

val read : string -> paths

read filename

Read paths from from the svg file at the given path.