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

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

运行结果:

相关推荐
znhy_232 分钟前
day41打卡
python
晨光32113 分钟前
Day34 模块与包的导入
java·前端·python
知行合一。。。3 分钟前
Python--01--核心基础
android·java·python
深蓝海拓12 分钟前
QT,sys.argv支持的核心内置参数
python·pyqt
superman超哥13 分钟前
仓颉语言中循环语句(for/while)的深度剖析与工程实践
c语言·开发语言·c++·python·仓颉
冷雨夜中漫步17 分钟前
Java类加载机制——双亲委派与自定义类加载器
java·开发语言·python
拾忆,想起29 分钟前
单例模式深度解析:如何确保一个类只有一个实例
前端·javascript·python·微服务·单例模式·性能优化·dubbo
癫狂的兔子33 分钟前
【Python】【NumPy】学习笔记
python·学习·numpy
Kurbaneli40 分钟前
Python的起源与发展
python
540_54040 分钟前
ADVANCE Day26
人工智能·python·机器学习