使用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)
    
相关推荐
少林码僧16 小时前
2.31 机器学习神器项目实战:如何在真实项目中应用XGBoost等算法
人工智能·python·算法·机器学习·ai·数据挖掘
智航GIS16 小时前
10.4 Selenium:Web 自动化测试框架
前端·python·selenium·测试工具
jarreyer16 小时前
摄像头相关记录
python
宝贝儿好16 小时前
【强化学习】第六章:无模型控制:在轨MC控制、在轨时序差分学习(Sarsa)、离轨学习(Q-learning)
人工智能·python·深度学习·学习·机器学习·机器人
大、男人16 小时前
python之asynccontextmanager学习
开发语言·python·学习
默默前行的虫虫17 小时前
nicegui文件上传归纳
python
一个没有本领的人17 小时前
UIU-Net运行记录
python
国强_dev18 小时前
Python 的“非直接原因”报错
开发语言·python
副露のmagic18 小时前
更弱智的算法学习 day24
python·学习·算法
廖圣平18 小时前
从零开始,福袋直播间脚本研究【三】《多进程执行selenium》
python·selenium·测试工具