闲来无事用海龟绘图画了一个科比的图标,画的比较简陋,有问题欢迎斧正。
话不多说,成品如下(加了个背景)。其中手为科比手是个背景图片,字体和图案为海龟所画。
代码如下:
import turtle
def top(x1,y1,s1,s2): #标志最上边的两个图形
turtle.penup() #抬笔
turtle.goto(x1,y1) #海龟爬到这个坐标,即落笔的地点
turtle.pendown() #落笔
turtle.begin_fill() #填充
turtle.fillcolor("#5c275e") #填充的颜色
turtle.setheading(90) #海龟朝向90°的方向
turtle.forward(32) #海龟爬的距离为32
if x1==-46: #因为用的是left和right,有对称的图像,所以加了个判断,判断是左边还是右边的一个图形
turtle.left(67) #海龟左转67度
else:
turtle.right(67)
turtle.forward(87)
if x1==-46:
turtle.left(52)
else:
turtle.right(52)
turtle.forward(20)
turtle.goto(x1,y1)
turtle.end_fill()#结束填充
def mid(x2,y2,s1,s2,s3):
turtle.penup()
turtle.goto(x2, y2)
turtle.pendown()
turtle.begin_fill()
turtle.fillcolor("#5c275e")
turtle.setheading(s1)
turtle.forward(115)
turtle.setheading(s2)
turtle.forward(35)
turtle.setheading(s3)
turtle.forward(83)
turtle.goto(x2,y2)
turtle.end_fill()
def