# Graffiti Markup Language (GML)

Graffiti Markup Language (`.gml`) is an open XML format for recording how a
drawing was made: the points of each stroke, their order and their timestamps.
Blackbook is an archive of these recordings, not just pictures of finished tags.

## A drawing in motion

A final image shows the result. GML also preserves the movement: where a stroke
starts, how fast it travels, when the writer pauses and when the next stroke
begins. A player can replay or scrub that motion, or render the same drawing
with a different brush. GML does not store a photograph of the ink or wall.

## Writers meet hackers

![Two hands shaking, one holding a marker and one a keyboard](/images/000000book-handshake.jpg)

Writers capture and share their gestures; programmers turn the same data into
players, visualizations and new tools. Projects including
[Graffiti Analysis](https://www.evan-roth.com/~/works/graffiti-analysis/) and
[EyeWriter](http://eyewriter.org) use GML to connect different ways of drawing.

## Try it

- [Play the tiny example below](#gml-demo): one stroke, three points, two seconds.
- [Explore the archive](/data) and open a tag to replay a real recording.
- [Draw your own GML](/upload) with the browser recorder.
- [Try Canvasplayer](https://jamiew.github.io/canvasplayer), the open-source
  player used on this site, or explore [applications using GML](/apps).

Interactive playback and recording need JavaScript. The explanation and XML
below remain readable without it.

## Inside a .gml file

This small example draws right for one second, then down for one second.
Each `stroke` groups points made without lifting the pen. A `pt` contains
`x` and `y` coordinates and a `time` in seconds. Here, coordinates use a
normalized 0–1 canvas; the environment records its size and orientation.

```xml
<gml spec="1.0">
  <tag>
    <header>
      <client><name>GML example</name></client>
      <environment>
        <screenBounds><x>1</x><y>1</y><z>0</z></screenBounds>
        <up><x>0</x><y>1</y><z>0</z></up>
      </environment>
    </header>
    <drawing>
      <stroke>
        <pt><x>0.1</x><y>0.2</y><time>0</time></pt>
        <pt><x>0.8</x><y>0.2</y><time>1</time></pt>
        <pt><x>0.8</x><y>0.8</y><time>2</time></pt>
      </stroke>
    </drawing>
  </tag>
</gml>
```

## Specifications and tools

- [GML 1.0 specification (archived)](https://web.archive.org/web/20221225193938/http://graffitimarkuplanguage.com/):
  the original specification site is offline.
- [GML validator](/validator): inspect a file's strokes, points and capture metadata.
- [Sample playback code](gml/playback-implementations.md) and
  [JavaScript and JSON](gml/javascript-and-json.md): build a reader or renderer.
- [GML mailing list](https://groups.google.com/group/graffiti-markup-language).

## The Blackbook API

GML is the file format. The Blackbook API is the separate service for sharing
those files. Read the [API documentation](api/README.md) to
[download](api/downloading-gml.md) or [upload](api/uploading-gml.md) drawings.
The [OpenAPI specification](/openapi.yaml) describes the HTTP endpoints.

