三只小狗被关在门内,门坏了有一个洞,它们一起探出头来看外面的世界。
外面的世界多精彩啊,不知道主人什么时候会回来。
这是用Python的海龟模块绘制一个三狗看世界的源代码。
由于进行了抽象分析,所以并不是逐像素绘制,
分辨率没有那么高哦,具体见下面的gif图形,有着类似水彩画的效果。
以下是部分代码,需要完整代码请联系本人微信scratch8。
import sys
import time
import turtle
def make_rnd_string():
digits = str(time.time())[-1:-4:-1]
name = time.strftime("%Y_%m_%d-%H.%M.%S")+ digits
return name
def draw_poly(downflag,iid,fill_flag,fc,pc,pz,points,scale=1):
'''根据参数画多边形,downflag落笔标志
iid: 编号,没有则是空, fill_flag:填充标志, fc:填充颜色,
pc:画笔颜色,pz:画笔线宽,points_坐标序列'''
turtle.pencolor(pc)
turtle.pensize(pz)
turtle.penup()
x ,y = points[0]
turtle.goto(scale*x,scale*y)
if downflag:turtle.pendown() # 如果落笔标志为真,则落笔
if fill_flag:
turtle.fillcolor(fc)
turtle.begin_fill()
for x,y in points[1:]:
turtle.goto(scale*x,scale*y)
if fill_flag:
turtle.end_fill()
turtle.penup()
turtle.speed(0)
turtle.delay(0)
turtle.hideturtle()
turtle.title(sys.argv[0])
screen = turtle.getscreen()
root = screen._root
scrwidth = root.winfo_screenwidth()
scrheight = root.winfo_screenheight()
screen.setup(scrwidth//2,scrheight - 50)
...........................................


