-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrender.py
39 lines (30 loc) · 944 Bytes
/
render.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
39
import turtle
class Render(turtle.Turtle):
def __init__(self, objects=None) -> None:
super().__init__(visible=False)
self.speed(0)
self.objects = objects or []
self.screen = self.getscreen()
self.update(self.objects)
def update(self, objects=None):
self.screen.tracer(0)
objects = objects or self.objects
self.clear()
for object in objects:
if object.type == "start": continue
self.draw(object)
self.screen.tracer(1)
def draw(self, object):
self.color(object.color)
self.pu()
points = object.boundingbox()
self.goto(points[0])
self.pd()
self.begin_fill()
for point in points[1:]:
self.goto(point)
self.goto(points[0])
self.end_fill()
if __name__ == "__main__":
from main import Main
Main()