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

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

运行结果:

相关推荐
摩拜芯城IC5 分钟前
ATSHA204A‑STUCZ CryptoAuthentication 安全认证芯片IC
python·安全
小雨中_34 分钟前
2.4 贝尔曼方程与蒙特卡洛方法
人工智能·python·深度学习·机器学习·自然语言处理
MediaTea1 小时前
Python:可迭代对象(对象语义角色)
开发语言·python
skywalk81632 小时前
Diffusers 库介绍,它支持LTX-2模型
python
一个处女座的程序猿O(∩_∩)O3 小时前
Python函数参数*args和**kwargs完全指南:从入门到精通
开发语言·python
好家伙VCC3 小时前
**发散创新:编译器优化实战——从LLVM IR到性能飞跃的奇妙旅程**
java·开发语言·python·算法
大尚来也3 小时前
Python 中使用 ezdxf:轻松读写 DXF 文件的完整指南
开发语言·python
小雨中_3 小时前
2.6 时序差分方法(Temporal Difference, TD)
人工智能·python·深度学习·机器学习·自然语言处理
@zulnger4 小时前
单元测试框架 —— unittest
python·单元测试
apcipot_rain4 小时前
原神“十盒半价”问题的兹白式建模分析
python·数学·算法·函数·数据科学·原神·数列