Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Animate The Palette?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/blit386-animate-the-palette)
---
name: animate-the-palette
description:
Animate palette slots for motion and mood without redrawing anything, using cycling, fading, flashing, and swapping.
Use for flowing water or fire, day-night transitions, hit flashes, theme switches, or any 'the whole screen shifts
color' effect.
---
# Animate the palette
Create motion and mood without redrawing anything by animating palette slots: cycling, fading, flashing, swapping.
## Start each effect once
Every call starts a new effect. `update()` runs about 60 times a second, so a `BT.paletteCycle` written straight into it
stacks 60 cycles a second, and a fade restarted every step never moves. Start an endless effect once, from the first
`update()` behind a flag, and a one-off effect on an event such as a key press:
```js
update() {
if (!this.isWaterFlowing) {
BT.paletteCycle(1, 8, 0.5); // runs until you clear it
this.isWaterFlowing = true;
}
if (BT.isPressed(BT.BTN_A, 0)) {
BT.paletteFlash(Color32.white, 120); // once per press
}
}
```
Not from `init()`: a real build plays the BLIT386 splash over `init()` and drops every effect started there, so an
effect that works in a dev build vanishes from the shipped game. Setting slots with `palette.set()` in `init()` is fine.
## The effects
```js
// Continuously rotate slots [start..end]. Great for waterfalls, lava, marquees.
BT.paletteCycle(1, 8, 0.5); // start, end, speed
// Smoothly fade the whole palette toward another palette over time.
BT.paletteFade(this.nightPalette, 2000, 'ease-in-out'); // target, durationMs, easing?
// Fade only a slice of slots toward a target palette.
BT.paletteFadeRange(1, 8, this.duskPalette, 1500);
// Fade the whole palette like a camera iris instead of a crossfade (blit386 1.5.0+).
// Bright slots come up first and hold on longest; dark slots arrive late and crush early.
BT.paletteFadeExposure(this.gamePalette, 1500); // target, durationMs, options?
BT.paletteFadeExposure(this.gamePalette, 1500, { highlightLead: 0.2, easing: 'ease-out' });
// Flash all colored slots to one color, then restore. Good for damage or explosions.
BT.paletteFlash(new Color32(255, 255, 255), 120); // color, durationMs
// Instantly exchange two slots.
BT.paletteSwap(3, 4);
// Cancel every running palette effect.
BT.paletteClearEffects();
```
## Key calls (all methods)
- `BT.paletteCycle(start, end, speed)`
- `BT.paletteFade(targetPalette, durationMs, easing?)`
- `BT.paletteFadeRange(start, end, targetPalette, durationMs, easing?)`
- `BT.paletteFadeExposure(targetPalette, durationMs, options?)` - engine 1.5.0+; options are `{ highlightLead, easing }`
- `BT.paletteFlash(color, durationMs)`
- `BT.paletteSwap(indexA, indexB)`
- `BT.paletteClearEffects()`
- Easing names: `'linear'`, `'ease-in'`, `'ease-out'`, `'ease-in-out'`, plus the full curve library on blit386 1.5.0+
(`'sine-*'`, `'cubic-*'`, `'expo-*'`, `'bounce-*'`, and more - see the `move-and-time` skill).
## Which fade do I want?
`paletteFade` mixes the numbers a color is stored as. Every slot dims by the same share at the same moment, so the
picture sinks into gray together. That is a crossfade, and it is the right choice for a cross-dissolve between two
themes.
`paletteFadeExposure` dims light rather than stored numbers, and starts each slot on its own schedule based on how
bright it is. Bright slots come up first and hold on longest; dark slots arrive late and crush early. That is what a
camera closing its iris looks like, so reach for it on a title card, a fade up into the game, or a blackout.
`highlightLead` is the knob. `0` puts every slot on one schedule (a plain fade, still in light); the default `0.5` reads
as cinematic. Both fades land exactly on the target palette, so nothing is left one step off at the end.
One catch worth knowing: a palette fade works per slot, not per pixel. A dark object standing in a bright room fades on
the dark schedule no matter what is around it, because the engine only knows its slot number. Fading up from black or
down to black always looks right; in a busy scene, look at it before shipping it.
## When the effects move (engine 1.8.0+)
Effects advance once per `update()` step, right after your `update()` returns, on the engine's tick clock - not per
rendered frame and not by wall time. Two things follow:
- They run at the same speed on a 60 Hz and a 144 Hz display, and `BT.renderAt(seconds)` reproduces them exactly, so a
seeked screenshot shows the fade where a live player would see it.
- Start effects in `update()` and write to palette slots in `init()` or `update()` - never in `render()`. A
`palette.set()` in `render()` lands after the effects already ran for that step, and a seek runs `render()` only once
at the end.
- `BT.ticksReset()` pauses every effect for one step instead of running it backwards. An effect's time counts from when
you added it, so an effect started after an idle gap begins at its start, not partway through.
## Notes
- These animate the active palette; set one up first (use-palette skill).
- Ranges and swap slots start at 1 and stay inside the palette. Slot 0 is the frozen transparent color, so on engine
1.9.0+ `BT.paletteCycle`, `BT.paletteFadeRange`, and `BT.paletteSwap` throw right at the call when a range touches
slot 0 or an `end` reaches past the last slot (older engines stopped the game on the next step instead).
- A fade target is a whole `Palette` - build the "night" palette once in `init()`. The use-palette skill shows
`fillBlock`, which copies a whole block of colors with one change applied (dimmed, tinted) in one call.
- Slots past the end of the target palette are left alone. Hand `paletteFadeExposure` a small target palette and it only
touches that many slots, which is how two different fades can run at once on one palette.
- A theme swap (new colors in the same slots, with `BT.paletteSet` or the effects above) needs nothing else: sprites
pick up the new colors on their own. Call `BT.spritesRefresh()` only after a layout swap, where the same colors moved
to different slot numbers. It re-maps every sheet from `SpriteSheet.loadIndexed`, including ones not drawn yet. Never
call it after a theme swap: the old colors are gone, so it fails and logs an error for each sheet that used one.
See `docs/palette.md`.