### Drawing with IMDrawable and IMGraphic

The class IMDrawable, the abstract base class for IMGraphic, abstracts the common drawing behavior of the class. This class is useful if you are interested only in the draw function (as for printing) and do not want to provide overloaded functionality for primitives.

IMDrawable has a pure virtual draw function that is implemented in the IMGraphic derived classes. All IMGraphics draw onto the IGrafPort passed to IMGraphic as a parameter. Besides the state information encapsulated by the IGrafPort , the IMGraphic object itself contains all other information needed to render the graphic. This information includes the geometry, attribute bundle and any transformation information. This member function is an abstract const, so that subclasses of IMGraphic can cache expensive drawing information such as bounds. Concrete subclasses must implement the draw member function.

virtual void draw(IGrafPort& port) const = 0

All IMGraphics draw synchronously and do not handle simple updating or animating requirements. If you need this functionality, you must create subclasses providing such behavior.

When drawing primitives as a collection, such as in a list of IMDrawable objects, the drawing sequence is the same as it would be when draw calls are made on the specified IGrafPort. Thus drawing a polygon and an ellipse renders differently depending upon the order in which they are rendered.

NOTE: The IGrafPort you pass to this member function is a passive iterator which is acted upon by the IMGraphic object to which it is passed. The IMGraphic object elaborates itself to the IGrafPort in terms of the 2D primitive set. IGrafPort does not have to be a rendering port.

Creating a Graphics Class