Class GTriangle

This class represents a solid triangle to draw on the screen. The triangle is defined as a sequence of three points. Just as with the GPath class (which is the parent of this class), it has an attribute points which represents these points as an even-length sequence of ints or floats.

The interior (fill) color of this triangle is fillcolor, while linecolor is the color of the border. If linewidth is set to 0, then the border is not visible.

As with GPath, the attributes x and y may be used to shift the triangle position. By default, these values are 0. However, if they are nonzero, then Python will add them to the triangle vertices. Similarly, the attributes width and height are immutable, and are computed directly from the points

Constructor

GTriangle(**keywords)

Creates a new solid triangle.

To use the constructor for this class, you should provide it with a list of keyword arguments that initialize various attributes. For example, to create a red triangle with vertices (0,0), (2,3), and (0,4), use the constructor call:

GTriangle(points=[0,0,2,3,0,4],fillcolor=colormodel.RED)

As with GPath the width and height attributes of this class are both immutable. They are computed from the list of points.

Parameter:keywords (keys are attribute names) – dictionary of keyword arguments

Attributes

This class does not have any attributes beyond those defined in GPath.

Methods

This class has all of the methods of GPath. In addition, it has the following altered method.

contains(point)

Checks whether this shape contains the point

By default, this method just checks the bounding box of the shape.

Warning: Using this method on a rotated object may slow down your framerate.

Parameter:point (Point2` or a pair of numbers) – the point to check
Returns:True if the shape contains this point
Return type:bool

Return to top level