Python turtle画月饼
2021/9/20 17:32:36
本文主要是介绍Python turtle画月饼,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
import turtle as t def goto(x, y): t.penup() t.goto(x, y) t.pendown() def draw_edges(x, y, color): count = 20 length = 210 t.color(color) goto(x, y) for foo in range(count): t.right(360 / count) t.begin_fill() t.fd(length) t.circle(40, 180) t.end_fill() goto(x, y) def draw_circle(): goto(0, -190) t.pensize(5) t.color(shadow) t.circle(190) def draw_font(): t.color(shadow) size = 80 goto(-size / 2, 80) font = ('kaiti', size, 'bold') t.write('豆', font=font) goto(-size / 2, -80 - size) t.write('沙', font=font) size = 50 content = '海上生明月 天涯共此时' len_ = len(content) + 2 t.color('red') goto(-len_ * size / 2, -400) font = ('kaiti', size, 'bold') t.write(content, font=font) color = 'khaki' shadow = '#d9b300' t.speed(1000) draw_edges(-25, 25, shadow) draw_edges(0, 0, color) draw_circle() write() t.done()
这篇关于Python turtle画月饼的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2025-01-03用FastAPI掌握Python异步IO:轻松实现高并发网络请求处理
- 2025-01-02封装学习:Python面向对象编程基础教程
- 2024-12-28Python编程基础教程
- 2024-12-27Python编程入门指南
- 2024-12-27Python编程基础
- 2024-12-27Python编程基础教程
- 2024-12-27Python编程基础指南
- 2024-12-24Python编程入门指南
- 2024-12-24Python编程基础入门
- 2024-12-24Python编程基础:变量与数据类型