Interface BitmapOptions

Options for the CanvasLayer.drawBitmap method. Required properties are initialised with defaults inside drawBitmap.

interface BitmapOptions {
    top: string | number;
    left: string | number;
    hOffset: number;
    vOffset: number;
    fit: "none" | "contain" | "cover";
    keepAspectRatio: boolean;
    smoothing: boolean | "high" | "low" | "medium";
    width?: string | number;
    height?: string | number;
    hAlign?: HAlign;
    vAlign?: VAlign;
    margin?: string | number;
    marginTop?: string | number;
    marginEnd?: string | number;
    marginBottom?: string | number;
    marginStart?: string | number;
}

Properties

top: string | number

Top position in pixels or as a percentage string (e.g. '50%'). Default: 0.

left: string | number

Left position in pixels or as a percentage string (e.g. '50%'). Default: 0.

hOffset: number

Horizontal pixel offset. Default: 0.

vOffset: number

Vertical pixel offset. Default: 0.

fit: "none" | "contain" | "cover"

Fit mode. 'contain' scales the image to fit within the available area (default). 'cover' scales to fill the available area, cropping overflow. 'none' disables scaling and draws at the original bitmap size. Default: 'contain'.

keepAspectRatio: boolean

Preserve the image aspect ratio when fitting. Default: true.

smoothing: boolean | "high" | "low" | "medium"

Resampling used when the bitmap is scaled.

Defaults to false (nearest-neighbour) because every pixel of a layer becomes one dot on the DMD: a smoothed downscale turns edges into intermediate values, which the dot grid renders as washed-out half-lit dots. Nearest-neighbour keeps each dot decisively on or off, which is what reads as "sharp" on a dot display.

Pass true (or an explicit 'low' | 'medium' | 'high' quality) to get the browser's smoothed resampling instead — occasionally what you want for a photographic image on a high-resolution DMD, where there are enough dots for the gradients to pay off.

Default: false.

width?: string | number

Target width in pixels or as a percentage string (used when fit is 'none').

height?: string | number

Target height in pixels or as a percentage string (used when fit is 'none').

hAlign?: HAlign

Horizontal alignment.

vAlign?: VAlign

Vertical alignment.

margin?: string | number

Margin on all sides in pixels or as a percentage string. Default: 0.

marginTop?: string | number

Top margin, overrides margin.

marginEnd?: string | number

Right/end margin, overrides margin.

marginBottom?: string | number

Bottom margin, overrides margin.

marginStart?: string | number

Left/start margin, overrides margin.