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¶
- class game2d.GTriangle(**keywords)¶
A class representing a solid triangle.
The triangle is defined as a sequence of three point. Just as with the GPath class (which is the parent of this class), it has an attribute point which represents this 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
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.
- GTriangle.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.
- Parameters
point (
Point2`
or a pair of numbers) – the point to check- Returns
True if the shape contains this point
- Return type
bool