First public release of OCaml-Canvas 1.0

We are proud to announce the first public release of OCaml-Canvas 1.0!

OCaml-Canvas provides canvases to do interactive vector graphics in OCaml, using native implementations (Windows, Macos, X11) and a web-backend (Javascript), with a programming interface similar to HTML5 canvases.

Compared to the Graphics library, it provides a larger API, a web backend, and native Windows and Macos backends (with Cocoa API, instead of XQuartz).

To sum up, OCaml-Canvas focuses on:

  • maximizing portability : OCaml-Canvas works natively under Linux (X11 and soon Wayland), macOS and Windows, and also provides a Javascript backend;
  • minimizing dependencies: the native backends make use of as few dependencies as possible;
  • improving aesthetics: OCaml-Canvas supports OpenType and TrueType fonts and anti-aliasing;

OCaml-Canvas is already available on Opam: opam - ocaml-canvas

A quick tutorial is available on Quick start — ocaml-canvas master (b1d252e ) (2022/12/12 10:50) documentation

The complete documentation is available on OCaml-Canvas

Hope this will be useful to the community !

27 Likes

Wonderful! Sorely needed.

If you fancy adding PDF export with CamlPDF I’d be happy to give a few pointers - everything other than custom fonts would be pretty easy, and it works on all your platforms (including JS). See graphicspdf/graphicspdf.ml at master · johnwhitington/graphicspdf · GitHub for a proof-of-concept.

7 Likes

That would indeed be a useful addition, albeit a bit involved considering the current library architecture (a lot of C code under the hood). I’ll see what can be done about it.

1 Like