squash_stretch_pass
Squash or stretch each frame's drawn shape around a fixed contact edge while preserving volume, adding impact weight to existing sprite animations.
Instructions
Squash or stretch a shape while the edge it rests on stays exactly where it is.
The weight in an impact: a body landing flattens against the ground and spreads
sideways. What makes it read is that the **contact edge does not move**. Scaling a
shape about its centre shortens it from both ends at once, so the thing lifts off the
surface at the very moment it should be pressed into it. Measured on a hand-built
squash before this existed: the contact row rose from 56 to 54, so the ball went *up*
two pixels on impact.
**Volume is preserved**: whatever the shape loses along the anchored axis it gains
across it, so a squash widens and a stretch narrows. That is the arithmetic a caller
would otherwise have to do twice and keep consistent.
**Which of these two tools you want.** `tween_cels` takes the drawing on the *first*
listed frame and resamples that one drawing across all of them, interpolating the
scale as it goes, which is how an inbetween is made. This takes *each frame's own*
drawing and deforms it in place by the same amount, which is how an animation that
already exists gets its weight: every frame of a walk keeps its own pose and is
pressed onto the ground.
Args:
layer: The layer holding the shape (default: the top one). The drawn box on each
frame is what gets deformed, not the canvas.
frames: Which frames to work on, 1-based. Defaults to every frame. A frame with
nothing drawn on it is reported as skipped rather than failing the pass.
anchor: The edge that stays put: "bottom" (the usual contact edge), "top",
"left" or "right". "bottom" and "top" squash vertically, "left" and "right"
horizontally.
amount: How much of the anchored axis is given up, 0 to 0.8. 0.2 is a firm
landing. **Negative stretches** instead, which is the other half of the pair:
-0.2 makes the shape 20 percent taller and correspondingly narrower, for the
frames before and after an impact.
Resizing is nearest neighbour, always. Bilinear is what the editor would reach for and
it is wrong here: measured on a 5-colour sprite, it returned 50 colours and 40
semi-transparent pixels, so a single pass would cost the sprite its palette and fringe
its silhouette.
Returns the per-frame report: the box before, the box after, and the coordinate the
anchored edge kept.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"filename": "<filename>"
},
"name": "squash_stretch_pass"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| layer | No | ||
| amount | No | Default: 0.2. | |
| anchor | No | Default: "bottom". | bottom |
| frames | No | ||
| filename | Yes |