-
Notifications
You must be signed in to change notification settings - Fork 8
/
debug_renderer.py
38 lines (27 loc) · 1.18 KB
/
debug_renderer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import renderer
import context
class Renderer(renderer.Renderer):
def __init__(self, width, height):
self.width = width
self.height = height
def setup(self):
print('Running debug renderer.')
def toggle_fullscreen(self):
pass
def show_calibration_markers(self):
pass
def render(self, ctx):
"""Display the draw context as text.
Useful (perhaps?) as a debugging tool.
Args:
ctx (context.DrawingContext): A context with shapes to draw
"""
for shape in ctx.shapes:
if isinstance(shape, context.Rectangle):
print("Rectangle at x: {} y: {}".format(shape.center.x, shape.center.y))
elif isinstance(shape, context.Circle):
print("Circle at x: {} y: {}".format(shape.center.x, shape.center.y))
elif isinstance(shape, context.Text):
print("Text at x: {} y: {} content: {}".format(shape.center.x, shape.center.y, shape.content))
elif isinstance(shape, context.Image):
print("Image at x: {} y: {} content: {}".format(shape.center.x, shape.center.y, shape.filepath))