Skip to content

Application Settings

Blits provides a flexible and performant way to configure your application at launch using the settings object passed to Blits.Launch. These settings allow you to fine-tune rendering, performance, input, fonts, and more.

Below is a comprehensive overview of the available settings you can provide to a Blits Application:

Basic Settings

SettingTypeDescription
wnumberWidth of the application (canvas)
hnumberHeight of the application (canvas)
debugLevelnumber | string[]Debug level for console log messages
multithreadedbooleanEnable multithreaded rendering

Fonts & Text

SettingTypeDescription
fontsFont[]Array of font objects to register
defaultFontstringDefault font family to use

Example font object:

js
{
  family: 'lato',
  type: 'msdf', // or 'web'
  file: 'fonts/Lato-Regular.ttf',
}

Rendering & Performance

SettingTypeDescription
renderQuality'low' | 'medium' | 'high' | 'retina' | numberControls render quality (1 = 100%)
screenResolution'hd' | 'fhd' | '4k' | numberSets device screen resolution
pixelRationumberCustom pixel ratio (overrides screenResolution)
canvasColorstringBackground color of the canvas
fpsIntervalnumberInterval (ms) for FPS updates (0 disables)
webWorkersLimitnumberMax number of web workers for image handling
gpuMemoryobjectGPU memory management (see below)
gpuMemoryLimitnumber(Deprecated) Use gpuMemory instead
textureProcessingTimeLimitnumberMax ms per frame for texture processing
viewportMarginnumber | [number,number,number,number]Extra margin for preloading elements
advancedobjectAdvanced renderer settings (use with care)

GPU Memory Example

js
{
  max: 200, // MB
  target: 0.8, // 80% of max
  cleanupInterval: 5000, // ms
  baseline: 25, // MB
  strict: false
}

Input & Focus

SettingTypeDescription
keymapobjectCustom key mapping for input events
holdTimeoutnumberTime (ms) to consider a key press as hold

Renderer

SettingTypeDescription
renderMode'webgl' | 'canvas'Renderer mode (default: 'webgl')
canvasHTMLCanvasElementCustom canvas to render to

Effects & Shaders

SettingTypeDescription
effectsShaderEffect[]Effects for DynamicShader
shadersShader[]Custom shaders

Inspector & Debugging

SettingTypeDescription
inspectorbooleanEnable the inspector tool

Accessibility

SettingTypeDescription
announcerbooleanEnable/disable text-to-speech announcer

Example Usage

js
Blits.Launch(App, 'app', {
  w: 1920,
  h: 1080,
  debugLevel: 1,
  renderQuality: 'high',
  fonts: [
    { family: 'lato', type: 'msdf', file: 'fonts/Lato-Regular.ttf' },
  ],
  keymap: {
    ArrowLeft: 'left',
    ArrowRight: 'right',
  },
  gpuMemory: {
    max: 200,
    target: 0.8,
    cleanupInterval: 5000,
    baseline: 25,
    strict: false,
  },
  inspector: false,
  announcer: true,
})