From 2076e7341d51ec925d743fa40f672958a36f3084 Mon Sep 17 00:00:00 2001 From: yrriban Date: Sun, 15 Jun 2025 13:31:32 -0400 Subject: [PATCH] PEP 8 compliance. --- dcc/text.py | 60 ++++++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/dcc/text.py b/dcc/text.py index cf11970..4a9aa61 100644 --- a/dcc/text.py +++ b/dcc/text.py @@ -3,36 +3,40 @@ import sys import wand.drawing import wand.image + def draw_text(img, text, font_size=64): - with wand.drawing.Drawing() as draw: - draw.font = dcc.config.FONT - draw.font_size=font_size - draw.fill_color=wand.color.Color(dcc.config.TEXT_FILL_COLOR) - draw.stroke_color=wand.color.Color(dcc.config.TEXT_STROKE_COLOR) - draw.stroke_width=font_size*5/32 - draw.text_interline_spacing=-font_size/4 - draw.text(5,int(draw.font_size)+5,text) - draw(img) - draw.stroke_color=wand.color.Color("none") - draw.stroke_width=0 - draw.text(5,int(draw.font_size)+5,text) - draw(img) + with wand.drawing.Drawing() as draw: + draw.font = dcc.config.FONT + draw.font_size = font_size + draw.fill_color = wand.color.Color(dcc.config.TEXT_FILL_COLOR) + draw.stroke_color = wand.color.Color(dcc.config.TEXT_STROKE_COLOR) + draw.stroke_width = font_size * 5 / 32 + draw.text_interline_spacing = -font_size / 4 + draw.text(5, int(draw.font_size) + 5, text) + draw(img) + draw.stroke_color = wand.color.Color("none") + draw.stroke_width = 0 + draw.text(5, int(draw.font_size)+5, text) + draw(img) class Text(dcc.doom_base.WadMap): - def get_parser(self, prog_name): - parser = super().get_parser(prog_name) - parser.add_argument("--nomap", action="store_true") - parser.add_argument("--demotype", default="UV-Max Demo") - return parser + def get_parser(self, prog_name): + parser = super().get_parser(prog_name) + parser.add_argument("--nomap", action="store_true") + parser.add_argument("--demotype", default="UV-Max Demo") + return parser - def take_action(self, parsed_args): - text = sys.stdin.read().rstrip() - if not parsed_args.nomap: - text = "MAP{}: {}".format(parsed_args.map, text) - text = "{}\n{}".format(text, parsed_args.demotype) - with wand.image.Image(height=dcc.config.THUMB_HEIGHT,width=dcc.config.THUMB_WIDTH) as img: - draw_text(img, text) - img.trim() - img.reset_coords() - img.save(filename=self.text_thumb_path()) + def take_action(self, parsed_args): + text = sys.stdin.read().rstrip() + if not parsed_args.nomap: + text = "MAP{}: {}".format(parsed_args.map, text) + text = "{}\n{}".format(text, parsed_args.demotype) + with wand.image.Image( + height=dcc.config.THUMB_HEIGHT, + width=dcc.config.THUMB_WIDTH + ) as img: + draw_text(img, text) + img.trim() + img.reset_coords() + img.save(filename=self.text_thumb_path())