Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added PanChuan/0000/final.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions PanChuan/0000/generate_red_reminder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw

"""
make an image's white part to be transparent for merging with another image
"""
def white_to_transparent(img):
img = img.convert('RGBA')
datas = img.getdata()
newData=[]
for item in datas:
if item[0] == 255 and item[1] == 255 and item[2] == 255:
newData.append((255,255,255,0))
else:
newData.append(item)
img.putdata(newData)
return img

if __name__ == "__main__":
p1_name = "github_logo.png"
p2_name = "red_reminder.png"
p1_image = Image.open(p1_name)
p2_image = Image.open(p2_name)
p2_transparent = white_to_transparent(p2_image)
p1_image.paste(p2_transparent,(0,0),p2_transparent)

usr_font = ImageFont.truetype("./yahei.TTF",32)
draw = ImageDraw.Draw(p1_image)
draw.text((152,8),u'12',font = usr_font)
p1_image.save("final.png","PNG")


Binary file added PanChuan/0000/github_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PanChuan/0000/red_reminder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PanChuan/0000/yahei.TTF
Binary file not shown.
20 changes: 20 additions & 0 deletions PanChuan/0001/generate_coupon.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import string
import random

"""
generate COUPON_NUM coupons,every coupon consists of
COUPON_STR_LEN digit which are capital letter or 0~9
"""
COUPON_NUM = 200
COUPON_STR_LENGTH = 8

if __name__ == "__main__":
lst = list(string.letters)[26:] + list(string.digits)
for i in range(COUPON_NUM):
coupon_list = [random.choice(lst) for i in range(COUPON_STR_LENGTH)]
coupon_str = "".join(coupon_list)
print coupon_str