使用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)
    
相关推荐
孟健10 小时前
Karpathy 用 200 行纯 Python 从零实现 GPT:代码逐行解析
python
码路飞12 小时前
写了个 AI 聊天页面,被 5 种流式格式折腾了一整天 😭
javascript·python
曲幽15 小时前
FastAPI压力测试实战:Locust模拟真实用户并发及优化建议
python·fastapi·web·locust·asyncio·test·uvicorn·workers
敏编程19 小时前
一天一个Python库:jsonschema - JSON 数据验证利器
python
前端付豪19 小时前
LangChain记忆:通过Memory记住上次的对话细节
人工智能·python·langchain
databook19 小时前
ManimCE v0.20.1 发布:LaTeX 渲染修复与动画稳定性提升
python·动效
花酒锄作田1 天前
使用 pkgutil 实现动态插件系统
python
前端付豪1 天前
LangChain链 写一篇完美推文?用SequencialChain链接不同的组件
人工智能·python·langchain
曲幽2 天前
FastAPI实战:打造本地文生图接口,ollama+diffusers让AI绘画更听话
python·fastapi·web·cors·diffusers·lcm·ollama·dreamshaper8·txt2img
老赵全栈实战2 天前
Pydantic配置管理最佳实践(一)
python