forked from china-testing/python-api-tesing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdutchflag.py
More file actions
executable file
·28 lines (24 loc) · 801 Bytes
/
dutchflag.py
File metadata and controls
executable file
·28 lines (24 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Author: xurongzhong#126.com wechat:pythontesting qq:37391319
# 技术支持 钉钉群:21745728(可以加钉钉pythontesting邀请加入)
# qq群:144081101 591302926 567351477
# CreateDate: 2018-6-12
# dutchflag.py
from PIL import Image
def dutchflag(width, height):
"""Return new image of Dutch flag."""
img = Image.new("RGB", (width, height))
for j in range(height):
for i in range(width):
if j < height/3:
img.putpixel((i, j), (255, 0, 0))
elif j < 2*height/3:
img.putpixel((i, j), (0, 255, 0))
else:
img.putpixel((i, j), (0, 0, 255))
return img
def main():
img = dutchflag(600, 400)
img.save("dutchflag.jpg")
main()