文章目录
- 写在前面
- 系列文章
- 绘图基础
- Tom&Jerry
- 写在后面
写在前面
汤姆永远抓不到杰瑞,我们的故事永远不会结束!本期博主给大家带来了Tom&Jerry,快来看看吧~(Tom和Jerry可以修改成自己想修改的名字哦)
系列文章
序号 | 文章目录 | 直达链接 |
---|---|---|
1 | 浪漫520表白代码 | https://want595.blog.csdn.net/article/details/130666881 |
2 | 满屏表白代码 | https://want595.blog.csdn.net/article/details/129794518 |
3 | 跳动的爱心 | https://want595.blog.csdn.net/article/details/129503123 |
4 | 漂浮爱心 | https://want595.blog.csdn.net/article/details/128808630 |
5 | 爱心光波 | https://want595.blog.csdn.net/article/details/132311588 |
6 | 流星雨 | https://want595.blog.csdn.net/article/details/129395465 |
7 | 满天星 | https://want595.blog.csdn.net/article/details/129572082 |
8 | 烟花秀 | https://want595.blog.csdn.net/article/details/128746664 |
9 | 圣诞树 | https://want595.blog.csdn.net/article/details/128213770 |
10 | 雪花代码 | https://want595.blog.csdn.net/article/details/129038108 |
11 | 模拟星空 | https://want595.blog.csdn.net/article/details/129948882 |
12 | 生日蛋糕 | https://want595.blog.csdn.net/article/details/129694998 |
13 | 樱花树 | https://want595.blog.csdn.net/article/details/130350743 |
14 | 五彩气球 | https://want595.blog.csdn.net/article/details/130950744 |
15 | 七彩花朵 | https://want595.blog.csdn.net/article/details/130897838 |
16 | 恶搞代码 | https://want595.blog.csdn.net/article/details/131274862 |
17 | 代码雨 | https://want595.blog.csdn.net/article/details/132574687 |
18 | 中秋星空 | https://want595.blog.csdn.net/article/details/132910075 |
19 | 国庆祝福 | https://want595.blog.csdn.net/article/details/133427031 |
20 | 皮卡丘 | https://want595.blog.csdn.net/article/details/133783136 |
21 | 玫瑰花 | https://want595.blog.csdn.net/article/details/133851128 |
22 | 名侦探柯南 | https://want595.blog.csdn.net/article/details/133903847 |
23 | 万圣节蝙蝠 | https://want595.blog.csdn.net/article/details/133935474 |
24 | 南瓜头 | https://want595.blog.csdn.net/article/details/133973340 |
25 | 万圣节礼物 | https://want595.blog.csdn.net/article/details/134011397 |
26 | hellokitty | https://want595.blog.csdn.net/article/details/134145048 |
27 | 小灰灰 | https://want595.blog.csdn.net/article/details/134282615 |
28 | 喜羊羊 | https://want595.blog.csdn.net/article/details/134338743 |
29 | Tom&Jerry | https://want595.blog.csdn.net/article/details/134382545 |
绘图基础
Python的turtle库是一个基于tkinter模块的绘图库,它提供了一些简单的命令来控制一个小乌龟的运动和绘图。下面是一些turtle绘图的基础知识:
- 导入turtle库:
import turtle
- 创建一个画布和一个小乌龟:
win = turtle.Screen() # 创建一个画布
t = turtle.Turtle() # 创建一个小乌龟
- 移动小乌龟:
t.forward(100) # 向前移动100个像素
t.backward(50) # 向后移动50个像素
t.right(90) # 向右转动90度
t.left(45) # 向左转动45度
- 绘制形状:
t.pendown() # 放下画笔
t.circle(50) # 绘制一个半径为50的圆形
t.penup() # 抬起画笔
t.goto(0, 0) # 将小乌龟移动到坐标(0, 0)
- 改变画笔的颜色、粗细等属性:
t.pensize(5) # 设置画笔的粗细为5个像素
t.pencolor('red') # 设置画笔的颜色为红色
- 填充形状:
t.begin_fill() # 开始填充
t.fillcolor('yellow') # 设置填充颜色为黄色
t.circle(50) # 绘制一个半径为50的圆形
t.end_fill() # 结束填充
- 隐藏或显示小乌龟:
t.hideturtle() # 隐藏小乌龟
t.showturtle() # 显示小乌龟
- 清空画布:
t.clear() # 清空画布中小乌龟绘制的所有内容
- 关闭画布:
win.bye() # 关闭画布
以上是turtle绘图的基础知识,可以根据需求进行更加复杂的绘图操作。
Tom&Jerry
程序设计
import turtle
turtle.title("Tom&Jerry")
turtle.setup(0.7,0.7)
turtle.hideturtle()
turtle.bgcolor('blue') # 背景颜色,可换成"pink"
t = turtle.Turtle()
t.screen.delay(0)
……完整代码文末公众号免费领取哦~
运行结果
写在后面
我是一只有趣的兔子,感谢你的喜欢!