Approve Shu archer handpainted sprite v5
This commit is contained in:
@@ -25,6 +25,7 @@ COMPARE_STEMS = ["unit-liu-bei", "unit-guan-yu", "unit-zhang-fei", "unit-rebel",
|
||||
COMPARE_LABELS = ["liu-bei", "guan-yu", "zhang-fei", "rebel", "shu-infantry"]
|
||||
FIT_WIDTH_SCALE = 1.0
|
||||
MIN_FRAME_HEIGHT = 0
|
||||
STRETCH_X = 1.0
|
||||
FRAME = 313
|
||||
DIRECTIONS = ("south", "east", "north", "west")
|
||||
BASE_FRAMES_PER_DIRECTION = 16
|
||||
@@ -198,6 +199,15 @@ def grow_to_minimum_height(subject: Image.Image, max_width: int, max_height: int
|
||||
return trim_to_alpha(solidify_alpha(subject.resize(size, Image.Resampling.LANCZOS)))
|
||||
|
||||
|
||||
def stretch_subject_x(subject: Image.Image, max_width: int) -> Image.Image:
|
||||
if STRETCH_X <= 1:
|
||||
return subject
|
||||
stretched_width = min(max_width, max(1, round(subject.width * STRETCH_X)))
|
||||
if stretched_width <= subject.width:
|
||||
return subject
|
||||
return trim_to_alpha(solidify_alpha(subject.resize((stretched_width, subject.height), Image.Resampling.LANCZOS)))
|
||||
|
||||
|
||||
def fit_frame(source: Image.Image, max_width: int, max_height: int, bottom: int = 304, x_offset: int = 0, allow_detached_effects = False) -> Image.Image:
|
||||
max_width = int(round(max_width * FIT_WIDTH_SCALE))
|
||||
subject = crop_subject(source, allow_detached_effects)
|
||||
@@ -212,6 +222,7 @@ def fit_frame(source: Image.Image, max_width: int, max_height: int, bottom: int
|
||||
subject = keep_largest_component(subject)
|
||||
subject = trim_to_alpha(subject)
|
||||
subject = grow_to_minimum_height(subject, max_width, max_height)
|
||||
subject = stretch_subject_x(subject, max_width)
|
||||
frame = Image.new("RGBA", (FRAME, FRAME), (0, 0, 0, 0))
|
||||
x = (FRAME - subject.width) // 2 + x_offset
|
||||
y = bottom - subject.height
|
||||
@@ -534,6 +545,7 @@ def parse_args() -> argparse.Namespace:
|
||||
parser.add_argument("--compare-labels", default=",".join(COMPARE_LABELS))
|
||||
parser.add_argument("--fit-width-scale", type=float, default=FIT_WIDTH_SCALE)
|
||||
parser.add_argument("--min-frame-height", type=int, default=MIN_FRAME_HEIGHT)
|
||||
parser.add_argument("--stretch-x", type=float, default=STRETCH_X)
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
@@ -541,7 +553,7 @@ def configure(args: argparse.Namespace) -> None:
|
||||
global SOURCE, WORK_DIR, BATTLE_REFERENCE, STEM, OUTPUT_PREFIX
|
||||
global CONTACT_TITLE, BEFORE_TITLE, BEFORE_SCALE_LABEL, REPORT_TITLE, SAMPLE_LABEL
|
||||
global COMPARE_STEMS, COMPARE_LABELS
|
||||
global FIT_WIDTH_SCALE, MIN_FRAME_HEIGHT
|
||||
global FIT_WIDTH_SCALE, MIN_FRAME_HEIGHT, STRETCH_X
|
||||
|
||||
SOURCE = project_path(args.source)
|
||||
WORK_DIR = project_path(args.work_dir)
|
||||
@@ -557,6 +569,7 @@ def configure(args: argparse.Namespace) -> None:
|
||||
COMPARE_LABELS = split_csv(args.compare_labels)
|
||||
FIT_WIDTH_SCALE = args.fit_width_scale
|
||||
MIN_FRAME_HEIGHT = args.min_frame_height
|
||||
STRETCH_X = args.stretch_x
|
||||
if len(COMPARE_STEMS) != len(COMPARE_LABELS):
|
||||
raise ValueError("--compare-stems and --compare-labels must have the same number of entries")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user