https://github.com/ocaml/graphics
The Graphics library from OCaml, in a standalone repository
https://github.com/ocaml/graphics
Last synced: 8 months ago
JSON representation
The Graphics library from OCaml, in a standalone repository
- Host: GitHub
- URL: https://github.com/ocaml/graphics
- Owner: ocaml
- License: other
- Created: 2019-03-12T09:19:29.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2025-02-28T11:35:21.000Z (over 1 year ago)
- Last Synced: 2025-05-25T18:06:08.519Z (about 1 year ago)
- Language: C
- Size: 435 KB
- Stars: 70
- Watchers: 19
- Forks: 32
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: LICENSE
Awesome Lists containing this project
README
Graphics
========
The graphics library provides a set of portable drawing
primitives. Drawing takes place in a separate window that is created
when Graphics.open_graph is called. It used to be distributed with
OCaml up to OCaml 4.08.

Documentation
-------------
The API is documented
[here](https://ocaml.org/p/graphics/latest/doc/Graphics/index.html)
and as comments in the source file `src/graphics.mli`.
On Linux, macOS, and other Unix systems
---------------------------------------
The Graphics library uses the X11 windows system.
macOS users need to install [XQuartz](https://www.xquartz.org/).
Here are the graphics mode specifications supported by
`Graphics.open_graph` on the X11 implementation of this library: the
argument to `Graphics.open_graph` has the format `"display-name
geometry"`, where display-name is the name of the X-windows display to
connect to, and geometry is a standard X-windows geometry
specification. The two components are separated by a space. Either can
be omitted, or both. Examples:
- `Graphics.open_graph "foo:0"`: connects to the display foo:0 and
creates a window with the default geometry
- `Graphics.open_graph "foo:0 300x100+50-0"` connects to the display
foo:0 and creates a window 300 pixels wide by 100 pixels tall, at
location (50,0)
- `Graphics.open_graph " 300x100+50-0"` connects to the default
display and creates a window 300 pixels wide by 100 pixels tall, at
location (50,0)
- `Graphics.open_graph ""` connects to the default display and creates
a window with the default geometry.
On Windows
----------
On Windows, the Graphics library uses the native Win32 API.
Examples
--------
The `examples/` directory contains a few examples. You can run them
with:
- `dune exec examples/sorts.exe`
- `dune exec examples/graph_example.exe`
- `dune exec examples/graph_test.exe`
- `dune exec examples/fonts.exe`