小学课后服务 Python少儿编程 入门篇:7 神秘的坐标 课件 (30张PPT)

资源下载
  1. 二一教育资源

小学课后服务 Python少儿编程 入门篇:7 神秘的坐标 课件 (30张PPT)

资源简介

(共30张PPT)
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
少儿编程课
神秘的坐标
坐标
可视窗口区域
X 方向
Y 方向
(0,0)
(0,220)
(220,0)
(0,-220)
(-220,0)
画笔的笔头默认出现在屏幕可视区域的中心
也就是坐标(0,0)表示的位置。
笔头默认指向右侧。
坐标
可视窗口区域
X 方向
Y 方向
(0,0)
(0,220)
(220,0)
(0,-220)
(-220,0)
可视区域中任意一个位置都可以根据它相对于中心点(0,0)的位置使用一对数字来描述。
坐标
可视窗口区域
X 方向
Y 方向
(0,0)
(0,220)
(220,0)
(0,-220)
(-220,0)
(正,正)
(正,负)
(负,正)
(负,负)
X 方向
Y 方向
(0,0)
(0,220)
(220,0)
(0,-220)
(-220,0)
(-100,0)
(0,150)
(100,100)
(100,-100)
(-200,-100)
(-150,150)
移动笔头
1. t.goto(x,y)函数可以移动笔头到屏幕的任意位置。
2. 笔头在移动过程中,会在屏幕上画线。如果不希望留下移动的轨迹,可以先抬起笔,再进行移动。
t.up( )
t.goto(x,y)
3. 移动结束绘制新内容的时候,需要重新落笔。
t.up( )
t.goto(x,y)
t.down( )
绘制一个六角星
import turtle
t = turtle.Turtle()
for x in range(3):
t.fd(60)
t.left(120)
t.up()
t.goto(0,30)
t.down()
for x in range(3):
t.fd(60)
t.right(120)
#移动前抬笔
#移动到指定位置
#绘制前落笔
气球飘飘
气球飘飘
随机生成绘制气球的位置
绘制实心圆作为气球
绘制一条竖线作为气球绳
利用循环绘制多个气球
r = randint(0,255)
g = randint(0,255)
b = randint(0,255)
t.color(r,g,b)
t.begin_fill() #准备填充
t.circle(25)
t.end_fill() #开始填充
绘制实心圆
t.right(90)
t.color(15,15,15) #气球线的颜色
t.fd(50) #气球线的长度
绘制气球线
from random import randint
i = randint(-150,150) #生成随机的x坐标
j = randint(-150,150) #生成随机的y坐标
t.up( )
t.goto( i , j ) #将画笔移动到随机生成的位置
t.down( )
随机生成位置
for x in range(10):
i = randint(-150,150)
j = randint(-150,150)
t.up()
t.goto(i,j)
t.down()
r = randint(0,255)
g = randint(0,255)
b = randint(0,255)
t.color(r,g,b)
t.begin_fill()
t.circle(25)
t.end_fill()
t.right(90)
t.color(15,15,15)
t.fd(50)
#随机生成每只气球的位置
#抬笔,移动,落笔
#生成气球颜色
#绘制气球线
有什么问题?
#绘制实心气球
设置笔头
海龟先生绘制图形时,一定都是沿着笔头指向的方向去绘制圆形或直线。
我们在绘制了向下的气球线后,笔头依然指向下方。
所以再次绘制气球并右转(顺时针)90度的时候,就会出现气球线指向不同的地方。
所以,每次绘制完气球线后都应该让笔头回到向右的指向。
t.left(90) 或者 t.seth(0)
#随机生成每只气球的位置
#抬笔,移动,落笔
#绘制实心气球
#绘制气球线
for x in range(10):
i = randint(-150,150)
j = randint(-150,150)
t.up()
t.goto(i,j)
t.down()
r = randint(0,255)
g = randint(0,255)
b = randint(0,255)
t.color(r,g,b)
t.begin_fill()
t.circle(25)
t.end_fill()
t.right(90)
t.color(15,15,15)
t.fd(50)
t.seth(0)
#让笔头指向右侧
#生成气球颜色
夜空中最亮的星
绘制黑夜
t.width(1000) #将画笔设置的非常的粗,一笔覆盖所有可视区域高度
t.up()
t.goto(-250,250) #移动到屏幕的左上角之外
t.down()
t.fd(1000) #绘制一条足够长足够粗的线
绘制黑夜
t.width(80)
for x in range(20):
t.up()
t.goto(-250,250-x*60)
t.down()
t.color(x*10,x*10,x*10)
t.fd(1000)
#将画笔设置的很粗
#画8条非常粗的线
#每次画时画笔向下挪60
#每次画时颜色都会浅一些
绘制星星
t.color(‘yellow’) # 生成以黄色为主的随机色
w = randint(5,10) # 生成大小不一的星星
t.begin_fill() # 绘制实心星星
for x in range (5):
t.fd(w)
t.left(144)
t.end_fill()
绘制星星
绘制星星
30°
120°
for x in range(8):
if x%2==0:
t.left(30)
else:
t.right(120)
t.fd(50)
绘制星星
t.left(30)
for x in range(8):
if x%2==0:
t.left(30)
else:
t.right(120)
t.fd(50)
绘制星星
30°
120°
for x in range(4):
t.fd(50) t.left(30)
t.fd(50) t.right(120)
绘制星星
t.left(30)
for x in range(4):
t.fd(50) t.left(30)
t.fd(50) t.right(120)
填充颜色
t.color(255,255,randint(0,200)) # 生成以黄色为主的随机色
w= randint(5,10) # 生成大小不一的星星
t.begin_fill() # 绘制实心星星
for x in range(8):
if x > 0 and x%2==0:
t.right(120)
else:
t.left(30)
t.fd(w)
t.end_fill()
绘制群星
for y in range( 50 ): #绘制50颗星星
i = randint( -250 , 250 ) #随机生成绘制星星的位置
j = randint( 0 , 250 )
t.up( )
t.goto( i , j ) #将画笔移动到生成的位置
t.down( )
w = randint( 5, 10 ) #随机生成星星的大小
t.begin_fill( )
for x in range( 5 ):
t.fd( w ) #绘制星星
t.left( 144 )
t.end_fill( )
t.ht( ) #隐藏笔头
for x in range(30):
i = randint(-250,250) #随机位置
j=randint(0,250)
t.up()
t.goto(i,j)
t.down()
t.color(255,255,randint(0,200)) # 生成以黄色为主的随机色
l = randint(5,10) # 每个星星的大小不等
t.begin_fill() # 绘制实心星星
for x in range(8):
if x > 0 and x%2==0:
t.right(120)
else:
t.left(30)
t.fd(l)
t.end_fill()
绘制群星
签名
t.up()
t.goto(10,-100) # 将画笔移动到屏幕右下的位置准备写字
t.write(‘夜空中最亮的星’,font=(‘楷体’,20,‘bold’)) # 给画起名字
t.goto(80,-150) # 换个画笔位置准备签名
t.color(‘white’) #换个画笔位置准备签名
t.write(‘by:榴莲老师’,font=(‘楷体’,14,‘bold’)) #签名

展开更多......

收起↑

资源预览