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()

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

运行结果:

相关推荐
cooldog123pp7 分钟前
cplex完全安装手册,适配matlab和python!
人工智能·python·matlab·cplex
TechWayfarer8 分钟前
苏超赛事网站安全防护:WAF、DDoS与仿冒页面如何联动治理
网络·python·安全·flask·ddos
huzhongqiang20 分钟前
单例装饰器升级:用 jsonic 过滤私有字段
python
云梦泽࿐้33 分钟前
变量与数据类型:Python世界的基石
开发语言·python
开发小能手-roy40 分钟前
Lambda表达式性能陷阱:避坑指南与JIT编译优化分析
开发语言·python
风吹夏回44 分钟前
RabbitMQ 核心术语 + Python pika 方法完整讲解
分布式·python·rabbitmq
爱读书的小胖1 小时前
无偿分享ChatGPT Image 2画图网页与并发绘图python程序【Ai绘图】
开发语言·python·chatgpt
cvcode_study1 小时前
Scikit-learn
python·机器学习·scikit-learn
vortex51 小时前
新手前后端开发学习指南:从Flask框架到全栈实践
后端·python·flask
你是个什么橙1 小时前
Python入门学习1:安装配置开发环境——Python或Annaconda,Pycharm
python·学习·pycharm