# SVG Loading PixiJS loads `.svg` files in one of two modes: rasterized to a texture (fast, fixed resolution) or parsed into a `GraphicsContext` (scalable vector, reusable across `Graphics` instances). Choose texture mode for backgrounds and decorative elements at a fixed size; choose Graphics mode for icons, UI elements, or anything that needs to scale or be modified at runtime. ## Quick Start ```ts const svgTexture = await Assets.load("icon.svg"); const sprite = new Sprite(svgTexture); const svgContext = await Assets.load({ src: "icon.svg", data: { parseAsGraphicsContext: true }, }); const graphic = new Graphics(svgContext); ``` By default, SVG files rasterize to a texture at their native size. Pass `parseAsGraphicsContext: true` in the `data` field to parse as vector geometry instead. ## Core Patterns ### Texture mode (default) ```ts const icon = await Assets.load("close.svg"); const button = new Sprite(icon); ``` The SVG is rasterized to a bitmap via the browser's native SVG-to-image pipeline, then uploaded as a `Texture`. Rendering is batched just like a regular sprite. Scaling up beyond the rasterized resolution pixelates; the rasterization happens once. ### Graphics mode ```ts const context = await Assets.load({ src: "logo.svg", data: { parseAsGraphicsContext: true }, }); const small = new Graphics(context); small.scale.set(0.5); const large = new Graphics(context); large.scale.set(3); ``` The SVG is parsed into a `GraphicsContext` (a compiled list of fill/stroke instructions). Both `Graphics` instances share the same context; cheap, and both stay crisp at any scale. ### Resolution for sharper texture mode ```ts const icon = await Assets.load({ src: "icon.svg", data: { resolution: 2 }, }); ``` For texture mode, you can pass `resolution` in `data` to rasterize at a higher density. Pairs with `autoGenerateMipmaps` for smooth downscaling. Doesn't apply in Graphics mode. ### Global default ```ts import { loadSvg } from "pixi.js"; loadSvg.config.parseAsGraphicsContext = true; ``` Flip the default mode globally. Any subsequent `Assets.load('*.svg')` call parses as Graphics unless overridden in the asset's `data` options. ### What Graphics mode parses Graphics mode reads `` (including `fill-rule="evenodd"` holes), ``, ``, ``, ``, ``, ``, and ``. Styling comes from the `fill`, `stroke`, `stroke-width`, `fill-opacity`, `stroke-opacity`, and `opacity` attributes or inline `style="..."`. Fills and strokes can reference `` and `` definitions through `url(#id)`; `gradientUnits` and percentage coordinates are honored. Not supported: `transform` attributes, `