pixi-wheels

index

pixi-wheels


pixi-wheels / index

index

Classes#

ClassDescription
DebugRingSkinThe plain skin: flat alternating fills, section index and id, the start angle of every section, degree marks on the disc and a line at every pointer. Nothing pretty, everything legible. Use it while wiring a wheel, or as the base of a headless-looking recipe.
EventEmitterTyped event emitter with zero dependencies.
GraphicsPointerSkinA pointer drawn with Graphics. The out-of-the-box tongue.
GraphicsRingSkinThe default look: painted wedges, dividers, a rim, a hub and fitted labels. Good enough to ship a prototype, and every colour comes from the section styles so a config alone changes the palette.
HeadlessRingSkinA skin that draws nothing. What the headless test harness uses.
PointerA pointer: the fixed mark a ring is read against.
RingOne spinning disc with its sections, pointers and skin.
RingBuilderConfigures one ring. Reached through WheelBuilder.ring(id, (r) => ...); the wheel builder’s own section methods are this, for the main ring.
RingGeometryThe sections of one ring, laid out around the circle.
SectionLabelsOne label per section, placed at the section’s middle angle. Shared by the graphics, texture and Spine skins so labels behave the same everywhere: radial, tangential or upright, fitted to the room the section has, and re-centred every time a dynamic section moves.
SpinControllerThe spin state machine of one ring.
TexturePointerSkinA pointer that is a sprite. Bring the game’s own stopper art.
TextureRingSkinA skin for a pre-rendered wheel: the game’s own painted disc as one texture, an optional static frame, and optional per-section sprites that the geometry keeps centred. Sections stay logical (weights, ids, values): the engine still knows where each one is, it just does not paint them.
TickerRefSafe wrapper around PixiJS Ticker subscriptions.
WheelA bonus wheel: one or more rings sharing a centre and one typed event stream. Place it like any container; everything else goes through the methods below.
WheelBuilderFluent construction of a Wheel. Validates on build() and throws a message that names the missing or conflicting call.

Interfaces#

InterfaceDescription
AnticipationOptions-
AssetResolverResolves asset keys named in a serialised config to loaded textures.
DebugOverlayHandleContract for objects that allocate resources and need cleanup.
DebugOverlayOptions-
DebugRingSnapshot-
DebugSectionSnapshotOne section in a snapshot. Plain numbers, rounded for reading.
DebugSnapshotPlain-JSON state of the whole wheel. No PixiJS objects, no cycles: it serialises, so an agent that cannot see the canvas can still read it.
DisposableContract for objects that allocate resources and need cleanup.
DynamicSectionsConfigA named set of dynamic steps plus how the wheel moves between them.
FitOptions-
FlapConfigThe pointer flap: how the tongue behaves against the pegs.
GraphicsPointerSkinOptions-
GraphicsRingSkinOptions-
IdleConfigSlow rotation while nothing is happening, so a wheel parked beside the reels reads as live.
LabelContextWhat a content factory receives: the section, its geometry and the room it has.
LabelSlotThe room a label has inside its wedge. width/height are the fit box, oriented like the label.
LabelSlotOptions-
LandingOptions-
PegConfigThe pegs a tongue touches: small circles on the disc, one per divider by default. They give the pointer flap its physics and the debug overlay draws them; a skin may draw them too (GraphicsRingSkin pegs).
PlanSkipInput-
PlanStopInput-
PointerConfigA pointer (“tongue”, “flapper”, “stopper”): the fixed mark the wheel is read against. A ring may have several, at different angles.
PointerConfigEntryA pointer in a config: its placement plus a serialised skin.
PointerCrossingA divider crossing, as Pointer.update() reports it.
PointerSkinThe visual of a pointer. Drawn in a local space where the pin (the point it pivots around) is at (0, 0) and the tip is at (+length, 0). The ring positions and rotates the view so the tip faces the hub or the rim.
PointerSkinConfig-
PointerSkinConfigGraphics-
PointerSkinConfigTextureThe serialised form of TexturePointerSkinOptions: the texture by asset key.
PointerSpecA pointer as the builder accepts it: placement plus a skin instance or config.
ResolvedAnticipationA bait with its geometry resolved against the ring. Built by the ring, consumed here.
ResolvedPegsThe pegs with their geometry resolved against the ring.
ResolvedSectionA section with its geometry resolved. Angles are wheel-local degrees: they rotate with the disc. startAngle is where the section begins going clockwise; endAngle = startAngle + arc. Both are kept unnormalised and increasing across the ring so endAngle of section i equals startAngle of section i + 1.
ResolvedSectionStyleEvery style field resolved, as a skin receives it.
ResolvedTargetA target after the ring’s geometry has been consulted.
ResolveTargetOptions-
RingConfigOne ring, serialised.
RingGeometryOptions-
RingParams-
RingSkinHow a ring looks. The ring owns the motion (rotation, sections, pointers); a skin owns the pixels. Swap GraphicsRingSkin for TextureRingSkin or a Spine skin and nothing about the spin changes.
RingSkinConfigA skin as a serialised config: the shape the studio exports and WheelBuilder.fromConfig() reads. type picks a registered factory; the rest is that factory’s options. Asset references are string keys resolved through an AssetResolver.
RingSkinConfigTextureThe serialised form of TextureRingSkinOptions: textures by asset key.
RingSkinContextWhat a ring hands its skin when the skin is attached.
SectionStylePer-section look. Everything is optional: a section with no style gets the skin’s palette colour for its index and the skin’s default label style. Skins that draw from textures or Spine ignore the paint fields and only read the label ones.
SettleConfig-
Size-
SkipConfigWhat a player’s skip press is allowed to do.
SpinHostWhat the controller needs from its ring. Kept as an interface so the controller is testable without PixiJS.
SpinOptionsOptions for a single spin() call.
SpinProfileA spin’s timing. Speeds are degrees per second; times are milliseconds. SpinPresets ships a few; builder.speed(name, profile) registers your own.
StopLegOne piece of a planned stop: cover distance degrees in duration ms along ease, forwards unless reverse. A plan is a list of these played back to back, so anticipation, skip and settle are all the same machinery.
StopPlan-
TargetAdapterConfigA serialisable description of how to read a wheel target out of a server response: which field, interpreted how. This is the shape the studio exports and createTargetAdapter compiles.
TexturePointerSkinOptions-
TextureRingDecoration-
TextureRingSkinOptions-
WeightTransitionOptionsOptions for an animated weight change.
WheelConfigA whole wheel as JSON. What the studio exports, what WheelBuilder.fromConfig() builds from, and what builder.toConfig() gives back. Asset references (textures, Spine aliases) are string keys resolved at build time.
WheelEventsEvery event a wheel emits. One emitter per wheel; every payload names the ring it came from ('main' for single-ring wheels), so a two-ring wheel needs no second subscription.
WheelParams-
WheelResultOptionsOptions for wheel.setResult(): a ring plus the landing options.
WheelSectionConfigOne section as the consumer authors it.
WheelSpinOptionsOptions for wheel.spin(): a ring to spin plus the per-spin options.
WheelSpinResultWhat spin() resolves with.

