MCPcopy Create free account
hub / github.com/ActiveState/code / Graphics

Class Graphics

recipes/Python/578004_processing/recipe-578004.py:39–64  ·  view source on GitHub ↗

Graphics(canvas) -> Graphics

Source from the content-addressed store, hash-verified

37################################################################################
38
39class Graphics:
40
41 "Graphics(canvas) -> Graphics"
42
43 __slots__ = 'canvas'
44
45 def __init__(self, canvas):
46 "Initializes graphics by wrapping a canvas."
47 self.canvas = canvas
48
49 def draw(self, polygon, fill, outline):
50 "Draws a polygon on the underlying canvas."
51 self.canvas.create_polygon(*itertools.chain(*polygon.vertices),
52 fill=fill, outline=outline)
53
54 def write(self, x, y, text, fill):
55 "Writes the text to bottom-left of location."
56 self.canvas.create_text(x, y, text=text, fill=fill, anchor=tkinter.NW)
57
58 def clear(self):
59 "Clears canvas of all objects shown on it."
60 self.canvas.delete(tkinter.ALL)
61
62 def fill(self, background):
63 "Fills in the canvas with the given color."
64 self.canvas.configure(background=background)
65
66################################################################################
67

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected