Draw Triangles and Other Polygons in Python Graphics
Students can now draw triangles, stars, and any other multi-sided shape in Python graphics with the new Polygon shape.
Students building Python graphics projects like Tell a Story! kept asking how to draw a triangle. Until now, the answer was to piece one together from separate lines. That workaround is gone.
Python graphics now includes a Polygon shape. Students create a polygon, add one point for each corner, and add it to the canvas like any other shape:
tri = Polygon()
tri.add_point(100, 250)
tri.add_point(300, 250)
tri.add_point(200, 60)
tri.set_color(Color.green)
add(tri)
Polygons work like the shapes students already know. They can change color, move with move or set_position, and be removed. Mouse clicks are detected inside the shape too, so polygons work in interactive programs and games. It matches the Polygon shape in JavaScript graphics, so classes that switch from JavaScript to Python don't lose it.