package hugin

  1. Overview
  2. Docs

Module UcairoSource

Minimal Cairo bindings.

Thin bindings covering image and PDF surface creation, path drawing, text rendering, and PNG output. Designed for the Hugin rendering backend; not a general-purpose Cairo binding.

All functions raise Failure on Cairo errors and Invalid_argument on destroyed handles.

Handle types

Sourcetype t

The type for Cairo drawing contexts.

Sourcetype surface

The type for Cairo surfaces.

Enumerations

Sourcetype font_weight =
  1. | Normal
  2. | Bold
    (*

    The type for font weight.

    *)
Sourcetype line_cap =
  1. | Butt
  2. | Round
  3. | Square
    (*

    The type for line cap style.

    *)
Sourcetype line_join =
  1. | Join_miter
  2. | Join_round
  3. | Join_bevel
    (*

    The type for line join style.

    *)
Sourcetype antialias =
  1. | Antialias_default
  2. | Antialias_none
  3. | Antialias_gray
  4. | Antialias_subpixel
    (*

    The type for antialiasing mode.

    *)

Text extents

Sourcetype text_extents = {
  1. x_bearing : float;
  2. y_bearing : float;
  3. width : float;
  4. height : float;
  5. x_advance : float;
  6. y_advance : float;
}

The type for text extent measurements.

Context creation

Sourceval create : surface -> t

create surface is a new drawing context targeting surface.

State

Sourceval save : t -> unit

save t pushes the current graphics state onto the stack.

Sourceval restore : t -> unit

restore t pops the graphics state from the stack.

Transformations

Sourceval translate : t -> float -> float -> unit

translate t tx ty translates the user-space origin by (tx, ty).

Sourceval scale : t -> float -> float -> unit

scale t sx sy scales the user-space axes by (sx, sy).

Sourceval rotate : t -> float -> unit

rotate t angle rotates the user-space axes by angle radians.

Source

Sourceval set_source_rgba : t -> float -> float -> float -> float -> unit

set_source_rgba t r g b a sets the source to the given RGBA color.

Sourceval set_source_surface : t -> surface -> x:float -> y:float -> unit

set_source_surface t s ~x ~y sets s as the source, offset by (x, y).

Stroke and fill parameters

Sourceval set_line_width : t -> float -> unit

set_line_width t w sets the stroke line width.

Sourceval set_line_cap : t -> line_cap -> unit

set_line_cap t cap sets the line cap style.

Sourceval set_line_join : t -> line_join -> unit

set_line_join t join sets the line join style.

Sourceval set_dash : t -> float array -> unit

set_dash t dashes sets the dash pattern. An empty array disables dashing.

Sourceval set_antialias : t -> antialias -> unit

set_antialias t aa sets the antialiasing mode.

Font

Sourceval select_font_face : t -> string -> font_weight -> unit

select_font_face t family weight selects a toy font face. Slant is always upright.

Sourceval set_font_size : t -> float -> unit

set_font_size t size sets the font size in user-space units.

Sourceval text_extents : t -> string -> text_extents

text_extents t s is the extents of s with the current font.

Sourceval show_text : t -> string -> unit

show_text t s renders s at the current point.

Path operations

Sourceval move_to : t -> float -> float -> unit

move_to t x y begins a new sub-path at (x, y).

Sourceval line_to : t -> float -> float -> unit

line_to t x y adds a line segment to (x, y).

Sourceval arc : t -> float -> float -> r:float -> a1:float -> a2:float -> unit

arc t xc yc ~r ~a1 ~a2 adds a circular arc centered at (xc, yc) with radius r from angle a1 to a2 (in radians).

Sourceval rectangle : t -> float -> float -> w:float -> h:float -> unit

rectangle t x y ~w ~h adds a closed rectangle sub-path.

Path module

Sourcemodule Path : sig ... end

Drawing operations

Sourceval fill : t -> unit

fill t fills the current path and clears it.

Sourceval fill_preserve : t -> unit

fill_preserve t fills the current path without clearing it.

Sourceval stroke : t -> unit

stroke t strokes the current path and clears it.

Sourceval paint : t -> unit

paint t paints the current source everywhere within the current clip.

Sourceval clip : t -> unit

clip t establishes a new clip region by intersecting the current clip with the current path, then clears the path.

Surface operations

Sourcemodule Surface : sig ... end

Image surface

Sourcemodule Image : sig ... end

PDF surface

Sourcemodule Pdf : sig ... end

PNG output

Sourcemodule Png : sig ... end