Hats and hair
"region": "head" masks everything from the top of each cell down to the
neck, empty space included, and leaves the body black. padding adds empty
pixels around every figure so there is room for a brim or a tall crown.
"hero.hat": {
"prompt": "Put the same wide-brimmed brown leather ranger hat with a small red feather on the head of every cyan mannequin on this spritesheet. The hat follows the direction each head faces. Keep the hat the same shape, size and colours in every cell. Keep each head exactly where it is and keep the cyan face and ears below the brim cyan. Do not add hair, bodies, clothes, weapons or extra characters.",
"layer": { "of": ["hero", "hero.walk.south", "hero.walk.east"], "region": "head", "padding": 10 }
}
Measured on 20 frames (8 rotations, two 6-frame walks) with 10px of padding: the hat was the same shape and colours in all 20 and turned correctly with the head, front, side, back and diagonals.
A padded layer comes back on a larger canvas. Each frame is its source
frame's canvas grown by padding on every side, because a hat above a head
that touches the top of a 64px frame has nowhere to go inside it. A 64px
frame with "padding": 10 gives an 84px layer. The two share a centre: draw
them centred on the same point, or draw the layer at the frame's position
minus padding in both axes.
Padding makes the sheet bigger, so fewer frames fit. See Cost and limits.
Nudging a layer into place
A provider does not always seat a hat where you would. offset moves a
layer by whole pixels, x to the right and y down:
"layer": { "of": ["hero", "hero.walk.south"], "region": "head", "padding": 10, "offset": [0, -2] }
It can also seat it differently per source asset, which is what a hat that
sits right on the stills and low on one walk needs. "*" is every asset not
named:
"offset": { "*": [0, -1], "hero.walk.south": [0, -3] }
On a drawn layer the move is applied when the frames are downloaded, not
when they are generated. Changing it shows in plan as recoverable, and
pixelkiln fetch moves the frames again from the provider's own bytes at no
cost, so trying a pixel either way is free. Pixels pushed off the canvas are
lost, and fetch says how many; padding is the room they have.
On a held item offset moves the item on the hand, and placing it again is
free. With grasp it is one more grip pass, since the fist has to be drawn
around the item where it now is.
The move is the same in every frame of an asset. It cannot fix one frame
that differs from its neighbours; redraw can.
Redrawing one frame
A layer is one inpaint over every frame, and now and then one frame of it
comes back wrong: a robe drawn from behind on a figure walking toward the
viewer, a pack on the chest. Generating the whole layer again pays for every
frame to fix one, and can break a different one. redraw draws only the
frames you name:
pixelkiln redraw hero.robe # lists the frame names
pixelkiln redraw hero.robe --frame hero.walk.south.frame-05 --dry-run
pixelkiln redraw hero.robe --frame hero.walk.south.frame-05
It puts the named frame on a small sheet with the other frames of the same
source asset (the other five of that walk, or the other seven rotations).
Those go on the sheet wearing the layer they already have, with their masks
closed; the named frame goes bare, with its mask open. The provider has the
outfit in front of it from every other side and one figure left to dress. A
frame name can be shortened to any ending that picks out one frame:
walk.south.frame-05.
The new frame replaces the old one as the layer's own: its hash goes in the
lockfile, the same offset is applied, and a later change of offset
starts from it. Anything derived from the layer goes stale and is rebuilt
by the next gen for nothing. The frame it replaced stays in the content
cache. The sheet, mask and result are kept in
.pixelkiln/layers/<style>/<layer>/redraw/.
It is a direct call, outside the plan and --budget, at the Pro price of
its sheet: six 64px frames make about a 90×118 sheet, which is 10. The
amount billed is added to the layer's entry. Several frames of one asset can
go in one call as long as at least one stays as a guide; frames of two
assets go on one sheet together.
What it does not do: it ignores a hand-made mask or keyed override,
which are the size of the whole layer's sheet; it is not for held items,
which are placed; and the new frame is drawn again, not copied, so a hem or
a fold can differ a little from its neighbours. Look at it before moving on.
