What it does
Each pixel blends from the top colour to the bottom colour by its height on the screen raised to the power of
curve. At 1 the blend is straight; above 1 the top colour holds longer and the change moves toward the bottom, like a
sunset band; below 1 it rises. Values at or below 0 are treated as 0.01, so a wild value never breaks the shader.
It ignores the camera, so the sky stays put however far the level scrolls. Its handle is the backdrop runtime's, so the layer can also fade in and out or have its curve tweened.
Features
- Two colour stops —
topandbottom, as hex strings with or without alpha. - A curve — one param bends the blend for a low horizon band or a high one.
- Live changes —
setandsetColorat any time, for a time of day or a change of mood. - The cheapest pass — one full-screen pass with almost no maths in it.
- In every core bundle —
core-2d,core-3dandcore-vectoralready include it.
Good for
- Platformers — a clear daytime sky behind the level.
- Skylines at dawn or dusk — a warm bottom and a deep top, with silhouettes in front.
- Space games — a deep blue base under a starfield or a nebula.
- Card and board games — a soft room tone instead of a flat colour.
Make it yours
A navy top over an amber bottom with curve at 1.4 is a sunset; two blues with curve at 0.6 is a bright noon. Add
stars over it for night. For a day cycle, blend colours with the color pack each step and set them on the handle.
A quick look
const sky = game.backdrop.add('sky', { curve: 1.4 }, { top: '#1a2a6c', bottom: '#fdbb2d' });
sky.set('curve', 2); // live
sky.setColor('top', '#000814'); // live
Works with
backdrops— the runtime it registers with; required.backdrop-stars,backdrop-nebulaandbackdrop-aurora— layers to stack over it.color— to blend the colours of a day cycle.backdrop-raster-bands— for more than two stops, or hard bands.sky-3d— for a 3D sky with a sun, clouds and a time of day.
Good to know
- Two colour stops only; more stops is
backdrop-raster-bands, one segment per pair. - It ignores the camera, so a sky that changes as a tall level climbs needs a backdrop of your own.
- Its colours are written as they are, not premultiplied, so keep them opaque unless it is the bottom layer.






