使用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)
    
相关推荐
该用户已不存在19 分钟前
PHP、Python、Node.js,谁能称霸2025?
python·node.js·php
luckys.one21 分钟前
第12篇|[特殊字符] Freqtrade 交易所接入全解:API、WebSocket、限频配置详解
网络·ide·python·websocket·网络协议·flask·流量运营
Pocker_Spades_A36 分钟前
Python快速入门专业版(四十六):Python类的方法:实例方法、类方法、静态方法与魔术方法
开发语言·python
cRack_cLick1 小时前
pandas库学习02——基本数据清洗
python·pandas
yubo05091 小时前
YOLO系列——实时屏幕检测
开发语言·windows·python
weixin_457340211 小时前
RTX5060 Ti显卡安装cuda版本PyTorch踩坑记录
人工智能·pytorch·python
测试19982 小时前
Web自动化测试之测试用例流程设计
自动化测试·软件测试·python·selenium·测试工具·职场和发展·测试用例
Juchecar3 小时前
示例说明 Flask 调试模式的安全隐患
python
大翻哥哥3 小时前
Python 2025:数据分析平台智能化转型与新范式
人工智能·python·数据分析
love530love4 小时前
EPGF 架构为什么能保持长效和稳定?
运维·开发语言·人工智能·windows·python·架构·系统架构