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

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

运行结果:

相关推荐
cnxy18815 小时前
围棋对弈Python程序开发完整指南:步骤4 - 提子逻辑和劫争规则实现
开发语言·python·机器学习
TheSumSt15 小时前
Python丨课程笔记Part3:语法进阶部分(控制结构与基础数据结构)
数据结构·笔记·python
ha_lydms16 小时前
5、Spark函数_s/t
java·大数据·python·spark·数据处理·maxcompute·spark 函数
电商API&Tina16 小时前
跨境电商 API 对接指南:亚马逊 + 速卖通接口调用全流程
大数据·服务器·数据库·python·算法·json·图搜索算法
Yyyyy123jsjs16 小时前
外汇Tick数据交易时段详解与Python实战分析
人工智能·python·区块链
默默前行的虫虫17 小时前
nicegui地图总结
网络·python
不易思不逸18 小时前
SAM2 测试
人工智能·python
趣知岛19 小时前
智能家居与物联网项目实战全指南:从架构设计到落地部署
python·物联网·智能家居
龘龍龙19 小时前
Python基础(八)
开发语言·python
vibag20 小时前
FastAPI框架
python·pycharm·fastapi