人已阳,准备画个喜羊羊纪念一下,但是喜羊羊头上的卷太多了,不太好画,于是找了参考文献1的普通的简笔画羊,使用Python中的turtle模块绘制(采用参考文献3中绘制云朵的代码绘制羊身体)。
绘制简笔画羊的代码及效果图如下所示:
import turtle as tdef drawBody():t.penup()t.setheading(-90)t.forward(-10)t.setheading(0)t.forward(45+40)t.pendown();t.setheading(80)t.circle(-15,180)t.setheading(80)t.circle(-15,180)t.setheading(80)t.circle(-10,180)t.setheading(80)t.circle(-18,180)t.setheading(80)t.circle(-20,180)t.setheading(30)t.circle(-10,180)t.setheading(0)t.circle(-20,180)t.setheading(-30)t.circle(-10,180)t.setheading(-45)t.circle(-15,180)t.setheading(-80)t.circle(-18,180)t.setheading(-90)t.circle(-10,180)t.setheading(-90)t.circle(-12,180)t.setheading(-110)t.circle(-15,180)t.setheading(-120)t.circle(-15,180)def drawHead():t.setheading(-45)t.forward(20)t.setheading(-145)t.circle(-15,90)t.setheading(85)t.forward(5)t.backward(50)t.setheading(-90)t.circle(-15,90)t.forward(25)t.circle(-50,80)t.setheading(80)t.forward(50)t.setheading(-145)t.circle(-15,90)t.setheading(-200)t.circle(-15,-90)t.penup()t.setheading(0)t.forward(25)t.right(90)t.forward(30)t.pendown()t.circle(5)t.penup()t.setheading(-30)t.forward(40)t.pendown()t.circle(5)t.penup()t.setheading(-180)t.forward(10)t.setheading(-120)t.forward(10) t.pendown()t.forward(10)t.right(120)t.forward(10)t.backward(10)t.setheading(-90)t.forward(15)def drawHair():t.penup()t.setheading(90)t.forward(90)t.setheading(180)t.forward(45)t.pendown();t.circle(-30,90)t.left(15)t.circle(-20,-90)t.penup()t.setheading(-5)t.forward(130)t.pendown();t.right(90)t.circle(-20,90)t.penup()t.circle(-20,-90)t.pendown();t.setheading(-240)t.circle(30,-120)t.penup()t.setheading(90)t.forward(60)t.setheading(180)t.forward(100)t.pendown();t.setheading(90)t.circle(-15,180)t.setheading(90)t.circle(-20,180)t.setheading(90)t.circle(-15,180)t.setheading(0)t.circle(-15,180)t.setheading(-90)t.circle(-15,180)t.setheading(-90)t.circle(-15,180)t.setheading(-90)t.circle(-10,180)t.setheading(0)t.circle(15,-150)def drawTail():t.penup()t.setheading(88)t.forward(60)t.setheading(0)t.forward(177)t.pendown();t.setheading(80)t.circle(-10,180)t.setheading(30)t.circle(-8,180)t.setheading(-80)t.circle(-10,180)def drawLegs():t.penup()t.setheading(-90)t.forward(60)t.setheading(-180)t.forward(177)t.pendown();t.setheading(-90)t.forward(60)t.left(90)t.forward(15)t.right(90)t.backward(50)t.forward(60)t.left(90)t.forward(15)t.left(90)t.forward(50)t.backward(35)t.setheading(0)t.backward(30)t.penup()t.setheading(90)t.forward(40)t.setheading(0)t.forward(100)t.pendown();t.pendown();t.setheading(-90)t.forward(50)t.left(90)t.forward(15)t.right(90)t.backward(50)t.forward(60)t.left(90)t.forward(15)t.left(90)t.forward(65)t.backward(50)t.setheading(0)t.backward(30)def drawGrass():t.color('black','green')t.penup()t.goto(-200,-50) t.pendown()t.begin_fill()t.setheading(75)t.forward(20)t.setheading(-75)t.forward(15)t.setheading(75)t.forward(15)t.setheading(-75)t.forward(15)t.setheading(75)t.forward(15)t.setheading(-75)t.forward(20)t.setheading(-180)t.forward(25)t.end_fill()t.penup()t.goto(200,-50)t.pendown()t.begin_fill()t.setheading(75)t.forward(20)t.setheading(-75)t.forward(15)t.setheading(75)t.forward(15)t.setheading(-75)t.forward(15)t.setheading(75)t.forward(15)t.setheading(-75)t.forward(20)t.setheading(-180)t.forward(25)t.end_fill()t.pensize(2)drawHead()drawHair()drawBody()drawTail()drawLegs()drawGrass()t.hideturtle()t.done()
参考文献:
[1]/article/6c67b1d6e80bd26687bb1e9f.html
[2]/zh-cn/3/library/turtle.html
[3]/Jane_Eyre111/article/details/121563066