Class GObject

game2d.GObject(**keywords)

Instances provide basic geometry information for drawing to a GView

You should never make a GObject directly. Instead, you should use one of the subclasses: GRectangle, GEllipse, GLine, GTriangle, GPolygon, GImage, and GLabel.

Constructor: creates a new GObject to support drawing.

param keywords:dictionary of keyword arguments

Precondition: See below.

To use the constructor for this class, you should provide it with a list of keyword arguments that initialize various attributes. For example, to initialize the x position and the fill color, use the constructor call

GObject(x=2,fillcolor=colormodel.RED)

You do not need to provide the keywords as a dictionary. The ** in the parameter keywords does that automatically.

Any attribute of this class may be used as a keyword. The argument must satisfy the invariants of that attribute. See the list of attributes of this class for more information.

Attributes

x

The horizontal coordinate of the left hand side.

Invariant: Must be an int or float. It is equivalent to attribute left.

y

The vertical coordinate of the bottom.

Invariant: Must be an int or float. It is equivalent to attribute bottom.

left

The horizontal coordinate of the left hand side.

Invariant: Must be an int or float. It is equivalent to attribute x.

right

The horizontal coordinate of the right hand side.

Invariant: Must be an int or float. It is equivalent to x+width.

bottom

The vertical coordinate of the bottom.

Invariant: Must be an int or float. It is equivalent to attribute y.

top

The vertical coordinate of the bottom.

Invariant: Must be an int or float. It is equivalent to y+height.

center_x

The horizontal center of this shape.

Invariant: Must be an int or float. It is equivalent to x+width/2

center_y

The vertical center of this shape.

Invariant: Must be an int or float. It is equivalent to y+height/2

linecolor

The object line color.

Used to color the foreground, text, or, in the case of solid shapes, the shape border.

Invariant: Must be a 4-element list of float between 0 and 1. If you assign it a RGB or HSV object from module colormodel, it will convert the color for your automatically.

fillcolor

The object fill color.

Used to color the backgrounds or, in the case of solid shapes, the shape interior.

Invariant: Must be a 4-element list of float between 0 and 1. If you assign it a RGB or HSV object from module colormodel, it will convert the color for your automatically.

Methods

contains(x, y)

Return: True if this shape contains the point (x,y), False otherwise.

param x:x coordinate of point to check

Precondition: an int or float

param y:y coordinate of point to check

Precondition: an int or float

This method always returns False for a GObject.

draw(view)

Draw this shape in the provide view.

param view:view to draw to

Precondition: an instance of GView

Ideally view should be the one provided by Game.

Table Of Contents

Previous topic

Class GPoint

Next topic

Class GLine

This Page