>>> from polygon import Polygon >>> pol = Polygon((255, 0, 0), []) >>> from point import Point >>> pol.add(Point(-5, -5)) >>> pol.add(Point(-5, 5)) >>> pol.add(Point(0, -2.5)) >>> len(pol) 3 >>> pol.color (255, 0, 0) >>> str(pol[0]) 'Point (-5, -5)' >>> str(pol) 'Polygon of 3 vertices' >>> pol1 = Polygon((255, 0, 0), [Point(-5, -5), Point(-5, 5), Point(0, -2.5)]) >>> pol1 == pol True >>> pol2 = Polygon((255, 0, 0), [Point(1, 2), Point(2, 3), Point(1.5, 3.7)]) >>> pol1 == pol2 False >>> str(pol2) 'Polygon of 3 vertices' >>> d = pol2.to_dict() >>> d == {'vertices': [{'x': 1, 'y': 2}, {'x': 2, 'y': 3}, {'x': 1.5, 'y': 3.7}], 'color': [255, 0, 0]} True >>> pol3 = Polygon.from_dict(d) >>> len(pol3) 3 >>> str(pol3[0]) 'Point (1, 2)' >>> str(pol3[1]) 'Point (2, 3)' >>> str(pol3[2]) 'Point (1.5, 3.7)'