项目作者: Chris00

项目描述 :
Binding to Cairo, a 2D Vector Graphics Library.
高级语言: OCaml
项目地址: git://github.com/Chris00/ocaml-cairo.git
创建时间: 2013-08-10T09:29:30Z
项目社区:https://github.com/Chris00/ocaml-cairo

开源协议:GNU Lesser General Public License v3.0

下载


Continuous Integration

OCaml interface to Cairo

This is an OCaml binding for the
Cairo library, a 2D graphics library
with support for multiple output devices.

You can read the API of
Cairo,
Cairo_gtk,
and
Cairo_pango
online.

Prerequisites

You need the development files of Cairo (see the
conf-cairo
package)
and the OCaml package
lablgtk2 (in the OPAM package
lablgtk).

Compilation & Installation

The easier way to install this library — once the prerequisites are set
up — is to use opam:

  1. opam install cairo2

If you would like to compile from the sources, install Dune

  1. opam install dune

and do:

  1. dune build @install

or just make. You can then install it with:

  1. dune install

Examples

You can read a version of the
Cairo tutorial using
this module. The code of this tutorial is available in the
examples/ directory. To compile it, just do

  1. dune build @examples

All the examples below are available (with some comments) by clicking
on images in the tutorial.

Basic examples

  • stroke.ml shows how to draw (stroke) a simple
    rectangle on a PNG surface.
  • stroke.ml shows how to fill a simple
    rectangle on a PNG surface.
  • showtext.ml illustrates how to select a font
    and draw some text on a PNG surface.
  • paint.ml shows how to paint the current source
    everywhere within the current clip region.
  • mask.ml shows how to apply a radial transparency
    mask on top of a linear gradient.
  • setsourcergba.ml produces

    Source RGBA

  • setsourcegradient.ml shows how to use
    radial and linear patterns. It generates:

    Gradient

  • path_close.ml shows how to draw a closed
    path. It produces the PNG:

    close path

  • textextents.ml displays graphically the various
    dimensions one can request about text. It generates the PNG:

    text

  • text_extents.ml exemplifies drawing
    consecutive UTF-8 strings in a PDF file. Some helping lines are
    also added to show the text extents.

  • tips_ellipse.ml shows the action of
    dilation on the line width and how to properly draw ellipses.
    It generates the PNG:

    ellipse

  • tips_letter.ml illustrates the wrong way
    of centering characters based on their individual extents:

    letters

    Instead, one should combine them with the font extents as shown in
    tips_font.ml to have:

    fonts

Examples generating the images of the tutorial