Type Aliases#

Type AliasDescription
AnticipationStyleThe shape of a near-miss. The wheel decelerates once and comes to rest once, on the result: no style stops somewhere else and moves on. The pointer rests just inside the target, next to the divider it shares with the bait (rest), so the miss reads as “by a hair”.
DebugHudPlacementWhere the HUD panel goes, in screen pixels on the wheel’s root container (the stage). Corners on the right or bottom need screen; { x, y } pins it exactly; false draws no panel.
DebugOverlayLayerOverlay layers. - sections divider lines on the disc, plus an upright pill just inside the rim with each section’s id and start angle. - pointers a marker at every pointer angle and a pill with the local angle under it. - pegs the pegs the tongues touch, the peg being ridden, and each tongue’s contact zone. - target the landing angle of the current result: a line on the disc and a pill naming it. - hud a panel per ring in screen space: state, rotation, speed, current leg, section under the pointer, flap.
DynamicStepA step in a dynamic-section sequence: the weights every named section takes when the wheel moves to that step. Sections not named keep their current weight.
EaseAn ease, as the name of a built-in curve or a function.
EaseFnA normalised easing function: f(0) = 0, f(1) = 1.
FitModeHow content meets the box it is fitted into.
LabelContentAnything a section shows instead of a text label: a Text, a Sprite, a BitmapText, a Spine instance, a whole Container of them. Pass the object, or a factory that builds it once from the section’s context. The label layer positions, rotates and fits it like a text label; it is re-fitted whenever the geometry changes. Code only: toConfig() keeps label and drops content.
LabelOrientationHow a label sits in its wedge.
LandingModeWhere inside the target section the pointer ends up.
LogLevelHow much the library is allowed to say. Each level includes the ones before it.
PointerFacingWhich way a pointer’s tip faces.
PointerSkinFactory-
RingSkinFactory-
SettleModeWhat the wheel does once the pointer has reached the landing angle.
SpinDirection-
SpinStateWhere a ring is in its life.
StopLegKindWhat one leg of a stop is for. Drives events and debug output; the motion is the same.
TickerCallback-
WheelTargetWhere a spin should land, as the server or the game decides it.
WheelTemplateName-

Variables#

VariableDescription
DEFAULT_ANTICIPATIONTiming and rest of a near-miss when AnticipationOptions leaves them out.
DEFAULT_FLAP-
DEFAULT_LANDING-
DEFAULT_PALETTEA palette that reads on a dark casino background and keeps neighbouring sections distinct even for eight or more wedges. Cycled by section index.
DEFAULT_PEGSPegs when a ring asks for them without details.
DEFAULT_POINTER-
DEFAULT_SETTLE-
DEFAULT_SKIP-
DEFAULTS-
DEG_TO_RADDegrees to radians.
EASE_NAMESEvery ease name resolveEase accepts, for error messages and pickers.
NO_ASSETSAn asset resolver that throws on any key: for configs that reference no assets.
OVERLAY_LABEL-
RAD_TO_DEGRadians to degrees.
SpinPresetsReady-made spin feels. Register them by name and switch at run time.
WHEEL_CONFIG_VERSIONThe current config schema version. Bumped when a field changes meaning.
WHEEL_TEMPLATE_NAMESThe template names, for pickers.
WheelTemplatesReady-made wheel configs for the common shapes. Each is a plain WheelConfig: load one into WheelBuilder.fromConfig(), or copy the JSON into the studio and tune it there.

