From 3b202c8e68d425e4dd7d2af9bb8e7a5d3beadcdb Mon Sep 17 00:00:00 2001 From: max Date: Tue, 8 Sep 2026 23:33:16 +0200 Subject: [PATCH] fix(controller): update particle positioning and compositing for padded canvas --- catser/cat_controller.py | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/catser/cat_controller.py b/catser/cat_controller.py index 742d455..44d094a 100644 --- a/catser/cat_controller.py +++ b/catser/cat_controller.py @@ -437,11 +437,11 @@ class CatController: heart_alpha = 1.0 - progress heart = self.assets.get_heart_particle(size=28, alpha=heart_alpha) - canvas = Image.new("RGBA", (self.config.cat_width, self.config.cat_height), (0, 0, 0, 0)) + canvas = Image.new("RGBA", (self.config.canvas_width, self.config.canvas_height), (0, 0, 0, 0)) canvas.paste(base, (0, 0), base) # Heart floats upwards - hx = int(self.config.cat_width * 0.65) - hy = int(self.config.cat_height * 0.15 - progress * 20.0) + hx = self.config.pad_x + int(self.config.cat_width * 0.65) + hy = self.config.pad_y + int(self.config.cat_height * 0.15 - progress * 20.0) canvas.paste(heart, (hx, max(0, hy)), heart) return self._composite_with_shadow(canvas, 0.0) @@ -467,10 +467,10 @@ class CatController: base = self.assets.get_walk_frame(0, coat, self.facing_left, "blink") # Animated zzz particle zzz = self.assets.get_zzz_indicator(size=22) - canvas = Image.new("RGBA", (self.config.cat_width, self.config.cat_height), (0, 0, 0, 0)) + canvas = Image.new("RGBA", (self.config.canvas_width, self.config.canvas_height), (0, 0, 0, 0)) canvas.paste(base, (0, 0), base) - zx = int(self.config.cat_width * 0.65) - zy = int(self.config.cat_height * 0.10 + math.sin(elapsed * 2.0) * 4.0) + zx = self.config.pad_x + int(self.config.cat_width * 0.65) + zy = self.config.pad_y + int(self.config.cat_height * 0.10 + math.sin(elapsed * 2.0) * 4.0) canvas.paste(zzz, (zx, max(0, zy)), zzz) return self._composite_with_shadow(canvas, 0.0) @@ -543,14 +543,14 @@ class CatController: def _composite_with_shadow(self, sprite: Image.Image, lift: float) -> Image.Image: """Draws soft contact shadow underneath the cat sprite.""" - w = self.config.cat_width - h = self.config.cat_height + w = self.config.canvas_width + h = self.config.canvas_height canvas = Image.new("RGBA", (w, h), (0, 0, 0, 0)) lift_ratio = min(1.0, lift / max(1.0, self.floor_y)) - shadow = self.assets.get_shadow(w, lift_ratio) - sx = (w - shadow.width) // 2 - sy = h - shadow.height - 1 + shadow = self.assets.get_shadow(self.config.cat_width, lift_ratio) + sx = self.config.pad_x + (self.config.cat_width - shadow.width) // 2 + sy = self.config.pad_y + self.config.cat_height - shadow.height - 1 canvas.paste(shadow, (sx, sy), shadow) # Cat sprite on top @@ -559,12 +559,10 @@ class CatController: def _composite_with_alert(self, sprite: Image.Image) -> Image.Image: """Paints alert exclamation mark bubble above the cat's head.""" - w = self.config.cat_width - h = self.config.cat_height canvas = self._composite_with_shadow(sprite, 0.0) alert_bubble = self.assets.get_alert_bubble(size=30) - ax = int(w * 0.70) if not self.facing_left else int(w * 0.05) - ay = 2 + ax = self.config.pad_x + (int(self.config.cat_width * 0.70) if not self.facing_left else int(self.config.cat_width * 0.05)) + ay = self.config.pad_y + 2 canvas.paste(alert_bubble, (ax, ay), alert_bubble) return canvas