v8.18.0
Added
- Add graphicsContextToSvg() function to export Graphics or GraphicsContext to a self-contained SVG string
- Add mask channel selection option to setMask() to pick which texture channel (red or alpha) drives visibility
- Allow preference parameter to accept an array of renderer types in autoDetectRenderer and Application.init
- Add domContainerRoot getter to Application to access the HTMLDivElement wrapping DOMContainer elements
- Add width option to MeshRope to allow explicit rope thickness decoupled from texture height
- Add defaultAnchor option to renderer.generateTexture() and textureOptions parameter to RenderTexture.create()
Changed
- Text/HTMLText/BitmapText with wordWrap: true and non-left align now return the true rendered width from text.width instead of reporting wordWrapWidth
Fixed
- Text.width and word wrap returning incorrect values
- Stroke-only Graphics masks now render correctly on Canvas renderer
- Skip _applyMipRange for single-mip textures on iOS 18.0–18.1
- Stale TextureMatrix when pooled textures reuse the same reference
- Unhandled actions in GraphicsPath.transform() switch statement
- VideoSource play/mediaReady recursion before video dimensions are known
💾 Download
Installation:
npm install pixi.js@8.18.0
Development Build:
- https://cdn.jsdelivr.net/npm/pixi.js@8.18.0/dist/pixi.js
- https://cdn.jsdelivr.net/npm/pixi.js@8.18.0/dist/pixi.mjs
Production Build:
- https://cdn.jsdelivr.net/npm/pixi.js@8.18.0/dist/pixi.min.js
- https://cdn.jsdelivr.net/npm/pixi.js@8.18.0/dist/pixi.min.mjs
Documentation:
Changed
https://github.com/pixijs/pixijs/compare/v8.17.1...v8.18.0
🚨 Behavior Change
- fix:
text.widthand word wrap returning incorrect values by @Zyie in https://github.com/pixijs/pixijs/pull/12007Text/HTMLText/BitmapTextwithwordWrap: trueand non-leftalign(center/right/justify) now return the true rendered width fromtext.widthinstead of reportingwordWrapWidth. If you relied ontext.width === wordWrapWidthfor layout, usewordWrapWidthdirectly or wrap the text in a sized container.
const text = new Text({ text: 'hello', style: { wordWrap: true, wordWrapWidth: 800, align: 'center' }, }); // before: text.width === 800 // after: text.width reflects the rendered string width
🎁 Added
- feat: add
graphicsContextToSvg()for Graphics → SVG export by @GoodBoyDigital in https://github.com/pixijs/pixijs/pull/11989- Adds
graphicsContextToSvg(source, precision?), a pure function that serializes aGraphicsorGraphicsContextto a self-contained SVG string. Supports rects, circles, ellipses, rounded rects, polygons, bezier/quadratic/arc paths, strokes, holes (viafill-rule="evenodd"), and linear/radial gradients.
import { Graphics, graphicsContextToSvg } from 'pixi.js'; const g = new Graphics() .rect(0, 0, 100, 50) .fill({ color: 0xff0000 }) .circle(150, 25, 25) .stroke({ color: 0x0000ff, width: 4 }); const svgString = graphicsContextToSvg(g, 2); await navigator.clipboard.writeText(svgString); - Adds
- feat: add mask channel selection for sprite masks by @Zyie in https://github.com/pixijs/pixijs/pull/11987
setMask()gains achanneloption ('red' | 'alpha') to pick which texture channel drives visibility, matching how design tools like Figma apply PNG masks. Default remains'red'.
import { Assets, Sprite } from 'pixi.js'; const photo = new Sprite(await Assets.load('photo.png')); const maskSprite = new Sprite(await Assets.load('mask-alpha.png')); photo.setMask({ mask: maskSprite, channel: 'alpha', }); - feat: allow
preferenceto accept an array of renderer types by @Zyie in https://github.com/pixijs/pixijs/pull/11963autoDetectRendererandApplication.initnow accept an array of renderer names forpreference, letting you restrict the fallback chain (e.g. disable WebGPU entirely) rather than only reorder it. A newRendererPreferencetype is exported.
import { Application, autoDetectRenderer } from 'pixi.js'; const renderer = await autoDetectRenderer({ preference: ['webgl', 'canvas'], }); const app = new Application(); await app.init({ preference: ['webgl', 'canvas'] }); - feat: provide a getter to the domElement via
app.domContainerRootby @carlos22 in https://github.com/pixijs/pixijs/pull/11974Applicationexposes a read-onlydomContainerRootgetter returning theHTMLDivElementthat wraps allDOMContainerelements, so apps can add CSS classes, inline styles, or customize the DOM overlay root.
import { Application } from 'pixi.js'; const app = new Application(); await app.init({ resizeTo: window }); app.domContainerRoot.classList.add('pixi-dom-layer'); app.domContainerRoot.style.pointerEvents = 'auto'; - feat: add
widthoption toMeshRopeby @mehmetcanakbay in https://github.com/pixijs/pixijs/pull/11990MeshRopenow accepts an explicitwidthfor rope thickness, decoupling it from the texture's height. Omittingwidthpreserves the previoustexture.heightdefault.
import { MeshRope, Point, Texture } from 'pixi.js'; const points = [new Point(0, 0), new Point(100, 50), new Point(200, 0)]; const rope = new MeshRope({ texture: Texture.from('snake.png'), points, width: 40, }); - feat: add a default anchor to texture generation by @ksv90 in https://github.com/pixijs/pixijs/pull/12011
renderer.generateTexture()accepts adefaultAnchoroption that's forwarded onto the producedTexture.RenderTexture.create()also gains atextureOptionsparameter to pass through fields likedefaultAnchorto the underlyingTexture.
import { Graphics, Sprite } from 'pixi.js'; const shape = new Graphics().circle(0, 0, 50).fill(0xff3366); const texture = app.renderer.generateTexture({ target: shape, defaultAnchor: { x: 0.5, y: 0.5 }, }); const sprite = new Sprite(texture); sprite.position.set(200, 200); // centered by default
🐛 Fixed
- fix: stroke-only Graphics masks now render correctly on Canvas renderer by @DmitriyGolub in https://github.com/pixijs/pixijs/pull/11979
- fix: skip
_applyMipRangefor single-mip textures (iOS 18.0–18.1) by @GoodBoyDigital in https://github.com/pixijs/pixijs/pull/11985 - fix: stale
TextureMatrixwhen pooled textures reuse the same reference by @GoodBoyDigital in https://github.com/pixijs/pixijs/pull/11997 - fix: unhandled actions in
GraphicsPath.transform()switch statement by @Zyie in https://github.com/pixijs/pixijs/pull/11996 - fix(VideoSource): avoid play/mediaReady recursion before video dimensions (#11133) by @satoren in https://github.com/pixijs/pixijs/pull/12009
- fix:
text.widthand word wrap returning incorrect values by @Zyie in https://github.com/pixijs/pixijs/pull/12007 - fix: handle literal
<characters inparseTaggedTextby @glennflanagan in https://github.com/pixijs/pixijs/pull/11972 - fix: move
CanvasFilterSystemto the filters module by @Zyie in https://github.com/pixijs/pixijs/pull/12014 - fix:
SplitTextbaseline mismatch whentagStylesused withlineHeightby @Zyie in https://github.com/pixijs/pixijs/pull/12008 - fix:
TilingSprite.tilePositiondivided by resolution when using Canvas renderer by @Zyie in https://github.com/pixijs/pixijs/pull/11957 - fix: move
CanvasFilterSystemto filters module by @Zyie in https://github.com/pixijs/pixijs/pull/12014 - fix(VideoSource): avoid play/mediaReady recursion before video dimensions by @satoren in https://github.com/pixijs/pixijs/pull/12009
🧹 Chores
- chore: bump
@xmldom/xmldomto 0.8.12 by @Zyie in https://github.com/pixijs/pixijs/pull/12016
New Contributors
- @mehmetcanakbay made their first contribution in https://github.com/pixijs/pixijs/pull/11990
- @DmitriyGolub made their first contribution in https://github.com/pixijs/pixijs/pull/11979
- @carlos22 made their first contribution in https://github.com/pixijs/pixijs/pull/11974
- @satoren made their first contribution in https://github.com/pixijs/pixijs/pull/12009
- @ksv90 made their first contribution in https://github.com/pixijs/pixijs/pull/12011
- @glennflanagan made their first contribution in https://github.com/pixijs/pixijs/pull/11972