python turtle绘图 中小学课堂教学 绘制一幅风景 太阳云朵 树 | 您所在的位置:网站首页 › 初学者丙烯画风景图 › python turtle绘图 中小学课堂教学 绘制一幅风景 太阳云朵 树 |
先看看成果图吧 非常适合教学使用,绘制不同图形的不同方法。 首先导入模块: import turtle t = turtle.Turtle() t.speed(50) #蓝天 s= turtle.Screen() s.bgcolor("#87cefa")一、画太阳,可以使用2种方法: 1、第一种: #移动到画太阳的位置 t.up() t.goto(-322,200) t.down() #绘制太阳 t.color("red") t.begin_fill() t.fillcolor("red") t.circle(20) t.end_fill() t.up() t.goto(-322,180) #绘制太阳光线 for i in range(9): t.up() t.circle(40,40) t.down() t.right(90) t.forward(10) t.backward(10) t.left(90)2、第二种: #绘制太阳法二 t.up() t.goto(-200,200) t.setheading(0) t.down() #太阳光线二 t.color("yellow") t.begin_fill() for i in range(12): t.forward(80) t.left(150) t.end_fill() t.up() t.goto(-160,190) t.setheading(0) t.down() #绘制太阳二 t.color("red") t.begin_fill() t.fillcolor("red") t.circle(20) t.end_fill() t.up() t.goto(-322,180) t.up() t.goto(70,180) t.down()二、绘制云朵,有3种画法: 1、第一种:通过圆弧的形式拼接而成 #绘制云朵一 t.color("white") t.begin_fill() t.setheading(90) t.circle(-5,180) t.setheading(90) t.circle(-10,180) t.setheading(90) t.circle(-5,180) t.setheading(0) t.circle(-10,180) t.setheading(-90) t.circle(-5,180) t.setheading(-90) t.circle(-5,180) t.setheading(-90) t.circle(-10,180) t.setheading(0) t.circle(10,-150) t.end_fill()第二种:通过画很粗的直线实现 #绘制云朵二 t.color("white") t.pensize(10) t.forward(30) t.goto(195,195) t.forward(40) t.goto(200,190) t.forward(40) t.goto(190,185) t.forward(40)第三种:通过画小点实现 t.color("white") t.dot(20) t.forward(12) t.dot(30) t.forward(15) t.dot(35) t.forward(12) t.dot(25)三、绘制草坪: #绘制草坪 t.pensize(2) t.up() t.goto(-430,-200) t.setheading(0) t.down() t.color("green") t.begin_fill() for i in range(10): t.circle(100,30) t.circle(-100,30) t.setheading(-10) t.goto(430,-300) t.goto(-430,-300) t.goto(-430,-200) t.end_fill()四:绘制树,树也有不同的画法: 第一种:画圆点的方式 #第一种棵树 t.up() t.goto(-144,-177) t.down() t.color("#473005") t.pensize(20) t.goto(-144,-80) t.color("#006400") t.dot(50) t.goto(-114,-80) t.dot(50) t.goto(-174,-80) t.dot(50) t.goto(-124,-50) t.dot(40) t.goto(-164,-50) t.dot(40) t.goto(-144,-25) t.dot(40)第二种画三角形的方式 #第二种树 t.up() t.goto(-30,-50) t.down() t.color('green') t.begin_fill() t.setheading(0) for i in range(3): t.forward(50) t.left(120) t.end_fill() t.forward(25) t.right(60) t.begin_fill() for i in range(4): t.forward(60) t.right(120) t.end_fill() t.forward(30) t.left(90) t.color('brown') t.forward(60)第三种:二叉树 #绘制第三种树 t.color("black") t.setheading(0) t.pensize(2) def draw(r): if(r |
CopyRight 2018-2019 实验室设备网 版权所有 |