Skip to content
pixi-silk
GitHub repository
Reference

API reference

Each entry point is its own module: import only what you use. The root import holds the core.

ImportWhat it holds
pixi-silkSilkGraphics, createSilkApp, gradients (linear, radial, conic, along, mesh), colour and curve helpers, motion helpers, enableSilkBatching.
pixi-silk/signalsignal, computed, watch, batch: the small reactive store every widget state uses.
pixi-silk/selectionSelection store and bindOutline, bindGizmo, bindMeasure.
pixi-silk/historyHistory (undo and redo), recordSignals, recordGizmo, bindHistoryKeys.
pixi-silk/pathBezier path model: BezierPath, drawPath, parseSvgPath, pathToSvg and edit operations.
pixi-silk/ui/radialRadialMenu and bindRadialTrigger: a ring menu with submenus.
pixi-silk/ui/buttonSilkButton: pill, circle or squircle button with press, hold, busy and appear animations.
pixi-silk/ui/dockButtonDock: a row or column of SilkButtons that closes the gap when one hides.
pixi-silk/ui/gizmoTransformGizmo: move, rotate, scale and box handles.
pixi-silk/ui/outlineSelectionOutline: hover and selection outlines.
pixi-silk/ui/pathgizmoPathGizmo and PenTool: edit and draw Bezier paths.
pixi-silk/ui/cameraCamera: pan and zoom a world container, ZoomControl.
pixi-silk/ui/measureMeasure: size labels and red lines between objects.
pixi-silk/ui/gridCanvasGrid: dots or lines that follow the camera.
pixi-silk/ui/rulerRuler: screen-edge rulers that follow the camera.
pixi-silk/ui/guidesGuides: draggable guide lines from the rulers.
pixi-silk/ui/marqueeMarquee: drag a box to select.
pixi-silk/ui/groupSelectionGroup: transform several objects as one.
pixi-silk/ui/spacingSpacingMarkers and findSpacing: equal-gap hints.
pixi-silk/ui/snapSnapEngine and SnapGuides: snap boxes to edges, centres and lines.
pixi-silk/ui/colorColour pickers: wheels, rings, OKLCH, channel sliders.
pixi-silk/ui/haloContextHalo: a ring of actions around a selected object.
pixi-silk/ui/brushBrushCursor: a brush size and hardness cursor.
pixi-silk/ui/modesSegmentedSwitch and ModeSwitcher: tool mode pickers, including the hold-a-key ring.
pixi-silk/ui/dialJogDial and Scrubber: rotary and drag-to-change number inputs.
pixi-silk/ui/timelineMiniTimeline: frames, keys, loop range and playback.
pixi-silk/ui/odometerOdometer: a rolling number counter with prefix, decimals and count-up timing.
pixi-silk/ui/gesturetrackGesture: tap, hold, flick and drag from one target, with slop per pointer kind.
pixi-silk/ui/arcAngle maths for ring widgets: angleDelta, wrapAngle, snapTo, rubberBand.
pixi-silk/ui/keysShared keyboard state: isKeyDown, modifier checks, onKey, isTypingTarget.
pixi-silk/ui/pillValuePill: a small rounded label for live readouts (angles, sizes, distances).
pixi-silk/ui/texteditTextEditor: an editable SilkText field with caret, selection and IME.
pixi-silk/ui/panelPanel: a docked, scrolling side panel drawn on the canvas.
pixi-silk/ui/layersLayerTree: a layer tree over any data through an adapter, with selection and history.
pixi-silk/ui/inspectorInspector: property fields bound to the selection.
pixi-silk/ui/minimapMinimap: an overview of the world with the camera frame.
pixi-silk/glassGlass: a frosted pane that blurs and bends what is behind it.
pixi-silk/glowGlow, Aurora and light helpers (neon, halo, rays, spectrum).
pixi-silk/webgpuenableWebGPU: installs the WGSL shader for your own WebGPU Application.
pixi-silk/textSilkText: distance-field text with outline, shadow and gradient fill. SdfAtlas, layoutText, caret helpers.
pixi-silk/layoutLayoutNode: a headless flex layout engine with no Pixi in it.
pixi-silk/ui/layoutSmartContainer and FlexContainer: place and scale a design box in the window, flex children inside it.
pixi-silk/uiEvery widget and editor tool in one import. The per-widget subpaths ship less code.

