Skip to main content

Background colour

The canvas paper colour is a per-scene viewport setting: viewport.background (any CSS colour). Absent means DEFAULT_CANVAS_BACKGROUND (#f5f5f5). It serialises with the document and reaches "with background" exports.

Setting itโ€‹

import { setViewport, canvasBackgroundOf } from "@oh-just-another/scene";

const { scene: dark } = setViewport(scene, { ...scene.viewport, background: "#4a4a4a" });
canvasBackgroundOf(dark.viewport); // "#4a4a4a"
canvasBackgroundOf(scene.viewport); // "#f5f5f5"

Through the editor โ€” part of history, so โŒ˜Z restores the previous colour; null clears the field:

editor.setCanvasBackground("#000000");
editor.canvasBackground; // "#000000"
editor.setCanvasBackground(null); // back to the default paper

In the UIโ€‹

Board โ€บ Background colour lists CANVAS_BACKGROUND_PRESETS (@oh-just-another/editor): White, Light gray (default), Gray, Dark gray, Black, Light blue. The <Editor> root's --du-canvas-bg follows the scene, so a document looks the same in every host; without a colour in the document the stylesheet token stays in charge. The dark chrome theme never recolours the paper.

Exportsโ€‹

PNG "with background" uses the scene colour (falling back to the host's --du-canvas-bg), and headless renderToPng uses it unless background is passed. SVG and transparent PNG carry no paper.