Python turtle库 实现 随机彩色文字平面批量输出

python 复制代码
# -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
import turtle
import random
import turtle as t
t.colormode(255)
turtle.bgcolor("white")
h=255
l=50#字号
m=60#间隔
n=500
t.penup()
turtle.hideturtle()
def wuxing():
    turtle.pu()
    #turtle.penup()
    
    #turtle.stamp()#central
    #turtle.right(90)
    text="二叉树"
    #turtle.pu()
    for i in text:
        e=random.randint(0,h)
        f=random.randint(0,h)
        g=random.randint(0,h)
        turtle.pencolor(e,f,g)
        turtle.write(i,font=('隶书',l))
        t.fd(m)
t.speed(10000)
for i in range(10):
    turtle.goto(-800, n)  # 到画布中心
    n-=100
    for j in range(10):
        wuxing()

声明:著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

运行结果:

相关推荐
癫狂的兔子5 分钟前
【BUG】【Python】【Spider】Compound class names are not allowed.
开发语言·python·bug
木头左23 分钟前
基于Backtrader框架的指数期权备兑策略实现与验证
python
李松桃33 分钟前
python第三次作业
java·前端·python
m0_5613596735 分钟前
使用PyTorch构建你的第一个神经网络
jvm·数据库·python
马士兵教育36 分钟前
计算机专业学生入行IT行业,编程语言如何选择?
java·开发语言·c++·人工智能·python
diediedei1 小时前
持续集成/持续部署(CI/CD) for Python
jvm·数据库·python
weixin_445402301 小时前
Python游戏中的碰撞检测实现
jvm·数据库·python
棒棒的皮皮1 小时前
【OpenCV】Python图像处理矩特征之矩的计算/计算轮廓的面积
图像处理·python·opencv·计算机视觉
人工智能AI技术1 小时前
【Agent从入门到实践】41 部署方式选型:本地脚本、Docker容器、云服务部署
人工智能·python