package cairo2

  1. Overview
  2. Docs

The SVG surface is used to render cairo graphics to SVG files and is a multi-page vector surface backend.

To create a cairo context cr that will write the the SVG file fname with dimensions w×h points, do let cr = Cairo.create(Cairo.SVG.create fname w h). Do not forget to call Surface.finish(get_target cr) when you are done drawing because the file may not be fully written before.

val create : fname:string -> width:float -> height:float -> Surface.t

Creates a SVG surface of the specified size in points to be written to fname.

  • parameter width

    width of the surface, in points (1 point = 1/72.0 inch)

  • parameter height

    height of the surface, in points (1 point = 1/72.0 inch)

val create_for_stream : output:(string -> unit) -> width:float -> height:float -> Surface.t

Creates a SVG surface of the specified size in points to be written incrementally to the stream represented by output. Any exception that output raises is considered as a write error.

  • parameter width

    width of the surface, in points (1 point = 1/72.0 inch)

  • parameter height

    height of the surface, in points (1 point = 1/72.0 inch)

type version =
  1. | VERSION_1_1
  2. | VERSION_1_2

The version number of the SVG specification that a generated SVG file will conform to.

val restrict_to_version : Surface.t -> version -> unit

Restricts the generated SVG file to version. See Cairo.SVG.get_versions for a list of available version values that can be used here.

This function should only be called before any drawing operations have been performed on the given surface. The simplest way to do this is to call this function immediately after creating the surface.

val get_versions : unit -> version list

Retrieve the list of supported versions.

val version_to_string : version -> string

Get the string representation of the given version id.

OCaml

Innovation. Community. Security.