Some color work

This commit is contained in:
spengreb 2021-03-28 13:41:32 +02:00
parent b02ec065cb
commit e80372557a

42
main.py
View file

@ -6,30 +6,44 @@ from wand.drawing import Drawing
from wand.color import Color
from wand.display import display
class CardColor:
def __init__(self, name, asset, hex_val):
self.name = name
self.hex_val = hex_val
self.asset = asset
def main():
colors = ['red', 'green', 'blue', 'yellow']
special_cards = ['W', 'N']
colors = []
colors.append(CardColor('red', 'red', '#ff2929'))
colors.append(CardColor('green', 'green', '#00800e'))
colors.append(CardColor('blue', 'blue', '#0062f8'))
colors.append(CardColor('yellow', 'yellow', '#e2f800'))
special_cards = []
special_cards.append(CardColor('W', 'white', '#ffffff'))
special_cards.append(CardColor('N', 'white', '#ffffff'))
for color in colors:
for i in range(1, 14):
draw_card_face(color, i)
for sign in special_cards:
draw_card_face('white', sign)
draw_card_face(sign, sign.name)
def draw_card_face(color, symbol):
with Image(filename='assets/wozard-card.png') as img:
draw_symbol(img, symbol, color, 150, 200)
draw_symbol(img, symbol, color, int(img.width - 150), 200)
draw_symbol(img, symbol, color.hex_val, 150, 200)
draw_symbol(img, symbol, color.hex_val, int(img.width - 150), 200)
img.flip() # Make mirrored text
draw_symbol(img, symbol, color, 150, 200)
draw_symbol(img, symbol, color, int(img.width - 150), 200)
draw_symbol(img, symbol, color.hex_val, 150, 200)
draw_symbol(img, symbol, color.hex_val, int(img.width - 150), 200)
draw_rune(img, color)
draw_card_trim(img)
draw_mask(img, color)
save_img(img, color, symbol)
draw_mask(img)
save_img(img, color.asset, symbol)
def draw_symbol(img, symbol, color, x, y):
def draw_symbol(img, symbol, hex_color, x, y):
with Drawing() as draw:
draw.font = 'DejaVu-Sans-Mono'
draw.font_size = 200
@ -37,15 +51,15 @@ def draw_symbol(img, symbol, color, x, y):
draw.stroke_color = Color('black')
draw.stroke_width = 5
draw.text_alignment = 'center'
draw.fill_color=Color(color)
draw.fill_color=hex_color
draw.text(x, y, str(symbol))
draw(img)
return img
def draw_rune(img, color):
with Image(filename='assets/{}.png'.format(color)) as rune:
with Image(filename='assets/{}.png'.format(color.asset)) as rune:
rune.resize(220,244)
rune.opaque_paint(target=Color("white"), fill=Color(color), fuzz=0.66*img.quantum_range)
rune.opaque_paint(target=Color("white"), fill=Color(color.hex_val), fuzz=0.66*img.quantum_range)
img.composite(
rune,
left=int((img.width - rune.width) / 2),
@ -59,7 +73,7 @@ def draw_card_trim(img):
return img
def draw_mask(img, color):
def draw_mask(img):
# 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: