diff --git a/cards/models.py b/cards/models.py index 3bf90d2..c754da5 100644 --- a/cards/models.py +++ b/cards/models.py @@ -185,22 +185,41 @@ class Dinosaur(models.Model): avoid extremely small/large sizes. """ try: - p = float(self.height_percent() or 0) + # Use a combined metric (height + weight) to smooth out extremes + h = float(self.height_percent() or 0) + w = float(self.weight_percent() or 0) + p = (h + w) / 2.0 except Exception: - # fallback if something odd happens p = 50.0 - # Map height percent p (0..100) to a background-size percentage - # so that the largest dinosaurs (p ~= 100) show the whole image - # (100%), and the smallest dinosaurs (p ~= 0) are shown with a - # zoomed-in background (e.g. 300%). This gives p=100 -> min_scale, - # p=0 -> max_scale. + # Use much smaller range for subtler effect: largest dinos -> 100% + # (full image), smallest -> 140% (mild zoom). Interpolate linearly. min_scale = 100 - max_scale = 300 - # Interpolate: scale = min_scale + (1 - p/100) * (max_scale - min_scale) + max_scale = 140 scale = int(round(min_scale + (1.0 - (p / 100.0)) * (max_scale - min_scale))) scale = max(min_scale, min(max_scale, scale)) return f"{scale}%" + @property + def image_scale(self): + """Return a scale factor (float) for the dinosaur's image size. + + Smaller dinosaurs will be scaled down (e.g. 0.6) and larger + dinosaurs closer to full size (1.0). Uses `height_percent()`. + """ + try: + # Combine height and weight for a smoother scale value + h = float(self.height_percent() or 0) + w = float(self.weight_percent() or 0) + p = (h + w) / 2.0 + except Exception: + p = 50.0 + # Subtle scaling: smallest -> 0.90, largest -> 1.00 + min_scale = 0.90 + max_scale = 1.00 + scale = min_scale + (p / 100.0) * (max_scale - min_scale) + scale = max(min_scale, min(max_scale, scale)) + return f"{scale:.2f}" + class BackgroundImage(models.Model): """Background images used behind card renders. diff --git a/cards/templates/cards/_card_item.html b/cards/templates/cards/_card_item.html index 06d7983..a369592 100644 --- a/cards/templates/cards/_card_item.html +++ b/cards/templates/cards/_card_item.html @@ -2,7 +2,7 @@
{% if card.image %} - {{ card.name }} + {{ card.name }} {% endif %}
{{ card.name }}