Renderer
PixiFormUI draws with its own small scene graph on the browser's built-in Canvas 2D API
(src/lib/render/canvas.ts, about 1,000 lines, no dependencies).
Why Canvas 2D#
| Size | The standalone bundle with every control is about 57 KB gzipped. |
| Many forms per page | No WebGL contexts, so there's no per-page limit: 20 forms on one page mount in about half a second. |
| Compatibility | Works wherever <canvas> does, including browsers or devices with WebGL disabled. |
| Content Security Policy | Needs only script-src 'self': no 'unsafe-eval', no workers (worker-src 'none'), no blob: URLs. |
| Power use | Renders only when something changes; an idle form uses no CPU. |
API#
The primitives below are what the built-in controls use, and what custom controls are built from. Everything is exported from the library entry:
import { Application, Container, Graphics, Text, Rectangle, Circle, type FederatedPointerEvent } from 'pixiform';
Container: children,position/x/y,visible,alpha,mask,eventMode,cursor,hitArea,getBounds(),toLocal()/toGlobal(), events viaon/off/emit.Graphics:rect,roundRect,circle,poly,moveTo/lineTo/arc/quadraticCurveTo, thenfill(color | {color, alpha})andstroke({width, color, alpha, alignment, cap, join}). Alignment1is inside,0outside and0.5centred.Text: plain text withstyle(font, size, weight, fill, lineHeight, wordWrap, wordWrapWidth, breakWords),anchor, measuredwidth/height. Mutatingtext.style.xre-lays it out.- Pointer events:
pointerdown,pointerup,pointerupoutside,pointertap,pointermove,globalpointermove,pointerover/pointerout, andwheel, with bubbling andstopPropagation(). Application:init({ width, height, resizeTo, background, backgroundAlpha, resolution }),stage,screen,canvas,ticker,renderer.resize(),renderer.background,render(),destroy().
Limits (by design)#
- Translation-only transforms: no scale, rotation or skew (PixiFormUI never uses them).
- Hit-testing without a
hitAreauses bounding boxes. Interactive controls sethitArea. - Wheel events are not cancelled by the renderer. A handler calls
e.preventDefault()only when it actually scrolls (ScrollView, openSelectmenu), so the page scrolls normally over an embedded form.