Functions#

FunctionDescription
arcDeltaThe positive angular distance travelled when rotating in direction from from to to, in [0, 360). Clockwise is the direction of increasing PixiJS rotation (screen y points down).
assertWheelConfigStructural check on a config object from an untrusted source (a file, a form). Throws a message that names the first problem. The builder runs the deeper validation (section ids, radii, eases) on build().
chordAtStraight-line width across an arc of arcDeg degrees at radius.
constantAccelEaseThe position curve of a constant-acceleration leg between two speeds. Normalised so f(0) = 0, f(1) = 1; the duration that makes this leg physically consistent is 2 * distance / (v0 + v1).
createPointerSkin-
createRingSkin-
createTargetAdapterCompile an adapter config into a function from any response to a WheelTarget.
debugArcThe ring unrolled into a line of text: every section as a box whose width is its arc, and a caret under the pointer. Read the wheel without seeing it.
debugOverlayDraw the wheel’s invisible geometry over it: dividers with their angles, pointer markers with the local angle under them, the pegs and the tongue’s contact, the planned landing angle, and a HUD panel per ring. Everything a developer stares at the canvas to guess is written out, at a readable size whatever scale the wheel is drawn at.
debugRingSnapshot-
debugSnapshot-
directionSign+1 for a clockwise spin (rotation increases), -1 for counter-clockwise.
enableDebugAttach the debug handle to window.__PIXI_WHEELS_DEBUG.
fitContainerScale any container (a Text, a Sprite, a Spine, a group) so its local bounds fit box. Sets obj.scale uniformly and returns the factor. Measure happens on the unscaled local bounds, so calling it again is idempotent.
fitTextFit a Text by lowering its font size instead of scaling its transform, so glyphs stay sharp. Leaves the scale at 1. Returns the font size it settled on. Up to four measure passes; minFontSize (default 6) is the floor.
getLogLevelThe active LogLevel.
hermiteStopEaseA stop curve that begins already moving: position goes 0 to 1 with initial slope startSlope (normalised: speed * duration / distance) and zero slope at the end. Monotonic for slopes in 0..3. Lets a leg take over from a slow crawl without a velocity step.
initialSlopeNumeric slope of an ease at t = 0, as a multiple of the average slope (which is 1 for a normalised curve). The stop planner divides by this to match the wheel’s cruise speed at the start of the deceleration, so the hand-off from cruise to stop has no velocity step.
isAngleInArcWhether angle lies inside the arc that starts at start and sweeps clockwise (increasing) for arc degrees. The start edge is inclusive, the end edge exclusive, so every angle belongs to exactly one section.
labelSlotCompute the box a section offers a label at a given radius: the chord across the wedge there, and the radial room between hub and rim around that point. SectionLabels uses it for every label; use it yourself to size custom content in a content factory or a skin.
localAngleUnderPointerThe wheel-local angle under a pointer, given the disc rotation. A point on the disc at local angle a appears on screen at a + rotation, so the screen angle pointer is over local pointer - rotation.
normalizeDegWrap an angle into [0, 360).
pickTurnsChoose how many full turns a stop should make.
planSettleThe legs a settle adds after landing. center glides the shortest way to the section’s middle; bounce overshoots and springs back.
planSkipThe fast-forward a skip plays: the shortest forward path to the landing, padded to at least a third of a turn so a slam never reads as a snap.
planStopPlan the deceleration from the current state to the landing rotation.
readPathRead a dotted path (a.b.0.c) off an object. Throws when a step is missing.
registerBuiltinSkinsRegister the built-in skin config types. Called from WheelBuilder.build() so a config-driven wheel always finds graphics, debug, texture, headless and the two pointer skins - a value import a bundler cannot drop, where a side-effect-only import could be.
registeredPointerSkinTypes-
registeredRingSkinTypes-
registerPointerSkin-
registerRingSkinMake a ring skin available to configs under type. The built-ins register themselves.
resolveEaseTurn an Ease into a function. Throws on an unknown name, naming the curves that exist, so a typo in a config fails at build time rather than producing a wheel that never stops.
resolveTargetTurn a WheelTarget into a section and a wheel-local landing angle.
rotationForLocalAngleThe disc rotation (normalised) that puts local angle local under the pointer.
scaleToFitThe scale factor that fits size into box under options. Pure; no PixiJS objects.
setLogLevelSet how much the library prints. Default 'info'.
signedDegWrap an angle into (-180, 180].
wedgePathTrace an annular sector (or a wedge when innerRadius is 0).