pixijs-math

安装量: 839
排名: #4727

安装

npx skills add https://github.com/pixijs/pixijs-skills --skill 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 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 ) ) ;

返回排行榜