File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -267,6 +267,15 @@ export interface RendererMainSettings {
267267 * @defaultValue `true`
268268 */
269269 strictBounds ?: boolean ;
270+
271+ /**
272+ * Canvas object to use for rendering
273+ *
274+ * @remarks
275+ * This is used to render the scene graph. If not provided, a new canvas
276+ * element will be created and appended to the target element.
277+ */
278+ canvas ?: HTMLCanvasElement ;
270279}
271280
272281/**
@@ -358,6 +367,7 @@ export class RendererMain extends EventEmitter {
358367 quadBufferSize : settings . quadBufferSize ?? 4 * 1024 * 1024 ,
359368 fontEngines : settings . fontEngines ,
360369 strictBounds : settings . strictBounds ?? true ,
370+ canvas : settings . canvas || document . createElement ( 'canvas' ) ,
361371 } ;
362372 this . settings = resolvedSettings ;
363373
@@ -367,12 +377,12 @@ export class RendererMain extends EventEmitter {
367377 deviceLogicalPixelRatio,
368378 devicePhysicalPixelRatio,
369379 inspector,
380+ canvas,
370381 } = resolvedSettings ;
371382
372383 const deviceLogicalWidth = appWidth * deviceLogicalPixelRatio ;
373384 const deviceLogicalHeight = appHeight * deviceLogicalPixelRatio ;
374385
375- const canvas = document . createElement ( 'canvas' ) ;
376386 this . canvas = canvas ;
377387 canvas . width = deviceLogicalWidth * devicePhysicalPixelRatio ;
378388 canvas . height = deviceLogicalHeight * devicePhysicalPixelRatio ;
You can’t perform that action at this time.
0 commit comments