-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdml_render.py
More file actions
28 lines (16 loc) · 748 Bytes
/
dml_render.py
File metadata and controls
28 lines (16 loc) · 748 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
import turtle
def render(file_name):
pen = turtle.Pen()
if '.' in file_name:
if file_name.split('.')[1] == 'dml':
for line in open(file_name,'r').read().split('\n'):
if line.startswith('<forward>') and line.endswith('</forward>'):
pen.forward(int(line.split('>')[1].split('</')[0]))
if line.startswith('<backward>') and line.endswith('</backward>'):
pen.backward(int(line.split('>')[1].split('</')[0]))
if line.startswith('<left>') and line.endswith('</left>'):
pen.left(int(line.split('>')[1].split('</')[0]))
if line.startswith('<right>') and line.endswith('</right>'):
pen.right(int(line.split('>')[1].split('</')[0]))
file_name = input('Enter file name: ')
render(file_name)