Skip to main content

Function: flattenArea()

flattenArea(layers, createCanvas, canvasWidth, canvasHeight, area, width?, height?): OffscreenCanvas

Defined in: src/lib/rendering/sample/index.ts:115

Draw an area of the canvas as it's shown (the white background, then every layer mixed as shown) onto a new canvas, scaled to fit width × height. Parts outside the canvas stay transparent.

Only the area of each layer is used: at full size, its pixels are read (see copyPixels); scaled down (e.g. a preview of a large area), that part of each layer is drawn scaled.

Parameters​

layers​

readonly DrawableLayer[]

createCanvas​

CanvasFactory

canvasWidth​

number

canvasHeight​

number

area​

PixelRect

width?​

number = area.width

height?​

number = area.height

Returns​

OffscreenCanvas

Example​

flattenArea(app.drawables, app.createCanvas, app.width, app.height, { x: 10, y: 10, width: 10, height: 10 });