def rect(self, rect: ZRect, color: Any, width: int = 1) -> None: """Draw a rectangle.""" if not isinstance(rect, RECT_CLASSES): raise TypeError("screen.draw.rect() requires a rect to draw") self._messages.append( serialize_json_message("draw.rect", make_color(color), (rect.x, rect.y, rect.w, rect.h), width))
def filled_circle(self, pos: Tuple[Any, Any], radius: float, color: Any) -> None: """Draw a filled circle.""" pos = round_pos(pos) self._messages.append( serialize_json_message("draw.circle", (make_color(color), pos, radius, 0)))
def circle(self, pos: Tuple[Any, Any], radius: float, color: Any, width: int = 1) -> None: """Draw a circle.""" pos = round_pos(pos) self._messages.append( serialize_json_message("draw.circle", (make_color(color), pos, radius, width)))
def polygon(self, points: List[Tuple[Any, Any]], color: Any) -> None: """Draw a polygon.""" try: iter(points) except TypeError: raise TypeError( "screen.draw.filled_polygon() requires an iterable of points to draw" ) from None # noqa points = [round_pos(point) for point in points] self._messages.append( serialize_json_message("draw.polygon", (make_color(color), points, 1)))
def line(self, start: Tuple[Any, Any], end: Tuple[Any, Any], color: Any, width: int = 1) -> None: """Draw a line from start to end.""" start = round_pos(start) end = round_pos(end) self._messages.append( serialize_json_message("draw.line", (make_color(color), start, end, width)))