学习Python中turtle模块的基本用法(5:绘制简笔画羊) 您所在的位置:网站首页 简单的简笔画画动物 学习Python中turtle模块的基本用法(5:绘制简笔画羊)

学习Python中turtle模块的基本用法(5:绘制简笔画羊)

2024-07-11 22:44| 来源: 网络整理| 查看: 265

  人已阳,准备画个喜羊羊纪念一下,但是喜羊羊头上的卷太多了,不太好画,于是找了参考文献1的普通的简笔画羊,使用Python中的turtle模块绘制(采用参考文献3中绘制云朵的代码绘制羊身体)。   绘制简笔画羊的代码及效果图如下所示: 在这里插入图片描述

import turtle as t def 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]https://jingyan.baidu.com/article/6c67b1d6e80bd26687bb1e9f.html [2]https://docs.python.org/zh-cn/3/library/turtle.html [3]https://blog.csdn.net/Jane_Eyre111/article/details/121563066



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有