This repository was archived by the owner on Jan 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathturtle.py
More file actions
63 lines (44 loc) · 1.5 KB
/
turtle.py
File metadata and controls
63 lines (44 loc) · 1.5 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from pyscript import document, window
class Turtle:
def __init__(self):
canvas = document.createElement("canvas")
canvas.id = "canvas"
document.body.prepend(canvas)
self.turtle = window.getTurtle("canvas")
async def forward(self, distance):
await self.turtle.forward(distance)
async def backward(self, distance):
await self.turtle.backward(distance)
async def left(self, angle):
await self.turtle.left(angle)
async def right(self, angle):
await self.turtle.right(angle)
async def goto(self, x, y):
await self.turtle.goto(x, y)
async def circle(self, radius):
await self.turtle.circle(radius, 360)
async def width(self, width):
self.turtle.width(width)
async def color(self, *args):
self.turtle.color(*args)
async def pencolor(self, *args):
self.turtle.color(*args)
async def fillcolor(self, *args):
self.turtle.fillcolor(*args)
async def begin_fill(self):
self.turtle.begin_fill()
async def end_fill(self):
self.turtle.end_fill()
async def penup(self):
self.turtle.penup()
async def pendown(self):
self.turtle.pendown()
async def speed(self, speed):
self.turtle.speed(speed)
async def shape(self, shape):
self.turtle.shape(shape)
class Screen:
def __init__(self):
self.turtle = window.getTurtle("canvas")
def bgcolor(self, *args):
self.turtle.bgcolor(*args)