pixi-silk
v1.5.2
Published
Smooth vector graphics for PixiJS v8: analytic anti-aliased SDF primitives, squircles, arcs, polylines, dashes, OKLab gradients, glows and DPR-exact canvases, one draw call per object.
Maintainers
Readme
pixi-silk
Smooth vector graphics for PixiJS v8. Every shape is an exact signed distance field that the shader anti-aliases per pixel, so edges stay clean at any zoom, rotation and device pixel ratio, without MSAA.
Docs | Getting started | API reference | Studio | Showcase | FAQ
Contents
- Why pixi-silk
- Install
- AI agent skills
- Quick start
- Gallery
- Coming from Graphics
- What is in the package
- Localized text
- Requirements
- What pixi-silk does not do
- Contributing
- Contributors
- License
Why pixi-silk
Pixi Graphics turns a shape into triangles once. The edge is only as smooth as the triangles and the
canvas antialiasing allow, and a hairline or a slow drift shows it. SilkGraphics sends each shape to
the shader as a few numbers and evaluates its exact distance field for every pixel.
- Edges stay smooth under zoom, rotation, sub-pixel motion and any device pixel ratio. MSAA stays off.
- An API close to
Graphics.rect,roundRect,circle,moveTo,lineTo,fill,strokeand the transform stack work as you expect, so moving code over is mostly a rename. - More than Graphics draws. Squircle corners, tapered and dashed strokes, round joins on any path, shape unions and cut-outs, gradients along a stroke, blur, inner and outer shadows, glow and glass.
- Few draw calls. A SilkGraphics packs its shapes into instances. After
enableSilkBatching(), consecutive SilkGraphics with the same blend mode render in one draw call. - Bundles only what you import. One entry point per area,
sideEffects: false, and the WebGPU shader loads only when WebGPU runs. - Text, layout and widgets on the same rendering. Distance field text in any script, a flex layout engine, buttons, radial menus, counters and an editor kit.
Install
npm install pixi-silk pixi.jspixi.js 8.6 or newer is a peer dependency. pnpm and yarn work the same.
AI agent skills
pixi-silk ships ten agent skills. A router skill picks the right one for the task. The others cover
drawing, paint, text, localized text, layout, widgets, the editor kit, app setup and moving code
from Graphics. They follow the open Agent Skills format, so Claude Code,
Codex, Cursor, Gemini CLI, Copilot and any agent that reads SKILL.md files can use them. Every code
block in them type-checks against the library in CI.
Install them with the skills CLI, which finds your agents and puts the skills where each one looks:
npx skills add schmooky/pixi-silk --list # see what is in the repo
npx skills add schmooky/pixi-silk # this project, pick agents and skills
npx skills add schmooky/pixi-silk -g # every project on this machine
npx skills add schmooky/pixi-silk -a claude-code -y # one agent, no promptsThe skills also ship inside the npm package. After npm install pixi-silk they are in
node_modules/pixi-silk/skills/, the same version as the code you installed: copy that folder to
.claude/skills/, .agents/skills/ or .cursor/skills/.
Agents without skill support can read llms.txt, which indexes the docs as plain text. Contributors working on this repo should read AGENTS.md.
Quick start
import { conic, createSilkApp, SilkGraphics, vertical } from 'pixi-silk';
const { app } = await createSilkApp({ parent: document.getElementById('stage')!, background: 0x000000 });
const g = new SilkGraphics();
g.roundRect(10, 10, 340, 140, 22, 0.6).fill(0x1c1c1e); // radius 22, squircle smoothing 0.6
g.arcSweep(80, 80, 44, -Math.PI / 2, Math.PI * 1.5)
.stroke({ width: 12, cap: 'round', gradient: conic([0x30d158, 0xffd60a, 0xff453a]) });
g.area([120, 100, 170, 80, 220, 92, 270, 60, 320, 70], 130, { smooth: 'monotone' })
.fill(vertical([[0, 0xff9f0a, 0.8], [1, 0xff9f0a, 0]]))
.stroke({ width: 2, color: 0xff9f0a, cap: 'round' });
app.stage.addChild(g);That draws a squircle card, a gauge with a conic gradient and a smoothed area chart:
createSilkApp turns MSAA off and maps one canvas pixel to one device pixel. In your own Pixi
Application, new SilkGraphics() works as it is. Getting started
walks through both.
Gallery
Every clip is a live demo on the docs site, recorded in Chrome. Open a page to change its controls and read the code that draws it.
Coming from Graphics
Most Graphics code runs after a rename:
import { SilkGraphics } from 'pixi-silk';
const g = new SilkGraphics(); // was: new Graphics()
g.roundRect(0, 0, 200, 80, 16).fill(0x1c1c1e).stroke({ width: 2, color: 0x0a84ff });
g.moveTo(20, 60).lineTo(100, 20).lineTo(180, 60).stroke({ width: 3, color: 0xffffff, cap: 'round' });Texture and pattern fills, svg() import and a shared GraphicsContext stay with Graphics, and
the two can sit side by side in one scene. Migrating from Graphics
lists every difference.
What is in the package
The root import holds SilkGraphics, gradients, createSilkApp, motion helpers and
enableSilkBatching(). Everything else is its own entry point, so an app bundles only what it
imports.
| Import | What it holds |
|---|---|
| pixi-silk | Shapes, lines, free paths, shape operations, gradients, blur and shadows |
| pixi-silk/text | SilkText, distance field text |
| pixi-silk/i18n, pixi-silk/i18n/pixi | Localized rich text, shaped at build time, in any script |
| pixi-silk/i18n/canvas, pixi-silk/i18n/shaper | Player names inside localized messages |
| pixi-silk/text/bidi | The Unicode Bidirectional Algorithm on its own |
| pixi-silk/layout, pixi-silk/ui/layout | A flex layout engine and the Pixi containers built on it |
| pixi-silk/glass, pixi-silk/glow | Glass and glow filters |
| pixi-silk/webgpu | The WGSL shader, for WebGPU in your own Pixi app |
| pixi-silk/webgl1 | Opt-in shaders for Pixi's WebGL1 fallback |
| pixi-silk/ui/* | Buttons, radial menus, counters and the editor kit |
Choose an entry point lists every subpath. The editor kit (camera, rulers, gizmos, pickers, panels) is experimental in 1.x: its API may change in a minor release.
Localized text
Translated messages in any script, Arabic and Hebrew included, are compiled ahead of time. The
silk command of @pixi-silk/compiler reads a strings spreadsheet, your fonts and a theme. It
shapes every message with HarfBuzz and writes .silk bundles and lossless WebP atlas pages. The
game then downloads no font and no shaper.
npm install -D @pixi-silk/compiler
npx silk compile --config silk.config.json --strings strings.xlsx --theme theme.json --out public/i18nimport { Assets, extensions } from 'pixi.js';
import { Silk, SilkMessage, silkBundleLoader } from 'pixi-silk/i18n/pixi';
extensions.add(silkBundleLoader);
const silk = await Silk.create();
await silk.addBundle(await Assets.load('/i18n/ar.silk'));
const theme = silk.createTheme(await (await fetch('/i18n/theme.json')).json());
const set = await silk.prepare({
locale: 'ar',
theme,
messages: { coins: { key: 'shop.coins', values: { count: 0 } } },
});
const coins = new SilkMessage(set.get('coins'));
app.stage.addChild(coins);
coins.set({ count: 1250 }); // rewrites only the digitsLocalized text has the guide.
Requirements
pixi.js8.6 or newer, as a peer dependency- WebGL2 or WebGPU. WebGL2 is the default. For WebGPU, pass
preference: 'webgpu'tocreateSilkApp, or callenableWebGPU()frompixi-silk/webgpubefore the firstSilkGraphicsin your own Pixi app - WebGL1 is opt-in: pass
webgl1: enableWebGL1frompixi-silk/webgl1tocreateSilkApp
What pixi-silk does not do
| Not here | Use instead |
|---|---|
| Texture and pattern fills, svg() import, a shared GraphicsContext | Pixi Graphics or a Sprite next to SilkGraphics |
| Blur and shadows on other display objects | Pixi filters. Silk effects act on silk shapes, from their distance field |
| Routing, app state or DOM UI | Your app, or a DOM layer over the canvas |
| A document model for editors | Your app's own model. Selection and History store references and commands |
| Canvas 2D | A GPU renderer: WebGL2, WebGPU, or WebGL1 through pixi-silk/webgl1 |
The FAQ lists the other limits.
Contributing
A pnpm workspace. packages/pixi-silk is the library, packages/compiler is @pixi-silk/compiler
and apps/site is the docs site.
pnpm install
pnpm site:dev # docs at http://localhost:5178
pnpm --filter pixi-silk test # unit tests
pnpm build # library buildCONTRIBUTING.md covers checks, changesets and releases. The clips in this README are recorded from the docs demos by tools/readme-media.
Contributors
Thanks to everyone who has written code, docs and fixes for pixi-silk.
License
MIT
