.. a7 Graphics Polygon class .. _gpolygon-label: Class GPolygon ============== This class represents a solid polygon to draw on the screen. The polygon is a triangle fan from the center of the polyon to the vertices in the attribute ``points``. The center of the polygon is always the point (0,0), unless you reassign the attributes ``x`` and ``y``. However, as with :ref:`GPath <gpath-label>`, if you assign the attributes ``x`` and ``y``, then Python will shift all of the vertices by that same amount. Hence the polygon vertices must be defined as triangle fan centered at the origin. 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. The polygon may also be textured by specifying a source image. The texture coordinates of each vertex will be relative to the size of the image. For example, if the image is 64x64, then the quad polygon (-32,-32,-32,32,32,32,32,-32) will be a rectangle equal to the image. You can adjust the size of the source image with the attributes ``source_width`` and ``source_height``. If the polygon is larger than the image, then the texture will repeat. As with :ref:`GPath <gpath-label>`, the attributes ``width`` and ``height`` are immutable, and are computed directly from the points. Constructor ----------- .. autoclass:: game2d.GPolygon Attributes ---------- This class does not have any attributes beyond those defined in :ref:`GPath <gpath-label>`. Methods ------- This class has all of the methods of :ref:`GPath <gpath-label>`. In addition, it has the following altered method. .. currentmodule:: game2d .. automethod:: GPolygon.contains :ref:`Return to top level <top-label>`