Refactor text generation to support video concatenation.
This commit is contained in:
parent
355bd9d5d9
commit
a15fb7604b
1 changed files with 22 additions and 18 deletions
34
dcc/text.py
34
dcc/text.py
|
@ -3,32 +3,36 @@ import sys
|
||||||
import wand.drawing
|
import wand.drawing
|
||||||
import wand.image
|
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)
|
||||||
|
|
||||||
|
|
||||||
class Text(dcc.doom_base.WadMap):
|
class Text(dcc.doom_base.WadMap):
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
parser = super().get_parser(prog_name)
|
parser = super().get_parser(prog_name)
|
||||||
parser.add_argument("--nomap", action="store_true")
|
parser.add_argument("--nomap", action="store_true")
|
||||||
parser.add_argument("--demotype", default="UV-Max")
|
parser.add_argument("--demotype", default="UV-Max Demo")
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
text = sys.stdin.read().rstrip()
|
text = sys.stdin.read().rstrip()
|
||||||
if not parsed_args.nomap:
|
if not parsed_args.nomap:
|
||||||
text = "MAP{}: {}".format(parsed_args.map, text)
|
text = "MAP{}: {}".format(parsed_args.map, text)
|
||||||
text = "{}\n{} Demo".format(text, parsed_args.demotype)
|
text = "{}\n{}".format(text, parsed_args.demotype)
|
||||||
with wand.image.Image(height=dcc.config.THUMB_HEIGHT,width=dcc.config.THUMB_WIDTH) as img:
|
with wand.image.Image(height=dcc.config.THUMB_HEIGHT,width=dcc.config.THUMB_WIDTH) as img:
|
||||||
with wand.drawing.Drawing() as draw:
|
draw_text(img, text)
|
||||||
draw.font = dcc.config.FONT
|
|
||||||
draw.font_size=64
|
|
||||||
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=10
|
|
||||||
draw.text_interline_spacing=-16
|
|
||||||
draw.text(5,int(draw.font_size),text)
|
|
||||||
draw(img)
|
|
||||||
draw.stroke_color=wand.color.Color("none")
|
|
||||||
draw.stroke_width=0
|
|
||||||
draw.text(5,int(draw.font_size),text)
|
|
||||||
draw(img)
|
|
||||||
img.trim()
|
img.trim()
|
||||||
img.reset_coords()
|
img.reset_coords()
|
||||||
img.save(filename=self.text_thumb_path())
|
img.save(filename=self.text_thumb_path())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue