Class GPoint

GPoint(x=0, y=0)

Instances are a Point in 2D space.

This class is used primarily for recording and handling mouse locations.

Constructor: creates a new GPoint value (x,y).

param x:initial x value

Precondition: value is an int or float.

param y:initial y value

Precondition: value is an int or float.

All values are 0.0 by default.

Attributes

x

The x coordinate of the point.

Invariant: Must be an int or float.

y

The y coordinate of the point.

Invariant: Must be an int or float.

Methods

The class GPoint has overloaded the operations + and - to allow point point addition and subtraction. It also supports scalar multiplication via * on both the right and the left.

list()

Returns: A python list with the contents of this GPoint.

interpolate(other, alpha)

Returns: the interpolation of self and other via alpha.

The value returned has the same type as self (so it is either a GPoint or is a subclass of GPoint). The contents of this object are not altered. The resulting value is

alpha*self+(1-alpha)*other

according to GPoint addition and scalar multiplication.

param other:tuple value to interpolate with

Precondition: value has the same type as self.

param alpha:scalar to interpolate by

Precondition: value is an int or float.

distanceTo(other)

Returns: the Euclidean distance from this point to other

Parameters:other – value to compare against

Precondition: value is a GPoint object.

Table Of Contents

Previous topic

Graphics Objects

Next topic

Class GObject

This Page