Skip to content
pixi-silk
GitHub repository
Function

createSilkApp

import { createSilkApp } from 'pixi-silk';
function createSilkApp(options: SilkAppOptions): Promise<SilkApp>;

Creates a Pixi application, appends its canvas to parent and keeps it sized to it.

It starts WebGL2 by default and WebGPU with preference: 'webgpu'. MSAA is off, since SilkGraphics anti-alias their own edges. The backing store is sized from devicePixelContentBoxSize, so each canvas pixel is one device pixel even at fractional DPRs such as 1.25 or 2.625. It follows DPR changes from browser zoom or a move to another display. Coordinates are not rounded, so motion stays sub-pixel smooth. Any other Pixi option you pass overrides these defaults.

It also listens for pointercancel on window. Pixi ignores that event, so a touch the page takes over for a scroll would leave a drag running. The app ends it with pointerupoutside.

Parameters#

ParameterType
optionsSilkAppOptions

Returns#

Promise<SilkApp>

Example#

const silk = await createSilkApp({ parent: document.getElementById('stage')!, background: 0x0b0b0d });
silk.app.stage.addChild(new SilkGraphics().circle(100, 100, 40).fill(0x30d158));