Class GScene

This class represents a node in a scene graph. A scene graph node is just a collection of GObjects. By placing them in the scene graph node, you can rotate and translate them all at once. Scene graphs are a sophisticated concept that allow you to do advanced animation.

As GScene is a subclass of GObject you can nest scene graph nodes inside of other scene graph nodes. The result is a tree structure.

The attributes width and height are present in this object, but they are now read-only. These values are computed from the list of GObjects stored in the scene.

All GObjects stored in a GScene are drawn as if the point (x,y) is the origin.

Constructor

GScene(**keywords)

Constructor: Creates a new scene graph node

To use the constructor for this class, you should provide it with a list of keyword arguments that initialize various attributes. The keywords are the same as the attribute names. For example, to create a scene with shapes rect, tri, and circ, call the constructor

GScene(children=[rect,tri,circ])

This class supports the same keywords as GObject, though some of them are unused, as the width and height attributes are now immutable.

Parameter:keywords – dictionary of keyword arguments

Precondition: See below.

Attributes

This class has all of the attributes of GObject. In addition, it has the following new or altered attributes.

children

The list of GObjects stores in this scene.

The objects are drawn as if (x,y) is the origin. Therefore, changing the attributes x and y will shift all of the children on the screen.

Invariant: Must be a list or tuple of GObjects (possibly empty)

width

The horizontal width of this path.

The value is the width of the smallest bounding box that contains all of the objects in this scene (and the center)

Immutable: This value is computed from the width of the children.

Invariant: Must be an int or float > 0.

height

The vertical height of this path.

The value is the height of the smallest bounding box that contains all of the objects in this scene (and the center)

Immutable: This value is computed from the height of the children.

Invariant: Must be an int or float > 0.