[Python3]GitHubのアイコンを円形にしようとした(失敗)

目的

最近丸アイコンが増えてきているので,GitHubのアイコンを円形にできたらいいなと思ってやってみた.

ソースコード

Python3
from PIL import Image, ImageDraw


img = Image.new('RGB', (420, 420), color=(240, 240, 240))
draw = ImageDraw.Draw(img)
r = 211
g = 116
b = 217
ul = 40
lr = 380
draw.pieslice((ul, ul, lr, lr), start=15, end=45, fill=(240, 240, 240))
draw.pieslice((ul, ul, lr, lr), start=45, end=75, fill=(240, 240, 240))
draw.pieslice((ul, ul, lr, lr), start=75, end=105, fill=(r, g, b))
draw.pieslice((ul, ul, lr, lr), start=105, end=135, fill=(240, 240, 240))
draw.pieslice((ul, ul, lr, lr), start=135, end=165, fill=(240, 240, 240))
draw.pieslice((ul, ul, lr, lr), start=165, end=195, fill=(r, g, b))
draw.pieslice((ul, ul, lr, lr), start=195, end=225, fill=(r, g, b))
draw.pieslice((ul, ul, lr, lr), start=225, end=255, fill=(r, g, b))
draw.pieslice((ul, ul, lr, lr), start=255, end=285, fill=(r, g, b))
draw.pieslice((ul, ul, lr, lr), start=285, end=315, fill=(r, g, b))
draw.pieslice((ul, ul, lr, lr), start=315, end=345, fill=(r, g, b))
draw.pieslice((ul, ul, lr, lr), start=345, end=375, fill=(r, g, b))

ul = 96
lr = 324
draw.pieslice((ul, ul, lr, lr), start=15, end=45, fill=(240, 240, 240))
draw.pieslice((ul, ul, lr, lr), start=45, end=75, fill=(240, 240, 240))
draw.pieslice((ul, ul, lr, lr), start=75, end=105, fill=(240, 240, 240))
draw.pieslice((ul, ul, lr, lr), start=105, end=135, fill=(240, 240, 240))
draw.pieslice((ul, ul, lr, lr), start=135, end=165, fill=(240, 240, 240))
draw.pieslice((ul, ul, lr, lr), start=165, end=195, fill=(r, g, b))
draw.pieslice((ul, ul, lr, lr), start=195, end=225, fill=(r, g, b))
draw.pieslice((ul, ul, lr, lr), start=225, end=255, fill=(r, g, b))
draw.pieslice((ul, ul, lr, lr), start=255, end=285, fill=(240, 240, 240))
draw.pieslice((ul, ul, lr, lr), start=285, end=315, fill=(r, g, b))
draw.pieslice((ul, ul, lr, lr), start=315, end=345, fill=(r, g, b))
draw.pieslice((ul, ul, lr, lr), start=345, end=375, fill=(r, g, b))

ul = 172
lr = 248
draw.ellipse((ul, ul, lr, lr), fill=(r, g, b))
img.save('test2.png')

結果

できた画像
test2.png

GitHubの画像
36354250.png

致命的にダサい.以上

改善点

5×5から離れたほうがいいのかもしれない

参考

Python, Pillowで円や四角、直線などの図形を描画 | Python / note.nkmk.me
初めてのPython画像処理 - Qiita

Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account log in.