-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanimations.py
More file actions
30 lines (24 loc) · 1021 Bytes
/
animations.py
File metadata and controls
30 lines (24 loc) · 1021 Bytes
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
"""Contains animations to be used by graphics."""
from turtle import RawPen, _CFG
class Arrow(RawPen):
"""Specialized 'RawPen' that draws arrows from one peg to another."""
def __init__(self, graphics):
"""Initialize self. See help(type(self)) for accurate signature."""
self.graphics = graphics
super().__init__(self.graphics.canvas, "arrow", _CFG["undobuffersize"],
True)
self.pen(pendown=False, speed=0, pencolor="green", fillcolor="green",
pensize=2)
self.goto(self.graphics.HADES)
def draw(self, origin, destination):
"""Draws arrow from 'origin' to 'destination'."""
self.goto(origin)
self.setheading(self.towards(destination))
self.pendown()
self.dot(10, "green")
self.goto(destination)
def banish(self):
"""Clears drawings and sends arrow back to Hades."""
self.clear()
self.penup()
self.goto(self.graphics.HADES)