# AnnotationSketch code examples

## Using AnnotationSketch to draw annotations from a file

The following code examples (in C and Lua) illustrate how to produce an image from a given GFF3 file using AnnotationSketch. The result is shown in Fig. 7. In essence, these code examples implement something like a simple version of the `gt sketch` tool from GenomeTools without most command-line options.

Figure 7: Example rendering of a GFF3 file with default style.

#### C code

(See `src/examples/sketch_parsed.c` in the source distribution.)

#### Lua code

(See `gtscripts/sketch_parsed.lua` in the source distribution. This example can be run by the command line `gt gtscripts/sketch_parsed.lua <style_file> <PNG_file> <GFF3_file>`)

#### Ruby code

(See `gtruby/sketch_parsed.rb` in the source distribution.)

#### Python code

(See `gtpython/sketch_parsed.py` in the source distribution.)

## Using AnnotationSketch to draw user-generated annotations

The following C code example illustrates how to produce an image from annotation graphs created by user code. The result is shown in Fig. 8.

Figure 8: Example rendering of user-generated annotations with default style.

#### C code

(See `src/examples/sketch_constructed.c` in the source distribution.)

#### Lua code

(See `gtscripts/sketch_constructed.lua` in the source distribution. This example can be run by the command line `gt gtscripts/sketch_constructed.lua <style_file> <PNG_file>`)

#### Ruby code

(See `gtruby/sketch_constructed.rb` in the source distribution.)

#### Python code

(See `gtpython/sketch_constructed.py` in the source distribution.)