使用python实现奔跑的线条效果

效果,展示(视频效果展示):

奔跑的线条

from turtle import *

import time

t1=Turtle()

t2=Turtle()

t3=Turtle()

t1.hideturtle()

t2.hideturtle()

t3.hideturtle()

t1.pencolor("red")

t2.pencolor("green")

t3.pencolor("blue")

t1.pensize(5)

t2.pensize(5)

t3.pensize(5)

t1.penup()

t2.penup()

t3.penup()

t1.goto(-50,50)

t2.goto(-40,50)

t3.goto(-30,50)

while 5>2:

for i in range(10):

t1.penup()

t2.penup()

t3.penup()

t1.goto(-50+30*i,50)

t2.goto(-40+30*i,50)

t3.goto(-30+30*i,50)

t1.pendown()

t2.pendown()

t3.pendown()

#t1.forward(10)

#t2.forward(10)

#t3.forward(10)

time.sleep(0.1)

t1.clear()

time.sleep(0.1)

t2.clear()

time.sleep(0.1)

t3.clear()

t1.penup()

t2.penup()

t3.penup()

t1.goto(-50+30*i,50)

t2.goto(-40+30*i,50)

t3.goto(-30+30*i,50)

t1.pendown()

t2.pendown()

t3.pendown()

t1.forward(30)

t2.forward(30)

t3.forward(30)

代码分享:

python 复制代码
from turtle import *
import time
t1=Turtle()
t2=Turtle()
t3=Turtle()
t1.hideturtle()
t2.hideturtle()
t3.hideturtle()
t1.pencolor("red")
t2.pencolor("green")
t3.pencolor("blue")
t1.pensize(5)
t2.pensize(5)
t3.pensize(5)
t1.penup()
t2.penup()
t3.penup()
t1.goto(-50,50)
t2.goto(-40,50)
t3.goto(-30,50)
while 5>2:
    for i in range(10):
        t1.penup()
        t2.penup()
        t3.penup()
        t1.goto(-50+30*i,50)
        t2.goto(-40+30*i,50)
        t3.goto(-30+30*i,50)
        t1.pendown()
        t2.pendown()
        t3.pendown()
        #t1.forward(10)
        #t2.forward(10)
        #t3.forward(10)
        time.sleep(0.1)
        t1.clear()
        time.sleep(0.1)
        t2.clear()
        time.sleep(0.1)
        t3.clear()
        t1.penup()
        t2.penup()
        t3.penup()
        t1.goto(-50+30*i,50)
        t2.goto(-40+30*i,50)
        t3.goto(-30+30*i,50)
        t1.pendown()
        t2.pendown()
        t3.pendown()
        t1.forward(30)    
        t2.forward(30)   
        t3.forward(30)
    
相关推荐
上班日常摸鱼1 小时前
Shell脚本基础教程:变量、条件判断、循环、函数实战(附案例)
python
无心水1 小时前
【Python实战进阶】5、Python字符串终极指南:从基础到高性能处理的完整秘籍
开发语言·网络·python·字符串·unicode·python实战进阶·python工业化实战进阶
2301_807583231 小时前
了解python,并编写第一个程序,常见的bug
linux·python
小白学大数据1 小时前
构建混合爬虫:何时使用Requests,何时切换至Selenium处理请求头?
爬虫·python·selenium·测试工具
2401_827560201 小时前
【Python脚本系列】PyAudio+librosa+dtw库录制、识别音频并实现点击(四)
python·语音识别
BBB努力学习程序设计2 小时前
Python自动化脚本:告别重复劳动
python·pycharm
BBB努力学习程序设计2 小时前
Python函数式编程:优雅的代码艺术
python·pycharm
2501_940943912 小时前
体系课\ Python Web全栈工程师
开发语言·前端·python
田姐姐tmner2 小时前
Python切片
开发语言·python
t***31653 小时前
爬虫学习案例3
爬虫·python·学习