The root import#

import { SilkGraphics, createSilkApp } from 'pixi-silk';

Classes#

ClassDescription
ConicGradientAn angular ramp around a centre. On arcs it follows the arc. Create it with conic.
GradientBase class of all gradients. Stops are interpolated premultiplied (OKLab by default), baked into a shared half-float atlas and dithered when sampled, which hides banding.
GradientAtlasAll gradient ramps live in one RGBA16F texture, 256 samples by 256 rows, shared by every SilkGraphics. Half floats keep about 11 bits per channel, so dark and low-alpha ramps are not quantised before the shader dithers them to the 8-bit framebuffer. You rarely need it directly.
LinearGradientA straight ramp between two points. Create it with linear, vertical or horizontal.
MeshGradientA smooth colour surface through a grid of control colours, like a gradient mesh in Illustrator. Colours blend with a bicubic spline in its space (OKLab by default), so falloffs stay soft in both directions. The surface is baked at 16x16 samples. Create it with mesh.
PathGradientA ramp that follows a stroke from its first point (t = 0) to its last (t = 1). Create it with along.
RadialGradientA ramp from a centre outwards, optionally starting at an inner radius. Create it with radial.
SilkGeometryGeometry behind every SilkGraphics: one unit quad plus an interleaved instance buffer of 44 floats (STRIDE) per primitive. You rarely need it directly.
SilkGraphicsA PixiJS display object with a Graphics-like API. Every primitive is a signed distance field evaluated per pixel, so edges stay sharp at any zoom, rotation and device pixel ratio. Each object is one instanced draw call, and enableSilkBatching() merges neighbours further.
SilkPipeRender pipe that draws runs of consecutive SilkGraphics in one instanced draw call, under WebGL2 and WebGPU. enableSilkBatching installs it.
SpringDamped harmonic spring with unit mass, integrated in fixed 1/240 s sub-steps. stiffness and damping follow the usual UI spring convention. The defaults are 170 and 26.

Interfaces#

InterfaceDescription
AreaOptionsOptions of area(): monotone smoothing of the series and its sample spacing.
ConicGradientOptionsOptions of conic: stops plus centre, start angle and sweep.
FillStyleHow a fill is painted: colour or gradient, opacity, blur with spread, blend mode and inner shadows.
GradientOptionsOptions shared by every gradient: colour stops, interpolation space, easing, extend mode and units.
InnerShadowA shadow drawn inside the shape from its own distance field, with Figma’s semantics. The shape is moved by x and y, shrunk by spread and blurred. What it no longer covers is shaded.
LinearGradientOptionsOptions of linear: stops plus the start and end points of the ramp.
MeshGradientOptionsOptions of mesh: where the grid sits, its units and its interpolation space.
PolylineOptionsOptions of polyline(): closed loops and monotone or Catmull-Rom smoothing of the points.
ProgressiveBlurA blur that changes across the shape, like Figma’s progressive layer blur. The radius goes from from at one edge of the shape to to at the opposite edge, along angle.
RadialGradientOptionsOptions of radial: stops plus centre, outer radius and inner radius.
SilkAppWhat createSilkApp returns: the Pixi application, its CSS size and resolution, and helpers to change or destroy it.
SilkAppOptionsOptions of createSilkApp: Pixi application options plus the element to fill, DPR limits and touch behaviour.
SilkGraphicsOptionsPer-object rendering settings of a SilkGraphics: dithering, anti-aliasing width and hairline threshold.
StrokeStyleHow a stroke is painted: width (or tapered widths), alignment, caps, dashes, plus everything in FillStyle.

Type Aliases#

