Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 42510ff

Browse files
committed
m
1 parent 644765d commit 42510ff

File tree

9 files changed

+59
-0
lines changed

9 files changed

+59
-0
lines changed

‎yeke/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
+ [py-ascii](https://github.com/JustDoPython/python-examples/tree/master/yeke/py-ascii) :Python 实现图片转字符画,静态图、GIF 都能转
2020
+ [py-snow](https://github.com/JustDoPython/python-examples/tree/master/yeke/py-snow) :用 Python 实现带音乐的雪花飘落雪景图
2121
+ [py-discern](https://github.com/JustDoPython/python-examples/tree/master/yeke/py-discern) :十行 Python 代码就提取了韦小宝的身份证信息
22+
+ [py-flag](https://github.com/JustDoPython/python-examples/tree/master/yeke/py-flag) :用 Python 给微信头像加个圣诞老人(平安果)小图标
2223

2324
---
2425

‎yeke/py-flag/__init__.py‎

Whitespace-only changes.

‎yeke/py-flag/apple.jpg‎

26 KB
Loading[フレーム]

‎yeke/py-flag/apple.py‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import turtle
2+
3+
turtle.setup(600, 600, 0, 0)
4+
turtle.up()
5+
turtle.goto(0, -200)
6+
turtle.down()
7+
# 先画一个圆,并填充为红色
8+
turtle.begin_fill()
9+
turtle.color("red")
10+
turtle.circle(radius=150)
11+
turtle.end_fill()
12+
# 画苹果把
13+
turtle.color("black")
14+
turtle.pu()
15+
turtle.goto(-90, 0)
16+
turtle.pd()
17+
turtle.circle(180, 40)
18+
turtle.pu()
19+
turtle.seth(105)
20+
turtle.goto(-20, 20)
21+
turtle.pd()
22+
turtle.circle(180, 50)
23+
turtle.pd()
24+
# 画左边叶子
25+
turtle.begin_fill()
26+
turtle.color("green")
27+
turtle.circle(180, 50)
28+
turtle.seth(-30)
29+
turtle.circle(180, 55)
30+
turtle.end_fill()
31+
# 画右边叶子
32+
turtle.begin_fill()
33+
turtle.color("green")
34+
turtle.seth(0)
35+
turtle.circle(180, 50)
36+
turtle.seth(-180)
37+
turtle.circle(180, 50)
38+
turtle.end_fill()
39+
turtle.done()

‎yeke/py-flag/apple_head.jpg‎

15.3 KB
Loading[フレーム]

‎yeke/py-flag/head.jpg‎

7.28 KB
Loading[フレーム]

‎yeke/py-flag/head_flag.py‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import cv2
2+
3+
# 读取头像和圣诞老人图片
4+
img_head = cv2.imread('head.jpg')
5+
img_flag = cv2.imread('sc.jpg')
6+
# 获取头像和圣诞老人图片宽度
7+
w_head, h_head = img_head.shape[:2]
8+
w_flag, h_flag = img_flag.shape[:2]
9+
# 计算图案缩放比例
10+
scale = w_head / w_flag / 4
11+
# 缩放图案
12+
img_flag = cv2.resize(img_flag, (0, 0), fx=scale, fy=scale)
13+
# 获取缩放后新宽度
14+
w_flag, h_flag = img_flag.shape[:2]
15+
# 按 3 个通道合并图片
16+
for c in range(0, 3):
17+
img_head[w_head - w_flag:, h_head - h_flag:, c] = img_flag[:, :, c]
18+
# 保存最终结果
19+
cv2.imwrite('sc_head.jpg', img_head)

‎yeke/py-flag/sc.jpg‎

33.3 KB
Loading[フレーム]

‎yeke/py-flag/sc_head.jpg‎

16.2 KB
Loading[フレーム]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /