
Pixijs Math
Install this when you are coding PixiJS v8 scenes and need transforms, layout rectangles, or hit testing without misusing Point, Matrix, and shape APIs.
Overview
pixijs-math is an agent skill for the Build phase that guides PixiJS v8 Point, Matrix, shape, layout-rectangle, and coordinate-conversion math for transforms and hit testing.
Install
npx skills add https://github.com/pixijs/pixijs-skills --skill pixijs-mathWhat is this skill?
- Covers Point, ObservablePoint, Matrix (translate/rotate/scale, apply, applyInverse, decompose)
- Shape primitives: Rectangle, Circle, Ellipse, Polygon, RoundedRectangle, Triangle with strokeContains and Polygon isCloc
- Rectangle layout helpers: pad, fit, enlarge, ceil, scale, getBounds, containsRect, intersects
- toGlobal / toLocal coordinate conversion across parent/child containers
- pixi.js/math-extras for vector ops and line/segment intersection helpers
- Documents Matrix 2D affine operations including decompose, apply, and applyInverse
- Covers six core shape classes plus Triangle and RoundedRectangle layout helpers
- Triggers on math-extras vector and line/segment intersection helpers via pixi.js/math-extras
Adoption & trust: 1.3k installs on skills.sh; 206 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You are wiring PixiJS transforms and pointers but keep getting wrong global positions, bad bounds, or unreliable hit tests on strokes and polygons.
Who is it for?
Solo builders shipping PixiJS v8 canvas or WebGL experiences who need authoritative patterns for matrices, rectangles, and hit testing in TypeScript.
Skip if: Teams not using PixiJS, or pure CSS/DOM layout work where canvas math primitives never apply.
When should I use this skill?
Working with coordinates, vectors, matrices, shapes, hit testing, or layout rectangles in PixiJS v8 (Point, Matrix, Rectangle, toGlobal, strokeContains, math-extras).
What do I get? / Deliverables
After the skill runs, your agent produces PixiJS v8 math code that uses the right types, Matrix/shape APIs, and math-extras helpers for layout and interaction.
- Correct PixiJS math usage in application code
- Hit-test and bounds logic aligned with v8 shape APIs
Recommended Skills
Journey fit
PixiJS math is applied while implementing canvas/WebGL UI and gameplay logic, which sits in the primary Build phase for frontend rendering code. Coordinates, matrices, and shape bounds are frontend implementation concerns tied to components, containers, and pointer interaction—not distribution or ops.
How it compares
Library-focused procedural knowledge for PixiJS math APIs—not a generic frontend design or deployment workflow.
Common Questions / FAQ
Who is pixijs-math for?
Indie game and interactive-UI developers using PixiJS v8 who want an agent to apply official math primitives correctly during implementation.
When should I use pixijs-math?
During Build (frontend) when you touch Point/Matrix, toGlobal/toLocal, Rectangle pad/fit/getBounds, Polygon winding, strokeContains, or math-extras intersections.
Is pixijs-math safe to install?
Review the Security Audits panel on this Prism page and the MIT-licensed SKILL.md in the repo before enabling it in your agent environment.
SKILL.md
READMESKILL.md - Pixijs Math
PixiJS exposes lightweight math primitives (Point, Matrix, shape classes) used throughout the library for transforms, hit testing, and coordinate conversion. Import `pixi.js/math-extras` to add vector operations (add, dot, magnitude, reflect) and Rectangle intersection/union helpers. ## Quick Start ```ts const parent = new Container(); parent.position.set(100, 100); parent.scale.set(2); app.stage.addChild(parent); const child = new Container(); child.position.set(50, 50); parent.addChild(child); const globalPt = child.toGlobal(new Point(0, 0)); const m = new Matrix() .translate(100, 50) .rotate(Math.PI / 4) .scale(2, 2); const world = m.apply(new Point(10, 20)); const hitArea = new Rectangle(0, 0, 200, 100); console.log(hitArea.contains(50, 50)); ``` **Related skills:** `pixijs-scene-container` (transform properties), `pixijs-events` (hitArea usage), `pixijs-scene-core-concepts` (culling with Rectangle). ## Core Patterns ### Point and ObservablePoint Point is a simple {x, y} value type. ObservablePoint fires a callback when x or y changes; it is used internally by Container's position, scale, pivot, origin, and skew. ```ts import { Point } from "pixi.js"; const p = new Point(10, 20); p.set(30, 40); // set both p.set(50); // x=50, y=50 const clone = p.clone(); console.log(p.equals(clone)); // true p.copyFrom({ x: 1, y: 2 }); // accepts any PointData // Point.shared: temporary point, reset to (0,0) on each access const temp = Point.shared; temp.set(100, 200); // do not store a reference to Point.shared ``` Container properties like `position`, `scale`, `pivot`, `origin`, and `skew` are ObservablePoints. Setting `.x` or `.y` on them triggers transform recalculation automatically. ```ts import { Container } from "pixi.js"; const obj = new Container(); obj.position.set(100, 200); // triggers observer -> marks transform dirty obj.position.x = 150; // also triggers observer ``` ### Matrix (2D affine transform) Matrix represents a 3x3 affine transform: `| a c tx | b d ty | 0 0 1 |`. It supports translate, scale, rotate, append, prepend, invert, and decompose. ```ts import { Matrix, Point } from "pixi.js"; // Build a transform const m = new Matrix() .translate(100, 50) .rotate(Math.PI / 4) .scale(2, 2); // Transform a point (local -> parent space) const local = new Point(10, 20); const world = m.apply(local); // Inverse transform (parent -> local space) const backToLocal = m.applyInverse(world); // Combine matrices const a = new Matrix().translate(50, 0); const b = new Matrix().rotate(Math.PI / 2); a.append(b); // a = a * b // Decompose into position/scale/rotation/skew const transform = { position: new Point(), scale: new Point(), pivot: new Point(), skew: new Point(), rotation: 0, }; m.decompose(transform); console.log(transform.rotation); // ~0.785 (PI/4) // Shared temporary matrix (reset on each access) const temp = Matrix.shared; // IDENTITY is read-only reference const isDefault = m.equals(Matrix.IDENTITY); ``` ### Coordinate transforms via Container Containers provide `toGlobal`, `toLocal`, and `getGlobalPosition` fo