Type AliasDescription
ColorSpaceColour space gradients are interpolated in: perceptual OKLab (default), linear light, or plain sRGB.
EasingHow the ramp moves between stops.
ExtendModeWhat a gradient does outside 0..1: hold the end colours (pad), tile (repeat) or mirror (reflect).
FillInputWhat fill() accepts: any Pixi colour, a gradient or a FillStyle.
GradientUnitsGradient coordinates: shape = fractions of each painted shape’s box, local = the graphics’ local units (one ramp across many shapes).
LineCapShape of the ends of open paths and of every dash: flat, round or square.
LineJoinShape of the corners where two segments of a stroke meet.
MeshColorInputA mesh control colour: any Pixi colour, or [color, alpha].
PointsInputPoints as a flat [x0, y0, x1, y1, ...] array, a typed array, or an array of { x, y } objects.
RGBAStraight (non-premultiplied) sRGB colour with alpha, all channels 0..1, as returned by parseColor.
ShapeOpA shape operation: union merges, subtract cuts the later shapes out of the first, intersect keeps the overlap, and exclude keeps what is covered an odd number of times.
StopInputA color stop: a bare color (stops are spread evenly), [offset, color], [offset, color, alpha] or { offset, color, alpha }.
StrokeInputWhat stroke() accepts: any Pixi colour, a gradient or a StrokeStyle.
Vec2A point [x, y]. In shape units, x and y are fractions of the painted shape’s box.

Variables#

VariableDescription
easeEasing curves for tweens (t from 0 to 1): inOutCubic, outCubic, inOutSine, outExpo.

Functions#

FunctionDescription
alongGradient that follows a stroke from its first point (t = 0) to its last (t = 1).
catmullRomSamples a centripetal Catmull-Rom spline through flat points. It has no cusps or self-loops within a segment. closed adds the segment back to the first point. step is the target sample spacing in local units, at most 64 per segment. alpha 0.5 is centripetal (0 uniform, 1 chordal). Fewer than 3 points come back as a copy.
conicConic (angular) gradient. On arcs and sectors it spans the arc by default, so a ring’s ramp always runs from its start cap to its end cap.
createSilkAppCreates a Pixi application, appends its canvas to parent and keeps it sized to it.
dampExponential approach: returns current moved towards target over dtSeconds. lambda is about 1 / seconds, higher is snappier. It never reaches the target exactly.
dampAngleLike damp for angles in radians: it turns the short way round. The result is not wrapped to one turn.
enableSilkBatchingTurns on batching across objects, which is off by default. Runs of consecutive SilkGraphics with the same blend mode and settings then render in one draw call. Only objects created after the call take part, and an object with batch: false never does. There is no call to turn it off. Each renderer gets the pipe the first time it draws one of them, so you can call it before or after creating the Application. It is safe to call again.
horizontalLeft-to-right linear gradient across each painted shape’s box.
linearLinear gradient. from / to default to top and bottom of the shape’s box (units: 'shape').
linearToOklabConverts linear-light sRGB to OKLab (Björn Ottosson’s perceptual colour space), used to interpolate gradients evenly.
meshGradient mesh: cols by rows control colours (row by row, top-left first) spread over the painted shape’s box, blended into one smooth surface. cols and rows are clamped to 1..16. Missing colours repeat the last one.
monotoneXMonotone cubic interpolation in x (Steffen’s method, same family as d3’s monotoneX). Never overshoots the data: peaks stay at the data points, flat runs stay flat. step is the target spacing of the output samples in local units, at most 64 per segment. Points must be sorted by x. Fewer than 3 points come back as a copy.
oklabToLinearConverts OKLab back to linear-light sRGB. Out-of-gamut colours fall outside 0..1, so callers clamp.
parseColorConverts any Pixi ColorSource to straight sRGB [r, g, b, a], channels 0..1, with alpha multiplied in. Returns a new array. Numbers and strings are cached, up to 1024 of them.
radialRadial gradient from center (default the box centre) out to radius, optionally starting at innerRadius.
toFlatCopies any PointsInput into a new flat [x0, y0, x1, y1, ...] array.
verticalTop-to-bottom linear gradient across each painted shape’s box.