// Palette Fade & Flash: smooth color transitions and flash effects.
// @description Smooth color transitions and flash effects: fade a palette toward a target color and snap it back.
//
// Part of the BLIT386 series.
//
// Prerequisites:
//   Basics            https://demos.blit386.dev/basics
//   Primitives        https://demos.blit386.dev/primitives
//   Palette Presets   https://demos.blit386.dev/palette-presets
//   Palette Animation https://demos.blit386.dev/palette-animation
//   Palette Cycling   https://demos.blit386.dev/palette-cycling
//     (guides: https://blit386.dev/docs/guides/palette-presets,
//      https://blit386.dev/docs/guides/palette#runtime-palette-effects)
//
// Live version: https://demos.blit386.dev/palette-fade
// Guide: https://blit386.dev/docs/guides/palette#runtime-palette-effects
//
// WHAT ARE PALETTE FADES?
//
// Imagine you have two sets of paint buckets: one for a sunny day, one for a
// dark night. A "palette fade" gradually mixes the day paints with the night
// paints over several seconds, so the whole picture smoothly transitions from
// bright to dark - like watching a sunset.
//
// BLIT386 does this with BT.paletteFade(targetPalette, durationMs, easing).
// You give it the destination paint set, how long the transition should take,
// and optionally a curve that controls how fast the change happens ("ease-in"
// starts slow, "ease-out" starts fast, "ease-in-out" is smooth on both ends).
//
// WHAT IS A PALETTE FLASH?
//
// A "flash" instantly turns every color to one single color (like white for
// lightning) for a short moment, then snaps everything back to normal.
// BT.paletteFlash(color, durationMs) does this in one call.
//
// UPDATE VS RENDER (palette work split):
//   init() builds separate day and night Palette objects and activates the day set.
//   update() runs the day/night state machine and calls BT.paletteFade() or
//   BT.paletteFlash() once per phase - the engine blends active palette slots over time.
//   render() draws the same landscape geometry every frame using palette indices only;
//   sky, trees, and ground change color because the engine updated the palette, not
//   because render() passes new Color32 values to draw calls.
//
// The phase caption panel is drawn with the shared UI kit (src/shared/ui.js). Its theme
// colors live in slots 240..251 - and because BT.paletteFade() blends EVERY slot toward
// the target palette, init() writes the same theme colors into the day and night target
// palettes too. That makes the UI slots "fade" from a color to the identical color, so
// the panel stays readable while the whole scene transitions around it.
//
// WHAT YOU WILL SEE:
//   A pixel-art landscape (sky, ground, trees, sun) that loops through:
//   1. Day (bright)   - hold 3 seconds
//   2. Fade to night  - 2 seconds, ease-in-out
//   3. Night (dark)   - hold 3 seconds
//   4. Lightning flash - 200 ms white flash
//   5. Night hold     - 2 seconds
//   6. Fade to day    - 2 seconds, ease-out (dawn)
//   Repeat forever.
//   The current phase (Day, Night, Dawn, etc.) shows in a UI kit panel in the top-left
//   corner, and also as an engine overlay row above the FPS bar.

