Prev Up Next
Class Hierarchy The Document and Graphics Classes The class Bounded

The class GraphicsObject

Base Classes: Bounded, HierarchyNode, Selectable and Protocols.

The class GraphicsObject defines the interface common to all graphics objects.

For convenience of implementation, and because their interfaces are needed elsewhere in the class hierarchy as well, some parts of this interface are defined by the base classes:


provides instance variables for the vertical and horizontal dimensions of a graphics object and some related methods.


provides the default behavior for all methods related to the management of the object hierarchy in the document.


defines the generic interface and default behavior for selection.


has some variables that describe the object's capabilities.

Instance Variables

GraphicsObject maintains no instance variables of its own, but uses those managed by its base classes.


Methods defined in GraphicsObject:

Blend(other, frac1, frac2)

Return the weighted average of self and other. frac1 and frac2 are the weights (if self and other were numbers this should be frac1 * self + frac2 * other).

This method is used by the function Blend in If self and other can't be blended, raise the blend.Mismatch exception. This is the default behavior.


Return self as a PolyBezier object if possible. If this is not possible, return None.

The following methods are not implemented in GraphicsObject directly, but must be defined for every graphics object. The derived classes Primitive and Compound provide a default implementation for most objects.


Apply the transformation object trafo to self. Return undo info.


Translate (move) self by offset. offset is a point object. Return undo info.

DrawShape(device [, clip])

Draw self on device. device is a graphics device .

The optional parameter clip is only provided if the object is used as a clip mask. If it is provided its value is 1. Objects that can be used as clip masks (their is_clip flag is true) request appropriate clipping from the graphics device. Objects that cannot be used as clip masks don't need to accept it.

(Note: The clipping interface for the high level drawing operations of the graphics devices is somewhat experimental)


Save self to file. The argument file is currently an instance of the class SKSaver which provides special methods for the object types currently implemented in Sketch.

Class Hierarchy The Document and Graphics Classes The class Bounded
Prev Up Next