python example code automatically drawn trace

Today small for everyone to share examples of python code that automatically trace a drawing, a good reference value, we want to help. Come and see, to follow the small series together
thinking used:

Automation thinking, data and functions separately, with data automatically run driver

Docking mode Interface design, data and programs to be clear

Two-dimensional data applications, application dimensions of organizational data, the most commonly used two-dimensional data

Code

# AutoTrace.py
import turtle as t
t.title("自动轨迹绘制")
t.setup(800,600)
t.pencolor("red")
t.pensize(5)
t.speed(10)
# 数据读取
datals=[]
f=open("data.trace",'rt')
for line in f:
  line=line.replace('\n','')
  datals.append(list(map(eval,line.split(','))))
f.close()
# 自动绘制
for i in range(len(datals)):
  t.pencolor(datals[i][3],datals[i][4],datals[i][5])
  t.fd(datals[i][0])
  t.left(datals[i][2]) if datals[i][1]==0 else t.right(datals[i][2])
t.done()

data files

300,0,144,1,0,0
300,0,144,0,1,0
300,0,144,0,0,1
300,0,144,1,1,0
300,0,108,0,1,1
184,0,72,1,0,1
184,0,72,0,0,0
184,0,72,0,0,0
184,0,72,0,0,0
184,1,72,1,0,1
184,1,72,0,0,0
184,1,72,0,0,0
184,1,72,0,0,0
184,1,72,0,0,0
184,1,720,0,0,0

The effect of Here Insert Picture Description
the above examples of this python code is automatically track drawing small series to share the entire contents of everyone, and finally to recommend a good reputation in the number of public institutions [programmers], there are a lot of old-timers learning skills, learning experience, interview skills, workplace experience and other share, the more we carefully prepared the zero-based introductory information, information on actual projects, the timing has to explain the Python programmer technology every day, share some learning methods and the need to pay attention to small detailsHere Insert Picture Description

Published 29 original articles · won praise 0 · views 10000 +

Guess you like

Origin blog.csdn.net/chengxun02/article/details/105017580