Using fig


Fig comes with a few code examples, in the /usr/share/doc/fig/examples filepath. You can view them with this command:

geany /usr/share/doc/fig/examples

To compile one of the examples, try giving these lines at the console:

fig29.py /usr/share/doc/fig/examples/nestloops.fig
/usr/share/doc/fig/examples/nestloops.fig.py

The first line compiles (translates) nestloops.fig to nestloops.fig.py, and the second line runs the resulting Python script.

The main difference between fig29.py and fig31.py is the first one runs in Python 2, and produces scripts for Python 2; while fig31.py runs in Python 3 and produces Python 3 scripts.

The feature sets of these are almost identical: fig 3.1 in addition to the features of previous verions, has a neat help feature:

fig31.py help

...and also has a function named "command" (taken from basic) which gets arguments from the command line. But you can create a compatible command in fig 2.9 like this:

#### license: creative commons cc0 1.0 (public domain) 
#### http://creativecommons.org/publicdomain/zero/1.0/
function cmd
python
    from sys import argv as figargv ; return figargv[1:]
    fig
    fig

The rest of the information you get from the help feature in fig 3.1 will be valid for fig 2.9.

You can also try the 4 fig utilities in /usr/bin by compiling them with fig31.py:

for p in /usr/bin/*.fig ; do fig31.py $p ; done | grep py

One of those programs is called arrname.fig and can be used this way:

find /usr/share/doc/fig/examples | arrname.fig.py 1 

...will show the file paths of all the entries under /usr/share/doc/fig/examples (this is more useful on a path with more subfolders.)

find /usr/share/doc/fig/examples | arrname.fig.py 2 

...will show the file names of all the entries under /usr/share/doc/fig/examples. And:

find /usr/share/doc/fig/examples | arrname.fig.py 3 

...will show the file extensions of all the entries under /usr/share/doc/fig/examples.

The find command lists entries in this format:

filepath / filename . extension (If there is an extension.)


Graphics in fig

Fig is capable of producing graphics with pygame. By default, if pygame is not installed then fig will emulate graphics in the term using ANSI escapes and unicode.

Installing pygame is trivial for fig 2.x and Python 2: sudo apt-get install python-pygame ...for fig 3.x you will need the version of pygame for Python 3 (you can install both):

> How-to-install-pygame-for-Python-3


< Learn-about-the-fig-programming-language

<< Fig OS Manual