The canvas provides several predefined item types, including lines, rectangles, and text. However, the canvas is designed to serve as a general-purpose display engine. Applications can define their own custom item types that integrate with the rest of the canvas framework. This lets them have a flicker-free display engine with proper event management and propagation.
The canvas supports two rendering models. One is based directly on Xlib (used via GDK), which provides an extremely fast and lean display that runs well over networks. The second rendering model is based on Libart, a sophisticated library for manipulating and rendering vector paths using antialiasing and alpha compositing. Libart provides a superset of the PostScript imaging model, allowing for extremely high-quality displays.
Simple applications can use the predefined canvas item types to create interactive graphics displays. For example, the GNOME Calendar program uses the canvas to display and manipulate monthly calendars. It only needs simple graphical items like rectangles and text to display its information. Please look at Figure 1 for an example of the use of the canvas in the GNOME Calendar.
Applications with more sophisticated requirements can define their custom canvas item types. The Gnumeric spreadsheet defines a large ‘Sheet’ item that takes care of painting the sheet's grid and the cell contents. It also defines an item to handle the complex cursor object in the spreadsheet, which must handle the current selection, the current cell, and the border items to drag and extend selections. Please look at Figure 2 for an example of the use of the canvas in the Gnumeric spreadsheet.
This tutorial describes the architecture of the GNOME canvas and Libart. It gives examples on why application writers may want to use these technologies.