Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# Canvas Module

The canvas module provides a highly optimized 2D graphic area called TQCanvas. The canvas can contain an arbitrary number of TQCanvasItems. Canvas items can have an arbitrary shape, size and content, can be freely moved around in the canvas, and can be checked for collisions. Canvas items can be set to move across the canvas automatically and animated canvas items are supported with TQCanvasSprite. (If you require 3D graphics see TQt's OpenGL module.)

The canvas module uses a document/view model. The TQCanvasView class is used to show a particular view of a canvas. Multiple views can operate on the same canvas at the same time. Every view can use an arbitrary transformation matrix on the canvas which makes it easy to implement features such as zooming.

TQt provides a number of predefined TQCanvas items as listed below.

- TQCanvasItem -- An abstract base class for all canvas items.
- TQCanvasEllipse -- An ellipse or "pie segment".
- TQCanvasLine -- A line segment.
- TQCanvasPolygon -- A polygon.
- TQCanvasPolygonalItem -- A base class for items that have a non-rectangular shape. Most canvas items derive from this class.
- TQCanvasRectangle -- A rectangle. The rectangle cannot be tilted or rotated. Rotated rectangles can be drawn using TQCanvasPolygon.
- TQCanvasSpline -- A multi-bezier spline.
- TQCanvasSprite -- An animated pixmap.
- TQCanvasText -- A text string.

The two classes TQCanvasPixmap and TQCanvasPixmapArray are used by TQCanvasSprite to show animated and moving pixmaps on the canvas.

More specialized items can be created by inheriting from one of the canvas item classes. It is easiest to inherit from one of TQCanvasItem's derived classes (usually TQCanvasPolygonalItem) rather than inherit TQCanvasItem directly.

See `examples/canvas` for an example that shows off some of TQCanvas's capabilities.