import { function bootstrap(DemoClass: DemoConstructor, options?: BootstrapOptions): Promise<boolean>
One-liner bootstrap function for BLIT386 demos. Handles canvas retrieval and engine initialization. Backend selection (WebGPU or software fallback) is managed internally by BTAPI. This function provides a streamlined way to start a demo with sensible defaults while allowing customization through options.
@since0.2.0@changed1.4.0 Calling `bootstrap()` again while already initialized now routes to a hot swap (via {@link registerHotReload}) when a Vite HMR context is registered, or logs a double-bootstrap guard and returns `false` otherwise - previously it silently started a second, unstoppable `GameLoop`.@changed1.7.0 Exposes `BT` on `window.BT` after bootstrap finishes, gated by {@link BootstrapOptions.exposeGlobal} (default: {@link BT.isDevMode}).@paramDemoClass - Demo class constructor implementing `IBTDemo` (optional `configure()` for hardware settings).@paramoptions - Optional configuration for IDs and callbacks.@returns`true` when the demo boots successfully; otherwise `false`.@example// Simplest usage - uses default IDs. bootstrap(MyDemo);@example// With custom options. bootstrap(MyDemo, { canvasID: 'custom-canvas', containerID: 'custom-container', onSuccess: () => console.log('Demo started!'), onError: (err) => analytics.trackError(err), });@example// Await the result. const success = await bootstrap(MyDemo); if (success) { console.log('Demo is running'); }
bootstrap
,
const BT: {
    FLIP_H: number;
    FLIP_V: number;
    ROT_90_CW: number;
    ROT_180_CW: number;
    ROT_270_CW: number;
    BTN_UP: number;
    BTN_DOWN: number;
    BTN_LEFT: number;
    BTN_RIGHT: number;
    BTN_A: number;
    BTN_B: number;
    BTN_X: number;
    BTN_Y: number;
    BTN_L: number;
    BTN_R: number;
    BTN_START: number;
    BTN_SELECT: number;
    BTN_POINTER_A: number;
    BTN_POINTER_B: number;
    BTN_POINTER_C: number;
    BTN_POINTER_D: number;
    PLAYER_ONE: number;
    PLAYER_TWO: number;
    PLAYER_THREE: number;
    PLAYER_FOUR: number;
    AXIS_LEFT_X: number;
    AXIS_LEFT_Y: number;
    AXIS_RIGHT_X: number;
    AXIS_RIGHT_Y: number;
    AXIS_TRIGGER_L: number;
    ... 106 more ...;
    spritesRefresh: () => void;
}
Main BLIT386 API namespace used by runtime demos.
BT
, class Color32
Mutable 32-bit RGBA color value with 8-bit channels.
@since0.1.0
Color32
, class Rect2i
Integer rectangle for pixel-perfect bounds and regions. Used throughout the engine for sprite regions, display-space bounds, and zero-allocation geometry helpers. Both convenience getters and allocation-free `*To()` helpers are provided so callers can choose between readability and hot-path efficiency.
@since0.1.0
Rect2i
, class Vector2i
Integer 2D vector for pixel-perfect positioning. Used for points, sizes, directions, and camera offsets throughout the engine. The API includes both allocation-free `*To()` / `*InPlace()` variants and convenience methods that return new vectors.
@since0.1.0
Vector2i
} from 'blit386';
import { import applyThemeapplyTheme, import uiui, import UI_ANCHORSUI_ANCHORS } from './shared/ui.js'; /** @typedef {import('blit386').IBTDemo} IBTDemo */ /** @typedef {import('blit386').HardwareSettings} HardwareSettings */ /** @typedef {import('blit386').Palette} Palette */ // Phase durations in ticks (at 60 FPS, 60 ticks = 1 second). const const PHASE_DAY_HOLD: 180PHASE_DAY_HOLD = 180; // 3 seconds const const PHASE_FADE_TO_NIGHT: 120PHASE_FADE_TO_NIGHT = 120; // 2 seconds const const PHASE_NIGHT_HOLD: 180PHASE_NIGHT_HOLD = 180; // 3 seconds const const PHASE_FLASH: 12PHASE_FLASH = 12; // 200 ms const const PHASE_NIGHT_HOLD_2: 120PHASE_NIGHT_HOLD_2 = 120; // 2 seconds const const PHASE_FADE_TO_DAY: 120PHASE_FADE_TO_DAY = 120; // 2 seconds // Fixed day/night cycle graph: each phase holds for `duration` ticks, then advances to `next`. const
const PHASE_TRANSITIONS: {
    day: {
        duration: number;
        next: string;
    };
    'fade-to-night': {
        duration: number;
        next: string;
    };
    night: {
        duration: number;
        next: string;
    };
    flash: {
        duration: number;
        next: string;
    };
    'night-2': {
        duration: number;
        next: string;
    };
    'fade-to-day': {
        duration: number;
        next: string;
    };
}
PHASE_TRANSITIONS
= {
day: {
    duration: number;
    next: string;
}
day
: { duration: numberduration: const PHASE_DAY_HOLD: 180PHASE_DAY_HOLD, next: stringnext: 'fade-to-night' },
'fade-to-night': { duration: numberduration: const PHASE_FADE_TO_NIGHT: 120PHASE_FADE_TO_NIGHT, next: stringnext: 'night' },
night: {
    duration: number;
    next: string;
}
night
: { duration: numberduration: const PHASE_NIGHT_HOLD: 180PHASE_NIGHT_HOLD, next: stringnext: 'flash' },
flash: {
    duration: number;
    next: string;
}
flash
: { duration: numberduration: const PHASE_FLASH: 12PHASE_FLASH, next: stringnext: 'night-2' },
'night-2': { duration: numberduration: const PHASE_NIGHT_HOLD_2: 120PHASE_NIGHT_HOLD_2, next: stringnext: 'fade-to-day' }, 'fade-to-day': { duration: numberduration: const PHASE_FADE_TO_DAY: 120PHASE_FADE_TO_DAY, next: stringnext: 'day' }, }; // Slot 0: always transparent. const const C_LABEL: 3C_LABEL = 3; const const C_DIM: 4C_DIM = 4; const const C_OVERLAY_BAR: 6C_OVERLAY_BAR = 6; // Overlay row background (same in day and night palettes) // Scene colors: sky, sun, ground, tree trunk, tree leaves, flowers. const const C_SKY: 10C_SKY = 10; const const C_SKY_LIGHT: 11C_SKY_LIGHT = 11; const const C_SUN: 12C_SUN = 12; const const C_SUN_GLOW: 13C_SUN_GLOW = 13; const const C_GROUND: 14C_GROUND = 14; const const C_GROUND_DARK: 15C_GROUND_DARK = 15; const const C_TRUNK: 16C_TRUNK = 16; const const C_LEAVES: 17C_LEAVES = 17; const const C_LEAVES_LIGHT: 18C_LEAVES_LIGHT = 18; const const C_FLOWER_1: 19C_FLOWER_1 = 19; const const C_FLOWER_2: 20C_FLOWER_2 = 20; const const C_CLOUD: 21C_CLOUD = 21; const const C_MOUNTAIN: 22C_MOUNTAIN = 22; const const C_MOUNTAIN_LIGHT: 23C_MOUNTAIN_LIGHT = 23; /** * Builds the "day" palette - bright, saturated outdoor colors. * * @param {Palette} p - Palette to fill. */ function function fillDay(p: Palette): void
Builds the "day" palette - bright, saturated outdoor colors.
@paramp - Palette to fill.
fillDay
(p: Palette
- Palette to fill.
@paramp - Palette to fill.
p
) {
p: Palette
- Palette to fill.
@paramp - Palette to fill.
p
.Palette.set(index: number, color: Color32): void
Writes a color into a palette slot.
@paramindex - Palette index to overwrite.@paramcolor - Color to store.@throwsError if the index is invalid or if index `0` is set opaque.
set
(const C_LABEL: 3C_LABEL, new new Color32(r?: number, g?: number, b?: number, a?: number): Color32
Creates a clamped 8-bit RGBA color.
@paramr - Red channel (0-255, defaults to 255).@paramg - Green channel (0-255, defaults to 255).@paramb - Blue channel (0-255, defaults to 255).@parama - Alpha channel (0-255, defaults to 255 = opaque).
Color32
(255, 210, 80));
p: Palette
- Palette to fill.
@paramp - Palette to fill.
p
.Palette.set(index: number, color: Color32): void
Writes a color into a palette slot.
@paramindex - Palette index to overwrite.@paramcolor - Color to store.@throwsError if the index is invalid or if index `0` is set opaque.
set
(const C_DIM: 4C_DIM, new new Color32(r?: number, g?: number, b?: number, a?: number): Color32
Creates a clamped 8-bit RGBA color.
@paramr - Red channel (0-255, defaults to 255).@paramg - Green channel (0-255, defaults to 255).@paramb - Blue channel (0-255, defaults to 255).@parama - Alpha channel (0-255, defaults to 255 = opaque).
Color32
(120, 130, 160));
p: Palette
- Palette to fill.
@paramp - Palette to fill.
p
.Palette.set(index: number, color: Color32): void
Writes a color into a palette slot.
@paramindex - Palette index to overwrite.@paramcolor - Color to store.@throwsError if the index is invalid or if index `0` is set opaque.
set
(const C_OVERLAY_BAR: 6C_OVERLAY_BAR, new new Color32(r?: number, g?: number, b?: number, a?: number): Color32
Creates a clamped 8-bit RGBA color.
@paramr - Red channel (0-255, defaults to 255).@paramg - Green channel (0-255, defaults to 255).@paramb - Blue channel (0-255, defaults to 255).@parama - Alpha channel (0-255, defaults to 255 = opaque).
Color32
(0, 0, 0, 200));
p: Palette
- Palette to fill.
@paramp - Palette to fill.
p
.Palette.set(index: number, color: Color32): void
Writes a color into a palette slot.
@paramindex - Palette index to overwrite.@paramcolor - Color to store.@throwsError if the index is invalid or if index `0` is set opaque.
set
(const C_SKY: 10C_SKY, new new Color32(r?: number, g?: number, b?: number, a?: number): Color32
Creates a clamped 8-bit RGBA color.
@paramr - Red channel (0-255, defaults to 255).@paramg - Green channel (0-255, defaults to 255).@paramb - Blue channel (0-255, defaults to 255).@parama - Alpha channel (0-255, defaults to 255 = opaque).
Color32
(100, 170, 255));
p: Palette
- Palette to fill.
@paramp - Palette to fill.
p
.Palette.set(index: number, color: Color32): void
Writes a color into a palette slot.
@paramindex - Palette index to overwrite.@paramcolor - Color to store.@throwsError if the index is invalid or if index `0` is set opaque.
set
(const C_SKY_LIGHT: 11C_SKY_LIGHT, new new Color32(r?: number, g?: number, b?: number, a?: number): Color32
Creates a clamped 8-bit RGBA color.
@paramr - Red channel (0-255, defaults to 255).@paramg - Green channel (0-255, defaults to 255).@paramb - Blue channel (0-255, defaults to 255).@parama - Alpha channel (0-255, defaults to 255 = opaque).
Color32
(150, 200, 255));
p: Palette
- Palette to fill.
@paramp - Palette to fill.
p
.Palette.set(index: number, color: Color32): void
Writes a color into a palette slot.
@paramindex - Palette index to overwrite.@paramcolor - Color to store.@throwsError if the index is invalid or if index `0` is set opaque.
set
(const C_SUN: 12C_SUN, new new Color32(r?: number, g?: number, b?: number, a?: number): Color32
Creates a clamped 8-bit RGBA color.
@paramr - Red channel (0-255, defaults to 255).@paramg - Green channel (0-255, defaults to 255).@paramb - Blue channel (0-255, defaults to 255).@parama - Alpha channel (0-255, defaults to 255 = opaque).
Color32
(255, 240, 100));
p: Palette
- Palette to fill.
@paramp - Palette to fill.
p
.Palette.set(index: number, color: Color32): void
Writes a color into a palette slot.
@paramindex - Palette index to overwrite.@paramcolor - Color to store.@throwsError if the index is invalid or if index `0` is set opaque.
set
(const C_SUN_GLOW: 13C_SUN_GLOW, new new Color32(r?: number, g?: number, b?: number, a?: number): Color32
Creates a clamped 8-bit RGBA color.
@paramr - Red channel (0-255, defaults to 255).@paramg - Green channel (0-255, defaults to 255).@paramb - Blue channel (0-255, defaults to 255).@parama - Alpha channel (0-255, defaults to 255 = opaque).
Color32
(255, 255, 180));
p: Palette
- Palette to fill.
@paramp - Palette to fill.
p
.Palette.set(index: number, color: Color32): void
Writes a color into a palette slot.
@paramindex - Palette index to overwrite.@paramcolor - Color to store.@throwsError if the index is invalid or if index `0` is set opaque.
set
(const C_GROUND: 14C_GROUND, new new Color32(r?: number, g?: number, b?: number, a?: number): Color32
Creates a clamped 8-bit RGBA color.
@paramr - Red channel (0-255, defaults to 255).@paramg - Green channel (0-255, defaults to 255).@paramb - Blue channel (0-255, defaults to 255).@parama - Alpha channel (0-255, defaults to 255 = opaque).
Color32
(80, 160, 60));
p: Palette
- Palette to fill.
@paramp - Palette to fill.
p
.Palette.set(index: number, color: Color32): void
Writes a color into a palette slot.
@paramindex - Palette index to overwrite.@paramcolor - Color to store.@throwsError if the index is invalid or if index `0` is set opaque.
set
(const C_GROUND_DARK: 15C_GROUND_DARK, new new Color32(r?: number, g?: number, b?: number, a?: number): Color32
Creates a clamped 8-bit RGBA color.
@paramr - Red channel (0-255, defaults to 255).@paramg - Green channel (0-255, defaults to 255).@paramb - Blue channel (0-255, defaults to 255).@parama - Alpha channel (0-255, defaults to 255 = opaque).
Color32
(50, 120, 40));
p: Palette
- Palette to fill.
@paramp - Palette to fill.
p
.Palette.set(index: number, color: Color32): void
Writes a color into a palette slot.
@paramindex - Palette index to overwrite.@paramcolor - Color to store.@throwsError if the index is invalid or if index `0` is set opaque.
set
(const C_TRUNK: 16C_TRUNK, new new Color32(r?: number, g?: number, b?: number, a?: number): Color32
Creates a clamped 8-bit RGBA color.
@paramr - Red channel (0-255, defaults to 255).@paramg - Green channel (0-255, defaults to 255).@paramb - Blue channel (0-255, defaults to 255).@parama - Alpha channel (0-255, defaults to 255 = opaque).
Color32
(100, 60, 30));
p: Palette
- Palette to fill.
@paramp - Palette to fill.
p
.Palette.set(index: number, color: Color32): void
Writes a color into a palette slot.
@paramindex - Palette index to overwrite.@paramcolor - Color to store.@throwsError if the index is invalid or if index `0` is set opaque.
set
(const C_LEAVES: 17C_LEAVES, new new Color32(r?: number, g?: number, b?: number, a?: number): Color32
Creates a clamped 8-bit RGBA color.
@paramr - Red channel (0-255, defaults to 255).@paramg - Green channel (0-255, defaults to 255).@paramb - Blue channel (0-255, defaults to 255).@parama - Alpha channel (0-255, defaults to 255 = opaque).
Color32
(40, 140, 50));
p: Palette
- Palette to fill.
@paramp - Palette to fill.
p
.Palette.set(index: number, color: Color32): void
Writes a color into a palette slot.
@paramindex - Palette index to overwrite.@paramcolor - Color to store.@throwsError if the index is invalid or if index `0` is set opaque.
set
(const C_LEAVES_LIGHT: 18C_LEAVES_LIGHT, new new Color32(r?: number, g?: number, b?: number, a?: number): Color32
Creates a clamped 8-bit RGBA color.
@paramr - Red channel (0-255, defaults to 255).@paramg - Green channel (0-255, defaults to 255).@paramb - Blue channel (0-255, defaults to 255).@parama - Alpha channel (0-255, defaults to 255 = opaque).
Color32
(80, 180, 70));
p: Palette
- Palette to fill.
@paramp - Palette to fill.
p
.Palette.set(index: number, color: Color32): void
Writes a color into a palette slot.
@paramindex - Palette index to overwrite.@paramcolor - Color to store.@throwsError if the index is invalid or if index `0` is set opaque.
set
(const C_FLOWER_1: 19C_FLOWER_1, new new Color32(r?: number, g?: number, b?: number, a?: number): Color32
Creates a clamped 8-bit RGBA color.
@paramr - Red channel (0-255, defaults to 255).@paramg - Green channel (0-255, defaults to 255).@paramb - Blue channel (0-255, defaults to 255).@parama - Alpha channel (0-255, defaults to 255 = opaque).
Color32
(255, 80, 120));
p: Palette
- Palette to fill.
@paramp - Palette to fill.
p
.Palette.set(index: number, color: Color32): void
Writes a color into a palette slot.
@paramindex - Palette index to overwrite.@paramcolor - Color to store.@throwsError if the index is invalid or if index `0` is set opaque.
set
(const C_FLOWER_2: 20C_FLOWER_2, new new Color32(r?: number, g?: number, b?: number, a?: number): Color32
Creates a clamped 8-bit RGBA color.
@paramr - Red channel (0-255, defaults to 255).@paramg - Green channel (0-255, defaults to 255).@paramb - Blue channel (0-255, defaults to 255).@parama - Alpha channel (0-255, defaults to 255 = opaque).
Color32
(255, 200, 60));
p: Palette
- Palette to fill.
@paramp - Palette to fill.
p
.Palette.set(index: number, color: Color32): void
Writes a color into a palette slot.
@paramindex - Palette index to overwrite.@paramcolor - Color to store.@throwsError if the index is invalid or if index `0` is set opaque.
set
(const C_CLOUD: 21C_CLOUD, new new Color32(r?: number, g?: number, b?: number, a?: number): Color32
Creates a clamped 8-bit RGBA color.
@paramr - Red channel (0-255, defaults to 255).@paramg - Green channel (0-255, defaults to 255).@paramb - Blue channel (0-255, defaults to 255).@parama - Alpha channel (0-255, defaults to 255 = opaque).
Color32
(240, 245, 255));
p: Palette
- Palette to fill.
@paramp - Palette to fill.
p
.Palette.set(index: number, color: Color32): void
Writes a color into a palette slot.
@paramindex - Palette index to overwrite.@paramcolor - Color to store.@throwsError if the index is invalid or if index `0` is set opaque.
set
(const C_MOUNTAIN: 22C_MOUNTAIN, new new Color32(r?: number, g?: number, b?: number, a?: number): Color32
Creates a clamped 8-bit RGBA color.
@paramr - Red channel (0-255, defaults to 255).@paramg - Green channel (0-255, defaults to 255).@paramb - Blue channel (0-255, defaults to 255).@parama - Alpha channel (0-255, defaults to 255 = opaque).
Color32
(100, 110, 140));
p: Palette
- Palette to fill.
@paramp - Palette to fill.
p
.Palette.set(index: number, color: Color32): void
Writes a color into a palette slot.
@paramindex - Palette index to overwrite.@paramcolor - Color to store.@throwsError if the index is invalid or if index `0` is set opaque.
set
(const C_MOUNTAIN_LIGHT: 23C_MOUNTAIN_LIGHT, new new Color32(r?: number, g?: number, b?: number, a?: number): Color32
Creates a clamped 8-bit RGBA color.
@paramr - Red channel (0-255, defaults to 255).@paramg - Green channel (0-255, defaults to 255).@paramb - Blue channel (0-255, defaults to 255).@parama - Alpha channel (0-255, defaults to 255 = opaque).
Color32
(140, 150, 175));
} /** * Builds the "night" palette - dark, desaturated blues and purples. * * @param {Palette} p - Palette to fill. */ function function fillNight(p: Palette): void
Builds the "night" palette - dark, desaturated blues and purples.
@paramp - Palette to fill.
fillNight
(p: Palette
- Palette to fill.
@paramp - Palette to fill.
p
) {
p: Palette
- Palette to fill.
@paramp - Palette to fill.
p
.Palette.set(index: number, color: Color32): void
Writes a color into a palette slot.
@paramindex - Palette index to overwrite.@paramcolor - Color to store.@throwsError if the index is invalid or if index `0` is set opaque.
set
(const C_LABEL: 3C_LABEL, new new Color32(r?: number, g?: number, b?: number, a?: number): Color32
Creates a clamped 8-bit RGBA color.
@paramr - Red channel (0-255, defaults to 255).@paramg - Green channel (0-255, defaults to 255).@paramb - Blue channel (0-255, defaults to 255).@parama - Alpha channel (0-255, defaults to 255 = opaque).
Color32
(180, 160, 100));
p: Palette
- Palette to fill.
@paramp - Palette to fill.
p
.Palette.set(index: number, color: Color32): void
Writes a color into a palette slot.
@paramindex - Palette index to overwrite.@paramcolor - Color to store.@throwsError if the index is invalid or if index `0` is set opaque.
set
(const C_DIM: 4C_DIM, new new Color32(r?: number, g?: number, b?: number, a?: number): Color32
Creates a clamped 8-bit RGBA color.
@paramr - Red channel (0-255, defaults to 255).@paramg - Green channel (0-255, defaults to 255).@paramb - Blue channel (0-255, defaults to 255).@parama - Alpha channel (0-255, defaults to 255 = opaque).
Color32
(80, 80, 110));
p: Palette
- Palette to fill.
@paramp - Palette to fill.
p
.Palette.set(index: number, color: Color32): void
Writes a color into a palette slot.
@paramindex - Palette index to overwrite.@paramcolor - Color to store.@throwsError if the index is invalid or if index `0` is set opaque.
set
(const C_OVERLAY_BAR: 6C_OVERLAY_BAR, new new Color32(r?: number, g?: number, b?: number, a?: number): Color32
Creates a clamped 8-bit RGBA color.
@paramr - Red channel (0-255, defaults to 255).@paramg - Green channel (0-255, defaults to 255).@paramb - Blue channel (0-255, defaults to 255).@parama - Alpha channel (0-255, defaults to 255 = opaque).
Color32
(0, 0, 0, 200));
p: Palette
- Palette to fill.
@paramp - Palette to fill.
p
.Palette.set(index: number, color: Color32): void
Writes a color into a palette slot.
@paramindex - Palette index to overwrite.@paramcolor - Color to store.@throwsError if the index is invalid or if index `0` is set opaque.
set
(const C_SKY: 10C_SKY, new new Color32(r?: number, g?: number, b?: number, a?: number): Color32
Creates a clamped 8-bit RGBA color.
@paramr - Red channel (0-255, defaults to 255).@paramg - Green channel (0-255, defaults to 255).@paramb - Blue channel (0-255, defaults to 255).@parama - Alpha channel (0-255, defaults to 255 = opaque).
Color32
(15, 20, 50));
p: Palette
- Palette to fill.
@paramp - Palette to fill.
p
.Palette.set(index: number, color: Color32): void
Writes a color into a palette slot.
@paramindex - Palette index to overwrite.@paramcolor - Color to store.@throwsError if the index is invalid or if index `0` is set opaque.
set
(const C_SKY_LIGHT: 11C_SKY_LIGHT, new new Color32(r?: number, g?: number, b?: number, a?: number): Color32
Creates a clamped 8-bit RGBA color.
@paramr - Red channel (0-255, defaults to 255).@paramg - Green channel (0-255, defaults to 255).@paramb - Blue channel (0-255, defaults to 255).@parama - Alpha channel (0-255, defaults to 255 = opaque).
Color32
(25, 35, 70));
p: Palette
- Palette to fill.
@paramp - Palette to fill.
p
.Palette.set(index: number, color: Color32): void
Writes a color into a palette slot.
@paramindex - Palette index to overwrite.@paramcolor - Color to store.@throwsError if the index is invalid or if index `0` is set opaque.
set
(const C_SUN: 12C_SUN, new new Color32(r?: number, g?: number, b?: number, a?: number): Color32
Creates a clamped 8-bit RGBA color.
@paramr - Red channel (0-255, defaults to 255).@paramg - Green channel (0-255, defaults to 255).@paramb - Blue channel (0-255, defaults to 255).@parama - Alpha channel (0-255, defaults to 255 = opaque).
Color32
(200, 200, 160));
p: Palette
- Palette to fill.
@paramp - Palette to fill.
p
.Palette.set(index: number, color: Color32): void
Writes a color into a palette slot.
@paramindex - Palette index to overwrite.@paramcolor - Color to store.@throwsError if the index is invalid or if index `0` is set opaque.
set
(const C_SUN_GLOW: 13C_SUN_GLOW, new new Color32(r?: number, g?: number, b?: number, a?: number): Color32
Creates a clamped 8-bit RGBA color.
@paramr - Red channel (0-255, defaults to 255).@paramg - Green channel (0-255, defaults to 255).@paramb - Blue channel (0-255, defaults to 255).@parama - Alpha channel (0-255, defaults to 255 = opaque).
Color32
(60, 60, 80));
p: Palette
- Palette to fill.
@paramp - Palette to fill.
p
.Palette.set(index: number, color: Color32): void
Writes a color into a palette slot.
@paramindex - Palette index to overwrite.@paramcolor - Color to store.@throwsError if the index is invalid or if index `0` is set opaque.
set
(const C_GROUND: 14C_GROUND, new new Color32(r?: number, g?: number, b?: number, a?: number): Color32
Creates a clamped 8-bit RGBA color.
@paramr - Red channel (0-255, defaults to 255).@paramg - Green channel (0-255, defaults to 255).@paramb - Blue channel (0-255, defaults to 255).@parama - Alpha channel (0-255, defaults to 255 = opaque).
Color32
(20, 50, 30));
p: Palette
- Palette to fill.
@paramp - Palette to fill.
p
.Palette.set(index: number, color: Color32): void
Writes a color into a palette slot.
@paramindex - Palette index to overwrite.@paramcolor - Color to store.@throwsError if the index is invalid or if index `0` is set opaque.
set
(const C_GROUND_DARK: 15C_GROUND_DARK, new new Color32(r?: number, g?: number, b?: number, a?: number): Color32
Creates a clamped 8-bit RGBA color.
@paramr - Red channel (0-255, defaults to 255).@paramg - Green channel (0-255, defaults to 255).@paramb - Blue channel (0-255, defaults to 255).@parama - Alpha channel (0-255, defaults to 255 = opaque).
Color32
(15, 35, 20));
p: Palette
- Palette to fill.
@paramp - Palette to fill.
p
.Palette.set(index: number, color: Color32): void
Writes a color into a palette slot.
@paramindex - Palette index to overwrite.@paramcolor - Color to store.@throwsError if the index is invalid or if index `0` is set opaque.
set
(const C_TRUNK: 16C_TRUNK, new new Color32(r?: number, g?: number, b?: number, a?: number): Color32
Creates a clamped 8-bit RGBA color.
@paramr - Red channel (0-255, defaults to 255).@paramg - Green channel (0-255, defaults to 255).@paramb - Blue channel (0-255, defaults to 255).@parama - Alpha channel (0-255, defaults to 255 = opaque).
Color32
(40, 25, 15));
p: Palette
- Palette to fill.
@paramp - Palette to fill.
p
.Palette.set(index: number, color: Color32): void
Writes a color into a palette slot.
@paramindex - Palette index to overwrite.@paramcolor - Color to store.@throwsError if the index is invalid or if index `0` is set opaque.
set
(const C_LEAVES: 17C_LEAVES, new new Color32(r?: number, g?: number, b?: number, a?: number): Color32
Creates a clamped 8-bit RGBA color.
@paramr - Red channel (0-255, defaults to 255).@paramg - Green channel (0-255, defaults to 255).@paramb - Blue channel (0-255, defaults to 255).@parama - Alpha channel (0-255, defaults to 255 = opaque).
Color32
(15, 50, 25));
p: Palette
- Palette to fill.
@paramp - Palette to fill.
p
.Palette.set(index: number, color: Color32): void
Writes a color into a palette slot.
@paramindex - Palette index to overwrite.@paramcolor - Color to store.@throwsError if the index is invalid or if index `0` is set opaque.
set
(const C_LEAVES_LIGHT: 18C_LEAVES_LIGHT, new new Color32(r?: number, g?: number, b?: number, a?: number): Color32
Creates a clamped 8-bit RGBA color.
@paramr - Red channel (0-255, defaults to 255).@paramg - Green channel (0-255, defaults to 255).@paramb - Blue channel (0-255, defaults to 255).@parama - Alpha channel (0-255, defaults to 255 = opaque).
Color32
(25, 65, 35));
p: Palette
- Palette to fill.
@paramp - Palette to fill.
p
.Palette.set(index: number, color: Color32): void
Writes a color into a palette slot.
@paramindex - Palette index to overwrite.@paramcolor - Color to store.@throwsError if the index is invalid or if index `0` is set opaque.
set
(const C_FLOWER_1: 19C_FLOWER_1, new new Color32(r?: number, g?: number, b?: number, a?: number): Color32
Creates a clamped 8-bit RGBA color.
@paramr - Red channel (0-255, defaults to 255).@paramg - Green channel (0-255, defaults to 255).@paramb - Blue channel (0-255, defaults to 255).@parama - Alpha channel (0-255, defaults to 255 = opaque).
Color32
(100, 30, 50));
p: Palette
- Palette to fill.
@paramp - Palette to fill.
p
.Palette.set(index: number, color: Color32): void
Writes a color into a palette slot.
@paramindex - Palette index to overwrite.@paramcolor - Color to store.@throwsError if the index is invalid or if index `0` is set opaque.
set
(const C_FLOWER_2: 20C_FLOWER_2, new new Color32(r?: number, g?: number, b?: number, a?: number): Color32
Creates a clamped 8-bit RGBA color.
@paramr - Red channel (0-255, defaults to 255).@paramg - Green channel (0-255, defaults to 255).@paramb - Blue channel (0-255, defaults to 255).@parama - Alpha channel (0-255, defaults to 255 = opaque).
Color32
(100, 80, 30));
p: Palette
- Palette to fill.
@paramp - Palette to fill.
p
.Palette.set(index: number, color: Color32): void
Writes a color into a palette slot.
@paramindex - Palette index to overwrite.@paramcolor - Color to store.@throwsError if the index is invalid or if index `0` is set opaque.
set
(const C_CLOUD: 21C_CLOUD, new new Color32(r?: number, g?: number, b?: number, a?: number): Color32
Creates a clamped 8-bit RGBA color.
@paramr - Red channel (0-255, defaults to 255).@paramg - Green channel (0-255, defaults to 255).@paramb - Blue channel (0-255, defaults to 255).@parama - Alpha channel (0-255, defaults to 255 = opaque).
Color32
(40, 45, 60));
p: Palette
- Palette to fill.
@paramp - Palette to fill.
p
.Palette.set(index: number, color: Color32): void
Writes a color into a palette slot.
@paramindex - Palette index to overwrite.@paramcolor - Color to store.@throwsError if the index is invalid or if index `0` is set opaque.
set
(const C_MOUNTAIN: 22C_MOUNTAIN, new new Color32(r?: number, g?: number, b?: number, a?: number): Color32
Creates a clamped 8-bit RGBA color.
@paramr - Red channel (0-255, defaults to 255).@paramg - Green channel (0-255, defaults to 255).@paramb - Blue channel (0-255, defaults to 255).@parama - Alpha channel (0-255, defaults to 255 = opaque).
Color32
(30, 35, 55));
p: Palette
- Palette to fill.
@paramp - Palette to fill.
p
.Palette.set(index: number, color: Color32): void
Writes a color into a palette slot.
@paramindex - Palette index to overwrite.@paramcolor - Color to store.@throwsError if the index is invalid or if index `0` is set opaque.
set
(const C_MOUNTAIN_LIGHT: 23C_MOUNTAIN_LIGHT, new new Color32(r?: number, g?: number, b?: number, a?: number): Color32
Creates a clamped 8-bit RGBA color.
@paramr - Red channel (0-255, defaults to 255).@paramg - Green channel (0-255, defaults to 255).@paramb - Blue channel (0-255, defaults to 255).@parama - Alpha channel (0-255, defaults to 255 = opaque).
Color32
(45, 50, 70));
} /** * Demonstrates BT.paletteFade() and BT.paletteFlash(). * A pixel-art landscape transitions between day and night with smooth fades, * plus a lightning flash effect. * * @implements {IBTDemo} */ class class Demo
Demonstrates BT.paletteFade() and BT.paletteFlash(). A pixel-art landscape transitions between day and night with smooth fades, plus a lightning flash effect.
@implementsIBTDemo
Demo
{
/** @type {Palette | null} */ Demo.palette: Palette | null
@type{Palette | null}
palette
= null;
/** @type {Palette | null} */ Demo.day: Palette | null
@type{Palette | null}
day
= null;
/** @type {Palette | null} */ Demo.night: Palette | null
@type{Palette | null}
night
= null;
// Palette slot map for the shared UI kit theme, filled in init() by applyTheme(). // theme.text, theme.header, ... are palette indices ready for BT draw calls. Demo.theme: nulltheme = null; // Which phase of the day/night cycle we are in. Demo.phase: stringphase = 'day'; // Tick when the current phase started. Demo.phaseStartTick: numberphaseStartTick = 0; // Whether a fade/flash has been triggered for this phase. Demo.effectTriggered: booleaneffectTriggered = false; // Reused every frame for the overlay (current day/night phase label). Demo.overlayRowData: {}overlayRowData = [{ leftText: stringleftText: 'Day', textPaletteIndex: numbertextPaletteIndex: const C_LABEL: 3C_LABEL }]; /** * Palette slots for the engine overlay bars. * * @returns {Partial<HardwareSettings>} */ Demo.configure(): Partial<HardwareSettings>
Palette slots for the engine overlay bars.
@returns
configure
() {
return {
overlayStyle: {
    barPaletteIndex: number;
    textPaletteIndex: number;
    gapPaletteIndex: number;
}
overlayStyle
: {
barPaletteIndex: numberbarPaletteIndex: const C_OVERLAY_BAR: 6C_OVERLAY_BAR, textPaletteIndex: numbertextPaletteIndex: const C_LABEL: 3C_LABEL, gapPaletteIndex: numbergapPaletteIndex: const C_OVERLAY_BAR: 6C_OVERLAY_BAR, }, isOverlayTimingChartEnabled: booleanisOverlayTimingChartEnabled: true,
overlayTimingChartStyle: {
    updateBarPaletteIndex: number;
    renderBarPaletteIndex: number;
    warningPaletteIndex: number;
    errorPaletteIndex: number;
    tagPaletteIndex: number;
}
overlayTimingChartStyle
: {
updateBarPaletteIndex: numberupdateBarPaletteIndex: const C_LABEL: 3C_LABEL, renderBarPaletteIndex: numberrenderBarPaletteIndex: const C_SUN: 12C_SUN, warningPaletteIndex: numberwarningPaletteIndex: const C_SUN_GLOW: 13C_SUN_GLOW, errorPaletteIndex: numbererrorPaletteIndex: const C_FLOWER_2: 20C_FLOWER_2, tagPaletteIndex: numbertagPaletteIndex: const C_DIM: 4C_DIM, }, }; } /** * Creates day and night palettes and activates the day palette. * * @returns {Promise<boolean>} */ async Demo.init(): Promise<boolean>
Creates day and night palettes and activates the day palette.
@returns
init
() {
console.log('[PaletteFadeDemo] Initializing...'); // Build both palettes. this.Demo.day: Palette | null
@type{Palette | null}
day
=
const BT: {
    FLIP_H: number;
    FLIP_V: number;
    ROT_90_CW: number;
    ROT_180_CW: number;
    ROT_270_CW: number;
    BTN_UP: number;
    BTN_DOWN: number;
    BTN_LEFT: number;
    BTN_RIGHT: number;
    BTN_A: number;
    BTN_B: number;
    BTN_X: number;
    BTN_Y: number;
    BTN_L: number;
    BTN_R: number;
    BTN_START: number;
    BTN_SELECT: number;
    BTN_POINTER_A: number;
    BTN_POINTER_B: number;
    BTN_POINTER_C: number;
    BTN_POINTER_D: number;
    PLAYER_ONE: number;
    PLAYER_TWO: number;
    PLAYER_THREE: number;
    PLAYER_FOUR: number;
    AXIS_LEFT_X: number;
    AXIS_LEFT_Y: number;
    AXIS_RIGHT_X: number;
    AXIS_RIGHT_Y: number;
    AXIS_TRIGGER_L: number;
    ... 106 more ...;
    spritesRefresh: () => void;
}
Main BLIT386 API namespace used by runtime demos.
BT
.paletteCreate: (size?: number) => Palette
Creates a standalone palette instance.
@since1.0.3@paramsize - Palette size. Defaults to 256 colors.@returnsNew mutable palette.
paletteCreate
(256);
function fillDay(p: Palette): void
Builds the "day" palette - bright, saturated outdoor colors.
@paramp - Palette to fill.
fillDay
(this.Demo.day: Palette
@type{Palette | null}
day
);
this.Demo.night: Palette | null
@type{Palette | null}
night
=
const BT: {
    FLIP_H: number;
    FLIP_V: number;
    ROT_90_CW: number;
    ROT_180_CW: number;
    ROT_270_CW: number;
    BTN_UP: number;
    BTN_DOWN: number;
    BTN_LEFT: number;
    BTN_RIGHT: number;
    BTN_A: number;
    BTN_B: number;
    BTN_X: number;
    BTN_Y: number;
    BTN_L: number;
    BTN_R: number;
    BTN_START: number;
    BTN_SELECT: number;
    BTN_POINTER_A: number;
    BTN_POINTER_B: number;
    BTN_POINTER_C: number;
    BTN_POINTER_D: number;
    PLAYER_ONE: number;
    PLAYER_TWO: number;
    PLAYER_THREE: number;
    PLAYER_FOUR: number;
    AXIS_LEFT_X: number;
    AXIS_LEFT_Y: number;
    AXIS_RIGHT_X: number;
    AXIS_RIGHT_Y: number;
    AXIS_TRIGGER_L: number;
    ... 106 more ...;
    spritesRefresh: () => void;
}
Main BLIT386 API namespace used by runtime demos.
BT
.paletteCreate: (size?: number) => Palette
Creates a standalone palette instance.
@since1.0.3@paramsize - Palette size. Defaults to 256 colors.@returnsNew mutable palette.
paletteCreate
(256);
function fillNight(p: Palette): void
Builds the "night" palette - dark, desaturated blues and purples.
@paramp - Palette to fill.
fillNight
(this.Demo.night: Palette
@type{Palette | null}
night
);
// Start with the day palette. this.Demo.palette: Palette | null
@type{Palette | null}
palette
=
const BT: {
    FLIP_H: number;
    FLIP_V: number;
    ROT_90_CW: number;
    ROT_180_CW: number;
    ROT_270_CW: number;
    BTN_UP: number;
    BTN_DOWN: number;
    BTN_LEFT: number;
    BTN_RIGHT: number;
    BTN_A: number;
    BTN_B: number;
    BTN_X: number;
    BTN_Y: number;
    BTN_L: number;
    BTN_R: number;
    BTN_START: number;
    BTN_SELECT: number;
    BTN_POINTER_A: number;
    BTN_POINTER_B: number;
    BTN_POINTER_C: number;
    BTN_POINTER_D: number;
    PLAYER_ONE: number;
    PLAYER_TWO: number;
    PLAYER_THREE: number;
    PLAYER_FOUR: number;
    AXIS_LEFT_X: number;
    AXIS_LEFT_Y: number;
    AXIS_RIGHT_X: number;
    AXIS_RIGHT_Y: number;
    AXIS_TRIGGER_L: number;
    ... 106 more ...;
    spritesRefresh: () => void;
}
Main BLIT386 API namespace used by runtime demos.
BT
.paletteCreate: (size?: number) => Palette
Creates a standalone palette instance.
@since1.0.3@paramsize - Palette size. Defaults to 256 colors.@returnsNew mutable palette.
paletteCreate
(256);
function fillDay(p: Palette): void
Builds the "day" palette - bright, saturated outdoor colors.
@paramp - Palette to fill.
fillDay
(this.Demo.palette: Palette
@type{Palette | null}
palette
);
// Install the shared UI kit colors (slots 240..251) into ALL THREE palettes. // This matters because BT.paletteFade() blends every slot toward the target // palette - if the day and night targets left those slots at their default // black, the first fade would fade the UI colors away for good. Writing the // identical theme colors into the targets turns the UI slots into fixed // points: they "fade" from a color to the very same color, so nothing moves. // (BT.paletteFlash() still whites them out for 200 ms, but it snapshots and // restores every slot afterwards, so the flash heals itself - just like it // always did for the scene colors.) import applyThemeapplyTheme(this.Demo.day: Palette
@type{Palette | null}
day
);
import applyThemeapplyTheme(this.Demo.night: Palette
@type{Palette | null}
night
);
this.Demo.theme: nulltheme = import applyThemeapplyTheme(this.Demo.palette: Palette
@type{Palette | null}
palette
);
const BT: {
    FLIP_H: number;
    FLIP_V: number;
    ROT_90_CW: number;
    ROT_180_CW: number;
    ROT_270_CW: number;
    BTN_UP: number;
    BTN_DOWN: number;
    BTN_LEFT: number;
    BTN_RIGHT: number;
    BTN_A: number;
    BTN_B: number;
    BTN_X: number;
    BTN_Y: number;
    BTN_L: number;
    BTN_R: number;
    BTN_START: number;
    BTN_SELECT: number;
    BTN_POINTER_A: number;
    BTN_POINTER_B: number;
    BTN_POINTER_C: number;
    BTN_POINTER_D: number;
    PLAYER_ONE: number;
    PLAYER_TWO: number;
    PLAYER_THREE: number;
    PLAYER_FOUR: number;
    AXIS_LEFT_X: number;
    AXIS_LEFT_Y: number;
    AXIS_RIGHT_X: number;
    AXIS_RIGHT_Y: number;
    AXIS_TRIGGER_L: number;
    ... 106 more ...;
    spritesRefresh: () => void;
}
Main BLIT386 API namespace used by runtime demos.
BT
.paletteSet: (palette: Palette) => void
Stores the active engine palette. Use this to swap the **entire palette** (e.g. switch between a day and night theme). After this call the renderer uploads the new palette uniform on the next frame. **Palette-value swap (change what a slot looks like):** mutate the live {@link BT.palette } in place with `palette.set(slot, newColor)`. The renderer uploads dirty slots on the next frame; no `paletteSet()` or {@link BT.spritesRefresh } needed. **Palette-layout swap (same colors, different slot positions):** build a new palette with the same colors at new indices, call `paletteSet()`, then call {@link BT.spritesRefresh } so every sprite sheet re-maps its original RGBA pixels against the new slot layout.
@since1.0.3@parampalette - Palette to make active.
paletteSet
(this.Demo.palette: Palette
@type{Palette | null}
palette
);
console.log('[PaletteFadeDemo] Initialized'); return true; } /** * Manages the day/night cycle state machine. * Each phase triggers a palette effect at its start and waits for a duration. */ Demo.update(): void
Manages the day/night cycle state machine. Each phase triggers a palette effect at its start and waits for a duration.
update
() {
const const tick: numbertick =
const BT: {
    FLIP_H: number;
    FLIP_V: number;
    ROT_90_CW: number;
    ROT_180_CW: number;
    ROT_270_CW: number;
    BTN_UP: number;
    BTN_DOWN: number;
    BTN_LEFT: number;
    BTN_RIGHT: number;
    BTN_A: number;
    BTN_B: number;
    BTN_X: number;
    BTN_Y: number;
    BTN_L: number;
    BTN_R: number;
    BTN_START: number;
    BTN_SELECT: number;
    BTN_POINTER_A: number;
    BTN_POINTER_B: number;
    BTN_POINTER_C: number;
    BTN_POINTER_D: number;
    PLAYER_ONE: number;
    PLAYER_TWO: number;
    PLAYER_THREE: number;
    PLAYER_FOUR: number;
    AXIS_LEFT_X: number;
    AXIS_LEFT_Y: number;
    AXIS_RIGHT_X: number;
    AXIS_RIGHT_Y: number;
    AXIS_TRIGGER_L: number;
    ... 106 more ...;
    spritesRefresh: () => void;
}
Main BLIT386 API namespace used by runtime demos.
BT
.ticks: number
Current fixed-update tick counter. Increments once per engine update. Reset via {@link BT.ticksReset } .
@since1.0.4@returnsCurrent tick count since initialization or last reset.
ticks
;
const const elapsed: numberelapsed = const tick: numbertick - this.Demo.phaseStartTick: numberphaseStartTick; // Trigger the effect for this phase (only once). this.Demo.triggerPhaseEffect(): void
Fires the palette effect for the current phase, if not already triggered.
triggerPhaseEffect
();
// Check if the current phase has expired and advance to the next one. this.Demo.advancePhaseIfExpired(elapsed: number, tick: number): void
Checks whether the current phase has run long enough and advances to the next.
@paramelapsed - Ticks since the current phase started.@paramtick - Current tick count.
advancePhaseIfExpired
(const elapsed: numberelapsed, const tick: numbertick);
} /** * Draws the pixel-art landscape. The scene geometry never changes; only the * palette colors shift via the fade/flash effects running in update(). */ Demo.render(): void
Draws the pixel-art landscape. The scene geometry never changes; only the palette colors shift via the fade/flash effects running in update().
render
() {
// Sky fills the whole screen as background.
const BT: {
    FLIP_H: number;
    FLIP_V: number;
    ROT_90_CW: number;
    ROT_180_CW: number;
    ROT_270_CW: number;
    BTN_UP: number;
    BTN_DOWN: number;
    BTN_LEFT: number;
    BTN_RIGHT: number;
    BTN_A: number;
    BTN_B: number;
    BTN_X: number;
    BTN_Y: number;
    BTN_L: number;
    BTN_R: number;
    BTN_START: number;
    BTN_SELECT: number;
    BTN_POINTER_A: number;
    BTN_POINTER_B: number;
    BTN_POINTER_C: number;
    BTN_POINTER_D: number;
    PLAYER_ONE: number;
    PLAYER_TWO: number;
    PLAYER_THREE: number;
    PLAYER_FOUR: number;
    AXIS_LEFT_X: number;
    AXIS_LEFT_Y: number;
    AXIS_RIGHT_X: number;
    AXIS_RIGHT_Y: number;
    AXIS_TRIGGER_L: number;
    ... 106 more ...;
    spritesRefresh: () => void;
}
Main BLIT386 API namespace used by runtime demos.
BT
.clear: (paletteIndex: number) => void
Sets the frame clear color using a palette index. The renderer uses this color when clearing the full display at the start of the next frame.
@since0.1.0@parampaletteIndex - Palette index for the full-screen clear pass.
clear
(const C_SKY: 10C_SKY);
this.Demo.renderScene(): void
Draws the landscape: sky gradient, clouds, mountains, sun, ground, trees, flowers. All draw calls use palette indices only.
renderScene
();
// A small UI kit panel names the current phase, so viewers can follow the // cycle without opening the engine overlay. Its colors come from the theme // slots, which the fade leaves alone (see init()). import uiui.begin(import UI_ANCHORSUI_ANCHORS.TOP_LEFT); import uiui.panel('Palette Fade & Flash'); import uiui.label(this.Demo.getPhaseLabel(): string
Short label for the current day/night cycle phase.
@returns
getPhaseLabel
());
import uiui.end(); } /** * Current fade/flash phase for the engine overlay (Day, Night, Dawn, etc.). * * @returns {readonly { leftText: string }[]} */
Demo.overlayRows(): readonly {
    leftText: string;
}[]
Current fade/flash phase for the engine overlay (Day, Night, Dawn, etc.).
@returns
overlayRows
() {
this.Demo.overlayRowData: {}overlayRowData[0].leftText = this.Demo.getPhaseLabel(): string
Short label for the current day/night cycle phase.
@returns
getPhaseLabel
();
return this.Demo.overlayRowData: {}overlayRowData; } /** * Short label for the current day/night cycle phase. * * @returns {string} */ Demo.getPhaseLabel(): string
Short label for the current day/night cycle phase.
@returns
getPhaseLabel
() {
const
const phaseLabels: {
    day: string;
    'fade-to-night': string;
    night: string;
    flash: string;
    'night-2': string;
    'fade-to-day': string;
}
phaseLabels
= {
day: stringday: 'Day', 'fade-to-night': 'Fading to night... (ease-in-out)', night: stringnight: 'Night', flash: stringflash: 'Lightning flash!', 'night-2': 'Night', 'fade-to-day': 'Dawn... (ease-out)', }; return
const phaseLabels: {
    day: string;
    'fade-to-night': string;
    night: string;
    flash: string;
    'night-2': string;
    'fade-to-day': string;
}
phaseLabels
[this.Demo.phase: stringphase] ?? this.Demo.phase: stringphase;
} /** * Transitions to a new phase of the day/night cycle. * * @param {string} newPhase - Name of the phase to enter. * @param {number} tick - Current tick when the phase starts. */ Demo.startPhase(newPhase: string, tick: number): void
Transitions to a new phase of the day/night cycle.
@paramnewPhase - Name of the phase to enter.@paramtick - Current tick when the phase starts.
startPhase
(newPhase: string
- Name of the phase to enter.
@paramnewPhase - Name of the phase to enter.
newPhase
, tick: number
- Current tick when the phase starts.
@paramtick - Current tick when the phase starts.
tick
) {
this.Demo.phase: stringphase = newPhase: string
- Name of the phase to enter.
@paramnewPhase - Name of the phase to enter.
newPhase
;
this.Demo.phaseStartTick: numberphaseStartTick = tick: number
- Current tick when the phase starts.
@paramtick - Current tick when the phase starts.
tick
;
this.Demo.effectTriggered: booleaneffectTriggered = false; } /** * Fires the palette effect for the current phase, if not already triggered. */ Demo.triggerPhaseEffect(): void
Fires the palette effect for the current phase, if not already triggered.
triggerPhaseEffect
() {
if (this.Demo.effectTriggered: booleaneffectTriggered) { return; } if (this.Demo.phase: stringphase === 'fade-to-night') { // Smooth 2-second fade from current palette to night.
const BT: {
    FLIP_H: number;
    FLIP_V: number;
    ROT_90_CW: number;
    ROT_180_CW: number;
    ROT_270_CW: number;
    BTN_UP: number;
    BTN_DOWN: number;
    BTN_LEFT: number;
    BTN_RIGHT: number;
    BTN_A: number;
    BTN_B: number;
    BTN_X: number;
    BTN_Y: number;
    BTN_L: number;
    BTN_R: number;
    BTN_START: number;
    BTN_SELECT: number;
    BTN_POINTER_A: number;
    BTN_POINTER_B: number;
    BTN_POINTER_C: number;
    BTN_POINTER_D: number;
    PLAYER_ONE: number;
    PLAYER_TWO: number;
    PLAYER_THREE: number;
    PLAYER_FOUR: number;
    AXIS_LEFT_X: number;
    AXIS_LEFT_Y: number;
    AXIS_RIGHT_X: number;
    AXIS_RIGHT_Y: number;
    AXIS_TRIGGER_L: number;
    ... 106 more ...;
    spritesRefresh: () => void;
}
Main BLIT386 API namespace used by runtime demos.
BT
.paletteFade: (target: Palette, durationMs: number, easing?: EasingFunction) => void
Smoothly interpolates all palette entries toward a target over time. Snapshots the current palette at the moment this is called. Each frame the entries are lerped between the snapshot and target using the easing curve. Auto-removes when the fade completes. Common patterns: - Fade to black: `BT.paletteFade(blackPalette, 1000)` - Fade to white: `BT.paletteFade(whitePalette, 500)` - Cross-fade: `BT.paletteFade(nightPalette, 2000, 'ease-in-out')`
@since1.0.3@paramtarget - Target palette to fade toward.@paramdurationMs - Fade duration in milliseconds.@parameasing - Easing curve. Defaults to `'linear'`.
paletteFade
(this.Demo.night: Palette | null
@type{Palette | null}
night
, 2000, 'ease-in-out');
const BT: {
    FLIP_H: number;
    FLIP_V: number;
    ROT_90_CW: number;
    ROT_180_CW: number;
    ROT_270_CW: number;
    BTN_UP: number;
    BTN_DOWN: number;
    BTN_LEFT: number;
    BTN_RIGHT: number;
    BTN_A: number;
    BTN_B: number;
    BTN_X: number;
    BTN_Y: number;
    BTN_L: number;
    BTN_R: number;
    BTN_START: number;
    BTN_SELECT: number;
    BTN_POINTER_A: number;
    BTN_POINTER_B: number;
    BTN_POINTER_C: number;
    BTN_POINTER_D: number;
    PLAYER_ONE: number;
    PLAYER_TWO: number;
    PLAYER_THREE: number;
    PLAYER_FOUR: number;
    AXIS_LEFT_X: number;
    AXIS_LEFT_Y: number;
    AXIS_RIGHT_X: number;
    AXIS_RIGHT_Y: number;
    AXIS_TRIGGER_L: number;
    ... 106 more ...;
    spritesRefresh: () => void;
}
Main BLIT386 API namespace used by runtime demos.
BT
.assignTag: (label?: string) => void
Places a labeled marker on the overlay timing chart at the current tick. Requires `isOverlayTimingChartEnabled: true` in `configure()`. Tags scroll with the chart history and are pruned when they leave the visible window. Empty labels become `"Untitled"`. Chart width resets add an automatic `"Start"` tag.
@since1.1.0@paramlabel - Short event name (for example `'Round start'`).
assignTag
('Fade to night');
this.Demo.effectTriggered: booleaneffectTriggered = true; } else if (this.Demo.phase: stringphase === 'flash') { // Lightning! White flash for 200ms.
const BT: {
    FLIP_H: number;
    FLIP_V: number;
    ROT_90_CW: number;
    ROT_180_CW: number;
    ROT_270_CW: number;
    BTN_UP: number;
    BTN_DOWN: number;
    BTN_LEFT: number;
    BTN_RIGHT: number;
    BTN_A: number;
    BTN_B: number;
    BTN_X: number;
    BTN_Y: number;
    BTN_L: number;
    BTN_R: number;
    BTN_START: number;
    BTN_SELECT: number;
    BTN_POINTER_A: number;
    BTN_POINTER_B: number;
    BTN_POINTER_C: number;
    BTN_POINTER_D: number;
    PLAYER_ONE: number;
    PLAYER_TWO: number;
    PLAYER_THREE: number;
    PLAYER_FOUR: number;
    AXIS_LEFT_X: number;
    AXIS_LEFT_Y: number;
    AXIS_RIGHT_X: number;
    AXIS_RIGHT_Y: number;
    AXIS_TRIGGER_L: number;
    ... 106 more ...;
    spritesRefresh: () => void;
}
Main BLIT386 API namespace used by runtime demos.
BT
.paletteFlash: (color: Color32, durationMs: number) => void
Temporarily sets all non-zero palette entries to a single color, then restores. Index 0 (transparent) is preserved. The original palette is saved internally and restored after the duration elapses. Auto-removes when complete.
@since1.0.3@paramcolor - Flash color applied to all non-zero entries.@paramdurationMs - How long the flash lasts in milliseconds.
paletteFlash
(new new Color32(r?: number, g?: number, b?: number, a?: number): Color32
Creates a clamped 8-bit RGBA color.
@paramr - Red channel (0-255, defaults to 255).@paramg - Green channel (0-255, defaults to 255).@paramb - Blue channel (0-255, defaults to 255).@parama - Alpha channel (0-255, defaults to 255 = opaque).
Color32
(255, 255, 255), 200);
const BT: {
    FLIP_H: number;
    FLIP_V: number;
    ROT_90_CW: number;
    ROT_180_CW: number;
    ROT_270_CW: number;
    BTN_UP: number;
    BTN_DOWN: number;
    BTN_LEFT: number;
    BTN_RIGHT: number;
    BTN_A: number;
    BTN_B: number;
    BTN_X: number;
    BTN_Y: number;
    BTN_L: number;
    BTN_R: number;
    BTN_START: number;
    BTN_SELECT: number;
    BTN_POINTER_A: number;
    BTN_POINTER_B: number;
    BTN_POINTER_C: number;
    BTN_POINTER_D: number;
    PLAYER_ONE: number;
    PLAYER_TWO: number;
    PLAYER_THREE: number;
    PLAYER_FOUR: number;
    AXIS_LEFT_X: number;
    AXIS_LEFT_Y: number;
    AXIS_RIGHT_X: number;
    AXIS_RIGHT_Y: number;
    AXIS_TRIGGER_L: number;
    ... 106 more ...;
    spritesRefresh: () => void;
}
Main BLIT386 API namespace used by runtime demos.
BT
.assignTag: (label?: string) => void
Places a labeled marker on the overlay timing chart at the current tick. Requires `isOverlayTimingChartEnabled: true` in `configure()`. Tags scroll with the chart history and are pruned when they leave the visible window. Empty labels become `"Untitled"`. Chart width resets add an automatic `"Start"` tag.
@since1.1.0@paramlabel - Short event name (for example `'Round start'`).
assignTag
('Lightning flash');
this.Demo.effectTriggered: booleaneffectTriggered = true; } else if (this.Demo.phase: stringphase === 'fade-to-day') { // Dawn: 2-second fade back to day, with ease-out for a quick start.
const BT: {
    FLIP_H: number;
    FLIP_V: number;
    ROT_90_CW: number;
    ROT_180_CW: number;
    ROT_270_CW: number;
    BTN_UP: number;
    BTN_DOWN: number;
    BTN_LEFT: number;
    BTN_RIGHT: number;
    BTN_A: number;
    BTN_B: number;
    BTN_X: number;
    BTN_Y: number;
    BTN_L: number;
    BTN_R: number;
    BTN_START: number;
    BTN_SELECT: number;
    BTN_POINTER_A: number;
    BTN_POINTER_B: number;
    BTN_POINTER_C: number;
    BTN_POINTER_D: number;
    PLAYER_ONE: number;
    PLAYER_TWO: number;
    PLAYER_THREE: number;
    PLAYER_FOUR: number;
    AXIS_LEFT_X: number;
    AXIS_LEFT_Y: number;
    AXIS_RIGHT_X: number;
    AXIS_RIGHT_Y: number;
    AXIS_TRIGGER_L: number;
    ... 106 more ...;
    spritesRefresh: () => void;
}
Main BLIT386 API namespace used by runtime demos.
BT
.paletteFade: (target: Palette, durationMs: number, easing?: EasingFunction) => void
Smoothly interpolates all palette entries toward a target over time. Snapshots the current palette at the moment this is called. Each frame the entries are lerped between the snapshot and target using the easing curve. Auto-removes when the fade completes. Common patterns: - Fade to black: `BT.paletteFade(blackPalette, 1000)` - Fade to white: `BT.paletteFade(whitePalette, 500)` - Cross-fade: `BT.paletteFade(nightPalette, 2000, 'ease-in-out')`
@since1.0.3@paramtarget - Target palette to fade toward.@paramdurationMs - Fade duration in milliseconds.@parameasing - Easing curve. Defaults to `'linear'`.
paletteFade
(this.Demo.day: Palette | null
@type{Palette | null}
day
, 2000, 'ease-out');
const BT: {
    FLIP_H: number;
    FLIP_V: number;
    ROT_90_CW: number;
    ROT_180_CW: number;
    ROT_270_CW: number;
    BTN_UP: number;
    BTN_DOWN: number;
    BTN_LEFT: number;
    BTN_RIGHT: number;
    BTN_A: number;
    BTN_B: number;
    BTN_X: number;
    BTN_Y: number;
    BTN_L: number;
    BTN_R: number;
    BTN_START: number;
    BTN_SELECT: number;
    BTN_POINTER_A: number;
    BTN_POINTER_B: number;
    BTN_POINTER_C: number;
    BTN_POINTER_D: number;
    PLAYER_ONE: number;
    PLAYER_TWO: number;
    PLAYER_THREE: number;
    PLAYER_FOUR: number;
    AXIS_LEFT_X: number;
    AXIS_LEFT_Y: number;
    AXIS_RIGHT_X: number;
    AXIS_RIGHT_Y: number;
    AXIS_TRIGGER_L: number;
    ... 106 more ...;
    spritesRefresh: () => void;
}
Main BLIT386 API namespace used by runtime demos.
BT
.assignTag: (label?: string) => void
Places a labeled marker on the overlay timing chart at the current tick. Requires `isOverlayTimingChartEnabled: true` in `configure()`. Tags scroll with the chart history and are pruned when they leave the visible window. Empty labels become `"Untitled"`. Chart width resets add an automatic `"Start"` tag.
@since1.1.0@paramlabel - Short event name (for example `'Round start'`).
assignTag
('Fade to day');
this.Demo.effectTriggered: booleaneffectTriggered = true; } } /** * Checks whether the current phase has run long enough and advances to the next. * * @param {number} elapsed - Ticks since the current phase started. * @param {number} tick - Current tick count. */ Demo.advancePhaseIfExpired(elapsed: number, tick: number): void
Checks whether the current phase has run long enough and advances to the next.
@paramelapsed - Ticks since the current phase started.@paramtick - Current tick count.
advancePhaseIfExpired
(elapsed: number
- Ticks since the current phase started.
@paramelapsed - Ticks since the current phase started.
elapsed
, tick: number
- Current tick count.
@paramtick - Current tick count.
tick
) {
const const current: anycurrent =
const PHASE_TRANSITIONS: {
    day: {
        duration: number;
        next: string;
    };
    'fade-to-night': {
        duration: number;
        next: string;
    };
    night: {
        duration: number;
        next: string;
    };
    flash: {
        duration: number;
        next: string;
    };
    'night-2': {
        duration: number;
        next: string;
    };
    'fade-to-day': {
        duration: number;
        next: string;
    };
}
PHASE_TRANSITIONS
[this.Demo.phase: stringphase];
if (const current: anycurrent && elapsed: number
- Ticks since the current phase started.
@paramelapsed - Ticks since the current phase started.
elapsed
>= const current: anycurrent.duration) {
this.Demo.startPhase(newPhase: string, tick: number): void
Transitions to a new phase of the day/night cycle.
@paramnewPhase - Name of the phase to enter.@paramtick - Current tick when the phase starts.
startPhase
(const current: anycurrent.next, tick: number
- Current tick count.
@paramtick - Current tick count.
tick
);
} } /** * Draws the landscape: sky gradient, clouds, mountains, sun, ground, trees, flowers. * All draw calls use palette indices only. */ Demo.renderScene(): void
Draws the landscape: sky gradient, clouds, mountains, sun, ground, trees, flowers. All draw calls use palette indices only.
renderScene
() {
// Sky gradient (two bands)
const BT: {
    FLIP_H: number;
    FLIP_V: number;
    ROT_90_CW: number;
    ROT_180_CW: number;
    ROT_270_CW: number;
    BTN_UP: number;
    BTN_DOWN: number;
    BTN_LEFT: number;
    BTN_RIGHT: number;
    BTN_A: number;
    BTN_B: number;
    BTN_X: number;
    BTN_Y: number;
    BTN_L: number;
    BTN_R: number;
    BTN_START: number;
    BTN_SELECT: number;
    BTN_POINTER_A: number;
    BTN_POINTER_B: number;
    BTN_POINTER_C: number;
    BTN_POINTER_D: number;
    PLAYER_ONE: number;
    PLAYER_TWO: number;
    PLAYER_THREE: number;
    PLAYER_FOUR: number;
    AXIS_LEFT_X: number;
    AXIS_LEFT_Y: number;
    AXIS_RIGHT_X: number;
    AXIS_RIGHT_Y: number;
    AXIS_TRIGGER_L: number;
    ... 106 more ...;
    spritesRefresh: () => void;
}
Main BLIT386 API namespace used by runtime demos.
BT
.drawRectFill: (rect: Rect2i, paletteIndex: number) => void
Draws a filled rectangle.
@since0.1.0@paramrect - Rectangle bounds in display coordinates.@parampaletteIndex - Palette color index.
drawRectFill
(new new Rect2i(x?: number, y?: number, width?: number, height?: number): Rect2i
Creates an integer rectangle, truncating all inputs toward zero.
@paramx - Left-edge X coordinate (defaults to 0).@paramy - Top-edge Y coordinate (defaults to 0).@paramwidth - Width in pixels (defaults to 0).@paramheight - Height in pixels (defaults to 0).
Rect2i
(0, 0, 320, 80), const C_SKY: 10C_SKY);
const BT: {
    FLIP_H: number;
    FLIP_V: number;
    ROT_90_CW: number;
    ROT_180_CW: number;
    ROT_270_CW: number;
    BTN_UP: number;
    BTN_DOWN: number;
    BTN_LEFT: number;
    BTN_RIGHT: number;
    BTN_A: number;
    BTN_B: number;
    BTN_X: number;
    BTN_Y: number;
    BTN_L: number;
    BTN_R: number;
    BTN_START: number;
    BTN_SELECT: number;
    BTN_POINTER_A: number;
    BTN_POINTER_B: number;
    BTN_POINTER_C: number;
    BTN_POINTER_D: number;
    PLAYER_ONE: number;
    PLAYER_TWO: number;
    PLAYER_THREE: number;
    PLAYER_FOUR: number;
    AXIS_LEFT_X: number;
    AXIS_LEFT_Y: number;
    AXIS_RIGHT_X: number;
    AXIS_RIGHT_Y: number;
    AXIS_TRIGGER_L: number;
    ... 106 more ...;
    spritesRefresh: () => void;
}
Main BLIT386 API namespace used by runtime demos.
BT
.drawRectFill: (rect: Rect2i, paletteIndex: number) => void
Draws a filled rectangle.
@since0.1.0@paramrect - Rectangle bounds in display coordinates.@parampaletteIndex - Palette color index.
drawRectFill
(new new Rect2i(x?: number, y?: number, width?: number, height?: number): Rect2i
Creates an integer rectangle, truncating all inputs toward zero.
@paramx - Left-edge X coordinate (defaults to 0).@paramy - Top-edge Y coordinate (defaults to 0).@paramwidth - Width in pixels (defaults to 0).@paramheight - Height in pixels (defaults to 0).
Rect2i
(0, 80, 320, 40), const C_SKY_LIGHT: 11C_SKY_LIGHT);
// Clouds this.Demo.drawCloud(x: number, y: number): void
Draws a simple cloud shape at the given position.
@paramx - Left position.@paramy - Top position.
drawCloud
(30, 20);
this.Demo.drawCloud(x: number, y: number): void
Draws a simple cloud shape at the given position.
@paramx - Left position.@paramy - Top position.
drawCloud
(180, 35);
this.Demo.drawCloud(x: number, y: number): void
Draws a simple cloud shape at the given position.
@paramx - Left position.@paramy - Top position.
drawCloud
(260, 15);
// Mountains this.Demo.drawMountain(x: number, baseY: number, width: number, height: number): void
Draws a triangular mountain shape using stacked rectangles.
@paramx - Center x.@parambaseY - Bottom of the mountain.@paramwidth - Base width.@paramheight - Mountain height.
drawMountain
(60, 105, 80, 35);
this.Demo.drawMountain(x: number, baseY: number, width: number, height: number): void
Draws a triangular mountain shape using stacked rectangles.
@paramx - Center x.@parambaseY - Bottom of the mountain.@paramwidth - Base width.@paramheight - Mountain height.
drawMountain
(160, 100, 100, 40);
this.Demo.drawMountain(x: number, baseY: number, width: number, height: number): void
Draws a triangular mountain shape using stacked rectangles.
@paramx - Center x.@parambaseY - Bottom of the mountain.@paramwidth - Base width.@paramheight - Mountain height.
drawMountain
(250, 108, 70, 32);
// Sun
const BT: {
    FLIP_H: number;
    FLIP_V: number;
    ROT_90_CW: number;
    ROT_180_CW: number;
    ROT_270_CW: number;
    BTN_UP: number;
    BTN_DOWN: number;
    BTN_LEFT: number;
    BTN_RIGHT: number;
    BTN_A: number;
    BTN_B: number;
    BTN_X: number;
    BTN_Y: number;
    BTN_L: number;
    BTN_R: number;
    BTN_START: number;
    BTN_SELECT: number;
    BTN_POINTER_A: number;
    BTN_POINTER_B: number;
    BTN_POINTER_C: number;
    BTN_POINTER_D: number;
    PLAYER_ONE: number;
    PLAYER_TWO: number;
    PLAYER_THREE: number;
    PLAYER_FOUR: number;
    AXIS_LEFT_X: number;
    AXIS_LEFT_Y: number;
    AXIS_RIGHT_X: number;
    AXIS_RIGHT_Y: number;
    AXIS_TRIGGER_L: number;
    ... 106 more ...;
    spritesRefresh: () => void;
}
Main BLIT386 API namespace used by runtime demos.
BT
.drawRectFill: (rect: Rect2i, paletteIndex: number) => void
Draws a filled rectangle.
@since0.1.0@paramrect - Rectangle bounds in display coordinates.@parampaletteIndex - Palette color index.
drawRectFill
(new new Rect2i(x?: number, y?: number, width?: number, height?: number): Rect2i
Creates an integer rectangle, truncating all inputs toward zero.
@paramx - Left-edge X coordinate (defaults to 0).@paramy - Top-edge Y coordinate (defaults to 0).@paramwidth - Width in pixels (defaults to 0).@paramheight - Height in pixels (defaults to 0).
Rect2i
(250, 25, 20, 20), const C_SUN: 12C_SUN);
const BT: {
    FLIP_H: number;
    FLIP_V: number;
    ROT_90_CW: number;
    ROT_180_CW: number;
    ROT_270_CW: number;
    BTN_UP: number;
    BTN_DOWN: number;
    BTN_LEFT: number;
    BTN_RIGHT: number;
    BTN_A: number;
    BTN_B: number;
    BTN_X: number;
    BTN_Y: number;
    BTN_L: number;
    BTN_R: number;
    BTN_START: number;
    BTN_SELECT: number;
    BTN_POINTER_A: number;
    BTN_POINTER_B: number;
    BTN_POINTER_C: number;
    BTN_POINTER_D: number;
    PLAYER_ONE: number;
    PLAYER_TWO: number;
    PLAYER_THREE: number;
    PLAYER_FOUR: number;
    AXIS_LEFT_X: number;
    AXIS_LEFT_Y: number;
    AXIS_RIGHT_X: number;
    AXIS_RIGHT_Y: number;
    AXIS_TRIGGER_L: number;
    ... 106 more ...;
    spritesRefresh: () => void;
}
Main BLIT386 API namespace used by runtime demos.
BT
.drawRectFill: (rect: Rect2i, paletteIndex: number) => void
Draws a filled rectangle.
@since0.1.0@paramrect - Rectangle bounds in display coordinates.@parampaletteIndex - Palette color index.
drawRectFill
(new new Rect2i(x?: number, y?: number, width?: number, height?: number): Rect2i
Creates an integer rectangle, truncating all inputs toward zero.
@paramx - Left-edge X coordinate (defaults to 0).@paramy - Top-edge Y coordinate (defaults to 0).@paramwidth - Width in pixels (defaults to 0).@paramheight - Height in pixels (defaults to 0).
Rect2i
(248, 27, 24, 16), const C_SUN_GLOW: 13C_SUN_GLOW);
// Ground
const BT: {
    FLIP_H: number;
    FLIP_V: number;
    ROT_90_CW: number;
    ROT_180_CW: number;
    ROT_270_CW: number;
    BTN_UP: number;
    BTN_DOWN: number;
    BTN_LEFT: number;
    BTN_RIGHT: number;
    BTN_A: number;
    BTN_B: number;
    BTN_X: number;
    BTN_Y: number;
    BTN_L: number;
    BTN_R: number;
    BTN_START: number;
    BTN_SELECT: number;
    BTN_POINTER_A: number;
    BTN_POINTER_B: number;
    BTN_POINTER_C: number;
    BTN_POINTER_D: number;
    PLAYER_ONE: number;
    PLAYER_TWO: number;
    PLAYER_THREE: number;
    PLAYER_FOUR: number;
    AXIS_LEFT_X: number;
    AXIS_LEFT_Y: number;
    AXIS_RIGHT_X: number;
    AXIS_RIGHT_Y: number;
    AXIS_TRIGGER_L: number;
    ... 106 more ...;
    spritesRefresh: () => void;
}
Main BLIT386 API namespace used by runtime demos.
BT
.drawRectFill: (rect: Rect2i, paletteIndex: number) => void
Draws a filled rectangle.
@since0.1.0@paramrect - Rectangle bounds in display coordinates.@parampaletteIndex - Palette color index.
drawRectFill
(new new Rect2i(x?: number, y?: number, width?: number, height?: number): Rect2i
Creates an integer rectangle, truncating all inputs toward zero.
@paramx - Left-edge X coordinate (defaults to 0).@paramy - Top-edge Y coordinate (defaults to 0).@paramwidth - Width in pixels (defaults to 0).@paramheight - Height in pixels (defaults to 0).
Rect2i
(0, 120, 320, 120), const C_GROUND: 14C_GROUND);
const BT: {
    FLIP_H: number;
    FLIP_V: number;
    ROT_90_CW: number;
    ROT_180_CW: number;
    ROT_270_CW: number;
    BTN_UP: number;
    BTN_DOWN: number;
    BTN_LEFT: number;
    BTN_RIGHT: number;
    BTN_A: number;
    BTN_B: number;
    BTN_X: number;
    BTN_Y: number;
    BTN_L: number;
    BTN_R: number;
    BTN_START: number;
    BTN_SELECT: number;
    BTN_POINTER_A: number;
    BTN_POINTER_B: number;
    BTN_POINTER_C: number;
    BTN_POINTER_D: number;
    PLAYER_ONE: number;
    PLAYER_TWO: number;
    PLAYER_THREE: number;
    PLAYER_FOUR: number;
    AXIS_LEFT_X: number;
    AXIS_LEFT_Y: number;
    AXIS_RIGHT_X: number;
    AXIS_RIGHT_Y: number;
    AXIS_TRIGGER_L: number;
    ... 106 more ...;
    spritesRefresh: () => void;
}
Main BLIT386 API namespace used by runtime demos.
BT
.drawRectFill: (rect: Rect2i, paletteIndex: number) => void
Draws a filled rectangle.
@since0.1.0@paramrect - Rectangle bounds in display coordinates.@parampaletteIndex - Palette color index.
drawRectFill
(new new Rect2i(x?: number, y?: number, width?: number, height?: number): Rect2i
Creates an integer rectangle, truncating all inputs toward zero.
@paramx - Left-edge X coordinate (defaults to 0).@paramy - Top-edge Y coordinate (defaults to 0).@paramwidth - Width in pixels (defaults to 0).@paramheight - Height in pixels (defaults to 0).
Rect2i
(0, 180, 320, 60), const C_GROUND_DARK: 15C_GROUND_DARK);
// Trees this.Demo.drawTree(x: number, groundY: number): void
Draws a simple tree (trunk + leaf canopy).
@paramx - Trunk center x.@paramgroundY - Y position of the ground line.
drawTree
(40, 110);
this.Demo.drawTree(x: number, groundY: number): void
Draws a simple tree (trunk + leaf canopy).
@paramx - Trunk center x.@paramgroundY - Y position of the ground line.
drawTree
(100, 115);
this.Demo.drawTree(x: number, groundY: number): void
Draws a simple tree (trunk + leaf canopy).
@paramx - Trunk center x.@paramgroundY - Y position of the ground line.
drawTree
(200, 108);
this.Demo.drawTree(x: number, groundY: number): void
Draws a simple tree (trunk + leaf canopy).
@paramx - Trunk center x.@paramgroundY - Y position of the ground line.
drawTree
(270, 118);
// Flowers this.Demo.drawFlowers(): void
Scatters small flower pixels across the ground.
drawFlowers
();
} /** * Draws a simple cloud shape at the given position. * * @param {number} x - Left position. * @param {number} y - Top position. */ Demo.drawCloud(x: number, y: number): void
Draws a simple cloud shape at the given position.
@paramx - Left position.@paramy - Top position.
drawCloud
(x: number
- Left position.
@paramx - Left position.
x
, y: number
- Top position.
@paramy - Top position.
y
) {
const BT: {
    FLIP_H: number;
    FLIP_V: number;
    ROT_90_CW: number;
    ROT_180_CW: number;
    ROT_270_CW: number;
    BTN_UP: number;
    BTN_DOWN: number;
    BTN_LEFT: number;
    BTN_RIGHT: number;
    BTN_A: number;
    BTN_B: number;
    BTN_X: number;
    BTN_Y: number;
    BTN_L: number;
    BTN_R: number;
    BTN_START: number;
    BTN_SELECT: number;
    BTN_POINTER_A: number;
    BTN_POINTER_B: number;
    BTN_POINTER_C: number;
    BTN_POINTER_D: number;
    PLAYER_ONE: number;
    PLAYER_TWO: number;
    PLAYER_THREE: number;
    PLAYER_FOUR: number;
    AXIS_LEFT_X: number;
    AXIS_LEFT_Y: number;
    AXIS_RIGHT_X: number;
    AXIS_RIGHT_Y: number;
    AXIS_TRIGGER_L: number;
    ... 106 more ...;
    spritesRefresh: () => void;
}
Main BLIT386 API namespace used by runtime demos.
BT
.drawRectFill: (rect: Rect2i, paletteIndex: number) => void
Draws a filled rectangle.
@since0.1.0@paramrect - Rectangle bounds in display coordinates.@parampaletteIndex - Palette color index.
drawRectFill
(new new Rect2i(x?: number, y?: number, width?: number, height?: number): Rect2i
Creates an integer rectangle, truncating all inputs toward zero.
@paramx - Left-edge X coordinate (defaults to 0).@paramy - Top-edge Y coordinate (defaults to 0).@paramwidth - Width in pixels (defaults to 0).@paramheight - Height in pixels (defaults to 0).
Rect2i
(x: number
- Left position.
@paramx - Left position.
x
, y: number
- Top position.
@paramy - Top position.
y
, 30, 8), const C_CLOUD: 21C_CLOUD);
const BT: {
    FLIP_H: number;
    FLIP_V: number;
    ROT_90_CW: number;
    ROT_180_CW: number;
    ROT_270_CW: number;
    BTN_UP: number;
    BTN_DOWN: number;
    BTN_LEFT: number;
    BTN_RIGHT: number;
    BTN_A: number;
    BTN_B: number;
    BTN_X: number;
    BTN_Y: number;
    BTN_L: number;
    BTN_R: number;
    BTN_START: number;
    BTN_SELECT: number;
    BTN_POINTER_A: number;
    BTN_POINTER_B: number;
    BTN_POINTER_C: number;
    BTN_POINTER_D: number;
    PLAYER_ONE: number;
    PLAYER_TWO: number;
    PLAYER_THREE: number;
    PLAYER_FOUR: number;
    AXIS_LEFT_X: number;
    AXIS_LEFT_Y: number;
    AXIS_RIGHT_X: number;
    AXIS_RIGHT_Y: number;
    AXIS_TRIGGER_L: number;
    ... 106 more ...;
    spritesRefresh: () => void;
}
Main BLIT386 API namespace used by runtime demos.
BT
.drawRectFill: (rect: Rect2i, paletteIndex: number) => void
Draws a filled rectangle.
@since0.1.0@paramrect - Rectangle bounds in display coordinates.@parampaletteIndex - Palette color index.
drawRectFill
(new new Rect2i(x?: number, y?: number, width?: number, height?: number): Rect2i
Creates an integer rectangle, truncating all inputs toward zero.
@paramx - Left-edge X coordinate (defaults to 0).@paramy - Top-edge Y coordinate (defaults to 0).@paramwidth - Width in pixels (defaults to 0).@paramheight - Height in pixels (defaults to 0).
Rect2i
(x: number
- Left position.
@paramx - Left position.
x
+ 5, y: number
- Top position.
@paramy - Top position.
y
- 4, 20, 6), const C_CLOUD: 21C_CLOUD);
} /** * Draws a triangular mountain shape using stacked rectangles. * * @param {number} x - Center x. * @param {number} baseY - Bottom of the mountain. * @param {number} width - Base width. * @param {number} height - Mountain height. */ Demo.drawMountain(x: number, baseY: number, width: number, height: number): void
Draws a triangular mountain shape using stacked rectangles.
@paramx - Center x.@parambaseY - Bottom of the mountain.@paramwidth - Base width.@paramheight - Mountain height.
drawMountain
(x: number
- Center x.
@paramx - Center x.
x
, baseY: number
- Bottom of the mountain.
@parambaseY - Bottom of the mountain.
baseY
, width: number
- Base width.
@paramwidth - Base width.
width
, height: number
- Mountain height.
@paramheight - Mountain height.
height
) {
// Draw the mountain as a series of horizontal slices getting narrower toward the top. for (let let row: numberrow = 0; let row: numberrow < height: number
- Mountain height.
@paramheight - Mountain height.
height
; let row: numberrow++) {
const const t: numbert = let row: numberrow / height: number
- Mountain height.
@paramheight - Mountain height.
height
; // 0 at bottom, 1 at top
const const sliceW: anysliceW = Math.floor(width: number
- Base width.
@paramwidth - Base width.
width
* (1 - const t: numbert * 0.8));
const const sliceX: numbersliceX = x: number
- Center x.
@paramx - Center x.
x
- Math.floor(const sliceW: anysliceW / 2);
const const sliceY: numbersliceY = baseY: number
- Bottom of the mountain.
@parambaseY - Bottom of the mountain.
baseY
- let row: numberrow;
// Upper half is lighter (snow-capped effect). const const slot: 22 | 23slot = const t: numbert > 0.6 ? const C_MOUNTAIN_LIGHT: 23C_MOUNTAIN_LIGHT : const C_MOUNTAIN: 22C_MOUNTAIN;
const BT: {
    FLIP_H: number;
    FLIP_V: number;
    ROT_90_CW: number;
    ROT_180_CW: number;
    ROT_270_CW: number;
    BTN_UP: number;
    BTN_DOWN: number;
    BTN_LEFT: number;
    BTN_RIGHT: number;
    BTN_A: number;
    BTN_B: number;
    BTN_X: number;
    BTN_Y: number;
    BTN_L: number;
    BTN_R: number;
    BTN_START: number;
    BTN_SELECT: number;
    BTN_POINTER_A: number;
    BTN_POINTER_B: number;
    BTN_POINTER_C: number;
    BTN_POINTER_D: number;
    PLAYER_ONE: number;
    PLAYER_TWO: number;
    PLAYER_THREE: number;
    PLAYER_FOUR: number;
    AXIS_LEFT_X: number;
    AXIS_LEFT_Y: number;
    AXIS_RIGHT_X: number;
    AXIS_RIGHT_Y: number;
    AXIS_TRIGGER_L: number;
    ... 106 more ...;
    spritesRefresh: () => void;
}
Main BLIT386 API namespace used by runtime demos.
BT
.drawRectFill: (rect: Rect2i, paletteIndex: number) => void
Draws a filled rectangle.
@since0.1.0@paramrect - Rectangle bounds in display coordinates.@parampaletteIndex - Palette color index.
drawRectFill
(new new Rect2i(x?: number, y?: number, width?: number, height?: number): Rect2i
Creates an integer rectangle, truncating all inputs toward zero.
@paramx - Left-edge X coordinate (defaults to 0).@paramy - Top-edge Y coordinate (defaults to 0).@paramwidth - Width in pixels (defaults to 0).@paramheight - Height in pixels (defaults to 0).
Rect2i
(const sliceX: numbersliceX, const sliceY: numbersliceY, const sliceW: anysliceW, 1), const slot: 22 | 23slot);
} } /** * Draws a simple tree (trunk + leaf canopy). * * @param {number} x - Trunk center x. * @param {number} groundY - Y position of the ground line. */ Demo.drawTree(x: number, groundY: number): void
Draws a simple tree (trunk + leaf canopy).
@paramx - Trunk center x.@paramgroundY - Y position of the ground line.
drawTree
(x: number
- Trunk center x.
@paramx - Trunk center x.
x
, groundY: number
- Y position of the ground line.
@paramgroundY - Y position of the ground line.
groundY
) {
// Trunk.
const BT: {
    FLIP_H: number;
    FLIP_V: number;
    ROT_90_CW: number;
    ROT_180_CW: number;
    ROT_270_CW: number;
    BTN_UP: number;
    BTN_DOWN: number;
    BTN_LEFT: number;
    BTN_RIGHT: number;
    BTN_A: number;
    BTN_B: number;
    BTN_X: number;
    BTN_Y: number;
    BTN_L: number;
    BTN_R: number;
    BTN_START: number;
    BTN_SELECT: number;
    BTN_POINTER_A: number;
    BTN_POINTER_B: number;
    BTN_POINTER_C: number;
    BTN_POINTER_D: number;
    PLAYER_ONE: number;
    PLAYER_TWO: number;
    PLAYER_THREE: number;
    PLAYER_FOUR: number;
    AXIS_LEFT_X: number;
    AXIS_LEFT_Y: number;
    AXIS_RIGHT_X: number;
    AXIS_RIGHT_Y: number;
    AXIS_TRIGGER_L: number;
    ... 106 more ...;
    spritesRefresh: () => void;
}
Main BLIT386 API namespace used by runtime demos.
BT
.drawRectFill: (rect: Rect2i, paletteIndex: number) => void
Draws a filled rectangle.
@since0.1.0@paramrect - Rectangle bounds in display coordinates.@parampaletteIndex - Palette color index.
drawRectFill
(new new Rect2i(x?: number, y?: number, width?: number, height?: number): Rect2i
Creates an integer rectangle, truncating all inputs toward zero.
@paramx - Left-edge X coordinate (defaults to 0).@paramy - Top-edge Y coordinate (defaults to 0).@paramwidth - Width in pixels (defaults to 0).@paramheight - Height in pixels (defaults to 0).
Rect2i
(x: number
- Trunk center x.
@paramx - Trunk center x.
x
- 2, groundY: number
- Y position of the ground line.
@paramgroundY - Y position of the ground line.
groundY
- 20, 4, 20), const C_TRUNK: 16C_TRUNK);
// Leaf canopy (rounded-ish shape from stacked rects).
const BT: {
    FLIP_H: number;
    FLIP_V: number;
    ROT_90_CW: number;
    ROT_180_CW: number;
    ROT_270_CW: number;
    BTN_UP: number;
    BTN_DOWN: number;
    BTN_LEFT: number;
    BTN_RIGHT: number;
    BTN_A: number;
    BTN_B: number;
    BTN_X: number;
    BTN_Y: number;
    BTN_L: number;
    BTN_R: number;
    BTN_START: number;
    BTN_SELECT: number;
    BTN_POINTER_A: number;
    BTN_POINTER_B: number;
    BTN_POINTER_C: number;
    BTN_POINTER_D: number;
    PLAYER_ONE: number;
    PLAYER_TWO: number;
    PLAYER_THREE: number;
    PLAYER_FOUR: number;
    AXIS_LEFT_X: number;
    AXIS_LEFT_Y: number;
    AXIS_RIGHT_X: number;
    AXIS_RIGHT_Y: number;
    AXIS_TRIGGER_L: number;
    ... 106 more ...;
    spritesRefresh: () => void;
}
Main BLIT386 API namespace used by runtime demos.
BT
.drawRectFill: (rect: Rect2i, paletteIndex: number) => void
Draws a filled rectangle.
@since0.1.0@paramrect - Rectangle bounds in display coordinates.@parampaletteIndex - Palette color index.
drawRectFill
(new new Rect2i(x?: number, y?: number, width?: number, height?: number): Rect2i
Creates an integer rectangle, truncating all inputs toward zero.
@paramx - Left-edge X coordinate (defaults to 0).@paramy - Top-edge Y coordinate (defaults to 0).@paramwidth - Width in pixels (defaults to 0).@paramheight - Height in pixels (defaults to 0).
Rect2i
(x: number
- Trunk center x.
@paramx - Trunk center x.
x
- 10, groundY: number
- Y position of the ground line.
@paramgroundY - Y position of the ground line.
groundY
- 35, 20, 8), const C_LEAVES: 17C_LEAVES);
const BT: {
    FLIP_H: number;
    FLIP_V: number;
    ROT_90_CW: number;
    ROT_180_CW: number;
    ROT_270_CW: number;
    BTN_UP: number;
    BTN_DOWN: number;
    BTN_LEFT: number;
    BTN_RIGHT: number;
    BTN_A: number;
    BTN_B: number;
    BTN_X: number;
    BTN_Y: number;
    BTN_L: number;
    BTN_R: number;
    BTN_START: number;
    BTN_SELECT: number;
    BTN_POINTER_A: number;
    BTN_POINTER_B: number;
    BTN_POINTER_C: number;
    BTN_POINTER_D: number;
    PLAYER_ONE: number;
    PLAYER_TWO: number;
    PLAYER_THREE: number;
    PLAYER_FOUR: number;
    AXIS_LEFT_X: number;
    AXIS_LEFT_Y: number;
    AXIS_RIGHT_X: number;
    AXIS_RIGHT_Y: number;
    AXIS_TRIGGER_L: number;
    ... 106 more ...;
    spritesRefresh: () => void;
}
Main BLIT386 API namespace used by runtime demos.
BT
.drawRectFill: (rect: Rect2i, paletteIndex: number) => void
Draws a filled rectangle.
@since0.1.0@paramrect - Rectangle bounds in display coordinates.@parampaletteIndex - Palette color index.
drawRectFill
(new new Rect2i(x?: number, y?: number, width?: number, height?: number): Rect2i
Creates an integer rectangle, truncating all inputs toward zero.
@paramx - Left-edge X coordinate (defaults to 0).@paramy - Top-edge Y coordinate (defaults to 0).@paramwidth - Width in pixels (defaults to 0).@paramheight - Height in pixels (defaults to 0).
Rect2i
(x: number
- Trunk center x.
@paramx - Trunk center x.
x
- 14, groundY: number
- Y position of the ground line.
@paramgroundY - Y position of the ground line.
groundY
- 27, 28, 10), const C_LEAVES: 17C_LEAVES);
const BT: {
    FLIP_H: number;
    FLIP_V: number;
    ROT_90_CW: number;
    ROT_180_CW: number;
    ROT_270_CW: number;
    BTN_UP: number;
    BTN_DOWN: number;
    BTN_LEFT: number;
    BTN_RIGHT: number;
    BTN_A: number;
    BTN_B: number;
    BTN_X: number;
    BTN_Y: number;
    BTN_L: number;
    BTN_R: number;
    BTN_START: number;
    BTN_SELECT: number;
    BTN_POINTER_A: number;
    BTN_POINTER_B: number;
    BTN_POINTER_C: number;
    BTN_POINTER_D: number;
    PLAYER_ONE: number;
    PLAYER_TWO: number;
    PLAYER_THREE: number;
    PLAYER_FOUR: number;
    AXIS_LEFT_X: number;
    AXIS_LEFT_Y: number;
    AXIS_RIGHT_X: number;
    AXIS_RIGHT_Y: number;
    AXIS_TRIGGER_L: number;
    ... 106 more ...;
    spritesRefresh: () => void;
}
Main BLIT386 API namespace used by runtime demos.
BT
.drawRectFill: (rect: Rect2i, paletteIndex: number) => void
Draws a filled rectangle.
@since0.1.0@paramrect - Rectangle bounds in display coordinates.@parampaletteIndex - Palette color index.
drawRectFill
(new new Rect2i(x?: number, y?: number, width?: number, height?: number): Rect2i
Creates an integer rectangle, truncating all inputs toward zero.
@paramx - Left-edge X coordinate (defaults to 0).@paramy - Top-edge Y coordinate (defaults to 0).@paramwidth - Width in pixels (defaults to 0).@paramheight - Height in pixels (defaults to 0).
Rect2i
(x: number
- Trunk center x.
@paramx - Trunk center x.
x
- 8, groundY: number
- Y position of the ground line.
@paramgroundY - Y position of the ground line.
groundY
- 40, 16, 8), const C_LEAVES_LIGHT: 18C_LEAVES_LIGHT);
} /** * Scatters small flower pixels across the ground. */ Demo.drawFlowers(): void
Scatters small flower pixels across the ground.
drawFlowers
() {
// A fixed set of flower positions so they don't jump around. const const flowers: {}flowers = [ [20, 140], [55, 155], [80, 145], [120, 160], [155, 142], [190, 158], [220, 148], [255, 165], [290, 138], [35, 170], [70, 175], [140, 172], [210, 170], [260, 178], ]; for (let let i: numberi = 0; let i: numberi < const flowers: {}flowers.length; let i: numberi++) { const [const fx: anyfx, const fy: anyfy] = const flowers: {}flowers[let i: numberi]; // Alternate between two flower colors. const const slot: 19 | 20slot = let i: numberi % 2 === 0 ? const C_FLOWER_1: 19C_FLOWER_1 : const C_FLOWER_2: 20C_FLOWER_2;
const BT: {
    FLIP_H: number;
    FLIP_V: number;
    ROT_90_CW: number;
    ROT_180_CW: number;
    ROT_270_CW: number;
    BTN_UP: number;
    BTN_DOWN: number;
    BTN_LEFT: number;
    BTN_RIGHT: number;
    BTN_A: number;
    BTN_B: number;
    BTN_X: number;
    BTN_Y: number;
    BTN_L: number;
    BTN_R: number;
    BTN_START: number;
    BTN_SELECT: number;
    BTN_POINTER_A: number;
    BTN_POINTER_B: number;
    BTN_POINTER_C: number;
    BTN_POINTER_D: number;
    PLAYER_ONE: number;
    PLAYER_TWO: number;
    PLAYER_THREE: number;
    PLAYER_FOUR: number;
    AXIS_LEFT_X: number;
    AXIS_LEFT_Y: number;
    AXIS_RIGHT_X: number;
    AXIS_RIGHT_Y: number;
    AXIS_TRIGGER_L: number;
    ... 106 more ...;
    spritesRefresh: () => void;
}
Main BLIT386 API namespace used by runtime demos.
BT
.drawPixel: (posOrX: Vector2i | number, yOrColor: number, maybeColor?: number) => void
Draws a single pixel. Accepts either: - `(posOrX: Vector2i, yOrColor: number)` where `yOrColor` is the palette index. - `(posOrX: number, yOrColor: number, maybeColor: number)` for `(x, y, paletteIndex)`.
@since0.1.0@paramposOrX - Pixel position as `Vector2i`, or x coordinate when using numeric overload.@paramyOrColor - Palette index for vector overload, or y coordinate for numeric overload.@parammaybeColor - Palette index when using numeric overload.
drawPixel
(new new Vector2i(x?: number, y?: number): Vector2i
Creates an integer 2D vector, truncating inputs toward zero.
@paramx - Horizontal component (defaults to 0).@paramy - Vertical component (defaults to 0).
Vector2i
(const fx: anyfx, const fy: anyfy), const slot: 19 | 20slot);
const BT: {
    FLIP_H: number;
    FLIP_V: number;
    ROT_90_CW: number;
    ROT_180_CW: number;
    ROT_270_CW: number;
    BTN_UP: number;
    BTN_DOWN: number;
    BTN_LEFT: number;
    BTN_RIGHT: number;
    BTN_A: number;
    BTN_B: number;
    BTN_X: number;
    BTN_Y: number;
    BTN_L: number;
    BTN_R: number;
    BTN_START: number;
    BTN_SELECT: number;
    BTN_POINTER_A: number;
    BTN_POINTER_B: number;
    BTN_POINTER_C: number;
    BTN_POINTER_D: number;
    PLAYER_ONE: number;
    PLAYER_TWO: number;
    PLAYER_THREE: number;
    PLAYER_FOUR: number;
    AXIS_LEFT_X: number;
    AXIS_LEFT_Y: number;
    AXIS_RIGHT_X: number;
    AXIS_RIGHT_Y: number;
    AXIS_TRIGGER_L: number;
    ... 106 more ...;
    spritesRefresh: () => void;
}
Main BLIT386 API namespace used by runtime demos.
BT
.drawPixel: (posOrX: Vector2i | number, yOrColor: number, maybeColor?: number) => void
Draws a single pixel. Accepts either: - `(posOrX: Vector2i, yOrColor: number)` where `yOrColor` is the palette index. - `(posOrX: number, yOrColor: number, maybeColor: number)` for `(x, y, paletteIndex)`.
@since0.1.0@paramposOrX - Pixel position as `Vector2i`, or x coordinate when using numeric overload.@paramyOrColor - Palette index for vector overload, or y coordinate for numeric overload.@parammaybeColor - Palette index when using numeric overload.
drawPixel
(new new Vector2i(x?: number, y?: number): Vector2i
Creates an integer 2D vector, truncating inputs toward zero.
@paramx - Horizontal component (defaults to 0).@paramy - Vertical component (defaults to 0).
Vector2i
(const fx: anyfx + 1, const fy: anyfy), const slot: 19 | 20slot);
const BT: {
    FLIP_H: number;
    FLIP_V: number;
    ROT_90_CW: number;
    ROT_180_CW: number;
    ROT_270_CW: number;
    BTN_UP: number;
    BTN_DOWN: number;
    BTN_LEFT: number;
    BTN_RIGHT: number;
    BTN_A: number;
    BTN_B: number;
    BTN_X: number;
    BTN_Y: number;
    BTN_L: number;
    BTN_R: number;
    BTN_START: number;
    BTN_SELECT: number;
    BTN_POINTER_A: number;
    BTN_POINTER_B: number;
    BTN_POINTER_C: number;
    BTN_POINTER_D: number;
    PLAYER_ONE: number;
    PLAYER_TWO: number;
    PLAYER_THREE: number;
    PLAYER_FOUR: number;
    AXIS_LEFT_X: number;
    AXIS_LEFT_Y: number;
    AXIS_RIGHT_X: number;
    AXIS_RIGHT_Y: number;
    AXIS_TRIGGER_L: number;
    ... 106 more ...;
    spritesRefresh: () => void;
}
Main BLIT386 API namespace used by runtime demos.
BT
.drawPixel: (posOrX: Vector2i | number, yOrColor: number, maybeColor?: number) => void
Draws a single pixel. Accepts either: - `(posOrX: Vector2i, yOrColor: number)` where `yOrColor` is the palette index. - `(posOrX: number, yOrColor: number, maybeColor: number)` for `(x, y, paletteIndex)`.
@since0.1.0@paramposOrX - Pixel position as `Vector2i`, or x coordinate when using numeric overload.@paramyOrColor - Palette index for vector overload, or y coordinate for numeric overload.@parammaybeColor - Palette index when using numeric overload.
drawPixel
(new new Vector2i(x?: number, y?: number): Vector2i
Creates an integer 2D vector, truncating inputs toward zero.
@paramx - Horizontal component (defaults to 0).@paramy - Vertical component (defaults to 0).
Vector2i
(const fx: anyfx, const fy: anyfy + 1), const slot: 19 | 20slot);
const BT: {
    FLIP_H: number;
    FLIP_V: number;
    ROT_90_CW: number;
    ROT_180_CW: number;
    ROT_270_CW: number;
    BTN_UP: number;
    BTN_DOWN: number;
    BTN_LEFT: number;
    BTN_RIGHT: number;
    BTN_A: number;
    BTN_B: number;
    BTN_X: number;
    BTN_Y: number;
    BTN_L: number;
    BTN_R: number;
    BTN_START: number;
    BTN_SELECT: number;
    BTN_POINTER_A: number;
    BTN_POINTER_B: number;
    BTN_POINTER_C: number;
    BTN_POINTER_D: number;
    PLAYER_ONE: number;
    PLAYER_TWO: number;
    PLAYER_THREE: number;
    PLAYER_FOUR: number;
    AXIS_LEFT_X: number;
    AXIS_LEFT_Y: number;
    AXIS_RIGHT_X: number;
    AXIS_RIGHT_Y: number;
    AXIS_TRIGGER_L: number;
    ... 106 more ...;
    spritesRefresh: () => void;
}
Main BLIT386 API namespace used by runtime demos.
BT
.drawPixel: (posOrX: Vector2i | number, yOrColor: number, maybeColor?: number) => void
Draws a single pixel. Accepts either: - `(posOrX: Vector2i, yOrColor: number)` where `yOrColor` is the palette index. - `(posOrX: number, yOrColor: number, maybeColor: number)` for `(x, y, paletteIndex)`.
@since0.1.0@paramposOrX - Pixel position as `Vector2i`, or x coordinate when using numeric overload.@paramyOrColor - Palette index for vector overload, or y coordinate for numeric overload.@parammaybeColor - Palette index when using numeric overload.
drawPixel
(new new Vector2i(x?: number, y?: number): Vector2i
Creates an integer 2D vector, truncating inputs toward zero.
@paramx - Horizontal component (defaults to 0).@paramy - Vertical component (defaults to 0).
Vector2i
(const fx: anyfx + 1, const fy: anyfy + 1), const slot: 19 | 20slot);
} } } function bootstrap(DemoClass: DemoConstructor, options?: BootstrapOptions): Promise<boolean>
One-liner bootstrap function for BLIT386 demos. Handles canvas retrieval and engine initialization. Backend selection (WebGPU or software fallback) is managed internally by BTAPI. This function provides a streamlined way to start a demo with sensible defaults while allowing customization through options.
@since0.2.0@changed1.4.0 Calling `bootstrap()` again while already initialized now routes to a hot swap (via {@link registerHotReload}) when a Vite HMR context is registered, or logs a double-bootstrap guard and returns `false` otherwise - previously it silently started a second, unstoppable `GameLoop`.@changed1.7.0 Exposes `BT` on `window.BT` after bootstrap finishes, gated by {@link BootstrapOptions.exposeGlobal} (default: {@link BT.isDevMode}).@paramDemoClass - Demo class constructor implementing `IBTDemo` (optional `configure()` for hardware settings).@paramoptions - Optional configuration for IDs and callbacks.@returns`true` when the demo boots successfully; otherwise `false`.@example// Simplest usage - uses default IDs. bootstrap(MyDemo);@example// With custom options. bootstrap(MyDemo, { canvasID: 'custom-canvas', containerID: 'custom-container', onSuccess: () => console.log('Demo started!'), onError: (err) => analytics.trackError(err), });@example// Await the result. const success = await bootstrap(MyDemo); if (success) { console.log('Demo is running'); }
bootstrap
(class Demo
Demonstrates BT.paletteFade() and BT.paletteFlash(). A pixel-art landscape transitions between day and night with smooth fades, plus a lightning flash effect.
@implementsIBTDemo
Demo
);