UV

About Projects

PyAmanith

Released: September 2006
Category: Python Library

PyAmanith is a Python wrapper for the Amanith 2D vector graphics library. It strives to offer a pythonic interface to the library and make all its features accessible.

Download

The current release is 0.3.35, which requires Amanith 0.3. This version fixes a compilation error on GCC 4.x.

Installing

In order to compile the wrapper, you'll need to have at least version 1.3.29 of SWIG installed. The code generated by SWIG should work on most compilers, but for reference I've used GCC 4.0 and Microsoft Visual Studio .NET 2003 (VS 7.1).

  1. Compile and install Amanith as instructed in its documentation.
  2. Run python setup.py install to build and install the wrapper.
  3. Optional: Run python test.py to test the wrapper's functionality.

Example

Here's a short example that draws a red heart on a white background. It requires PyGame and PyOpenGL.

import amanith, pygame, sys, time
from OpenGL.GL import *

pygame.display.init()
pygame.display.set_mode((640, 480), pygame.OPENGL | pygame.DOUBLEBUF)

drawboard = amanith.GOpenGLBoard(0, 0, 640, 480)

keys = [
amanith.GKeyValue(0.0, (1.0, 0.0, 0.0, 1.0)),
amanith.GKeyValue(0.5, (1.0, 1.0, 1.0, 1.0)),
amanith.GKeyValue(1.0, (1.0, 0.0, 0.0, 1.0)),
]

grad = drawboard.CreateLinearGradient((360, 100), (320, 300), keys)

drawboard.SetFillEnabled(True)
drawboard.SetStrokeEnabled(True)
drawboard.SetStrokeWidth(8)
drawboard.Clear(1.0, 1.0, 1.0, True)
drawboard.SetFillPaintType(amanith.G_GRADIENT_PAINT_TYPE)
drawboard.SetFillGradient(grad)
drawboard.DrawPaths("M 320,360 c +250,+100 +250,-175 0,-300 c -250,+100 -250,+400 0,300 z")

pygame.display.flip()
time.sleep(10)

Documentation

Currently the best documentation for the wrapper is Amanith's API reference.
« Back to all projects