PIDDLE: A Python Graphics API
While working on this book, we tried to create a printing system that could handle multiple formats, including Windows and PDF. At the same time, several people in the Python newsgroup felt that it was a real pity everyone was using platform-specific code to draw charts and diagrams, and that it should be possible to come up with a common API that covered several output formats. A team of four— Joe Strout, Magnus Hetland, Perry Stoll, and Andy Robinson—developed a common API during the spring of 1999, and a number of backends and a test suite are available at press time. This has produced some powerful printing solutions, which we explore here.
The API is known as Plug-In Drawing, Does Little Else (PIDDLE) and is
available from
http://www.strout.net/python/piddle/. The
package includes the basic API, test patterns, and as many backends
as are deemed stable. The basic API defines classes to represent
fonts and colors, and a base class called
Canvas
, which exposes several drawing methods.
The base canvas doesn’t produce any output and exists to define
an interface; specific backends implement a canvas to draw on the
relevant device or file format.
Let’s quickly run through the main features of the PIDDLE API.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access