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

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

运行结果:

相关推荐
hudawei99618 小时前
Flask 与 FastAPI 对比分析
python·flask·fastapi
寻星探路18 小时前
【Python 全栈测开之路】Python 基础语法精讲(一):常量、变量与运算符
java·开发语言·c++·python·http·ai·c#
智航GIS18 小时前
10.5 PyQuery:jQuery 风格的 Python HTML 解析库
python·html·jquery
小兔崽子去哪了18 小时前
机器学习,梯度下降,拟合,正则化,混淆矩阵
python·机器学习
缘友一世18 小时前
PyCharm连接autodl平台服务(python解释器&jupyter lab)
python·jupyter·pycharm
a程序小傲19 小时前
得物Java面试被问:方法句柄(MethodHandle)与反射的性能对比和底层区别
java·开发语言·spring boot·后端·python·面试·职场和发展
华研前沿标杆游学19 小时前
2026走进滕讯:小游戏×大模型产业交流记
python
_codemonster19 小时前
计算机视觉入门到实战系列(八)Harris角点检测算法
python·算法·计算机视觉
默默前行的虫虫19 小时前
nicegui的3D可视化
python
hui函数20 小时前
Python系列Bug修复|如何解决 pip install -e . 安装报错 “后端不支持可编辑安装(PEP 660)” 问题
python·bug·pip