Approve Wu river cavalry handpainted sprite v4
This commit is contained in:
@@ -26,6 +26,7 @@ COMPARE_LABELS = ["liu-bei", "guan-yu", "zhang-fei", "rebel", "shu-infantry"]
|
||||
FIT_WIDTH_SCALE = 1.0
|
||||
MIN_FRAME_HEIGHT = 0
|
||||
STRETCH_X = 1.0
|
||||
ACTION_SHRINK_X = 1.0
|
||||
FRAME = 313
|
||||
DIRECTIONS = ("south", "east", "north", "west")
|
||||
BASE_FRAMES_PER_DIRECTION = 16
|
||||
@@ -208,6 +209,26 @@ def stretch_subject_x(subject: Image.Image, max_width: int) -> Image.Image:
|
||||
return trim_to_alpha(solidify_alpha(subject.resize((stretched_width, subject.height), Image.Resampling.LANCZOS)))
|
||||
|
||||
|
||||
def shrink_action_frame_x(frame: Image.Image) -> Image.Image:
|
||||
if ACTION_SHRINK_X >= 1:
|
||||
return frame
|
||||
rgba = solidify_alpha(frame)
|
||||
alpha = np.array(rgba.getchannel("A"))
|
||||
ys, xs = np.where(alpha > 0)
|
||||
if len(xs) == 0:
|
||||
return rgba
|
||||
left, right = int(xs.min()), int(xs.max()) + 1
|
||||
top, bottom = int(ys.min()), int(ys.max()) + 1
|
||||
subject = rgba.crop((left, top, right, bottom))
|
||||
target_width = max(1, round(subject.width * ACTION_SHRINK_X))
|
||||
if target_width >= subject.width:
|
||||
return rgba
|
||||
subject = solidify_alpha(subject.resize((target_width, subject.height), Image.Resampling.LANCZOS))
|
||||
out = Image.new("RGBA", (FRAME, FRAME), (0, 0, 0, 0))
|
||||
out.alpha_composite(subject, ((FRAME - target_width) // 2, bottom - subject.height))
|
||||
return solidify_alpha(out)
|
||||
|
||||
|
||||
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)
|
||||
@@ -321,6 +342,7 @@ def build_action_sheet(poses: dict[str, Image.Image]) -> Image.Image:
|
||||
action_frame = frame
|
||||
if direction == "north" and action in {"attack", "strategy", "item", "celebrate"}:
|
||||
action_frame = poses["walk_back"] if action == "attack" else poses["command"]
|
||||
action_frame = shrink_action_frame_x(action_frame)
|
||||
sheet.alpha_composite(solidify_alpha(action_frame), ((offset + index) * FRAME, row * FRAME))
|
||||
return solidify_alpha(sheet)
|
||||
|
||||
@@ -546,6 +568,7 @@ def parse_args() -> argparse.Namespace:
|
||||
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)
|
||||
parser.add_argument("--action-shrink-x", type=float, default=ACTION_SHRINK_X)
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
@@ -553,7 +576,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, STRETCH_X
|
||||
global FIT_WIDTH_SCALE, MIN_FRAME_HEIGHT, STRETCH_X, ACTION_SHRINK_X
|
||||
|
||||
SOURCE = project_path(args.source)
|
||||
WORK_DIR = project_path(args.work_dir)
|
||||
@@ -570,6 +593,7 @@ def configure(args: argparse.Namespace) -> None:
|
||||
FIT_WIDTH_SCALE = args.fit_width_scale
|
||||
MIN_FRAME_HEIGHT = args.min_frame_height
|
||||
STRETCH_X = args.stretch_x
|
||||
ACTION_SHRINK_X = args.action_shrink_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