Add rounded edges to cards
This commit is contained in:
parent
87d80ddca3
commit
703f54a037
1 changed files with 20 additions and 1 deletions
21
main.py
21
main.py
|
|
@ -11,7 +11,7 @@ def main():
|
|||
special_cards = ['W', 'N']
|
||||
|
||||
for color in colors:
|
||||
for i in range(1, 4):
|
||||
for i in range(1, 3):
|
||||
draw_card_face(color, i)
|
||||
|
||||
for sign in special_cards:
|
||||
|
|
@ -25,6 +25,8 @@ def draw_card_face(color, symbol):
|
|||
img = draw_symbol(img, symbol, color, 90, 130)
|
||||
img = draw_symbol(img, symbol, color, int(img.width - 100), 130)
|
||||
img = draw_rune(img, color)
|
||||
|
||||
draw_mask(img, color)
|
||||
save_img(img, color, symbol)
|
||||
|
||||
def draw_symbol(img, symbol, color, x, y):
|
||||
|
|
@ -46,6 +48,23 @@ def draw_rune(img, color):
|
|||
top=int((img.height - rune.height) / 2))
|
||||
return img
|
||||
|
||||
def draw_mask(img, color):
|
||||
# Mask with a pink outline. This pink outline is this replaced
|
||||
# with a transparency layer before being returned
|
||||
with Image(width=img.width, height=img.height, background=Color("#c300ff")) as mask:
|
||||
with Drawing() as ctx:
|
||||
ctx.fill_color = Color("black")
|
||||
ctx.rectangle(left=0,
|
||||
top=0,
|
||||
width=mask.width,
|
||||
height=mask.height,
|
||||
radius=mask.width * 0.075)
|
||||
ctx(mask)
|
||||
|
||||
img.composite_channel('all_channels', mask, 'screen')
|
||||
img.opaque_paint(target=Color("#c300ff"), fill=Color("transparent"), fuzz=0.30*img.quantum_range)
|
||||
return img
|
||||
|
||||
def save_img(img, color, symbol):
|
||||
img.save(filename='output/card-{}-{}.png'.format(color, symbol))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue