geometry-and-math

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Phaser 4 — Geometry and Math

Phaser 4 — 几何与数学工具

Geom classes (Circle, Ellipse, Line, Polygon, Rectangle, Triangle), intersection tests, and Math utilities (Vector2, Vector3, Matrix4, angles, distances, interpolation, easing, random, snap, clamp).
Related skills: graphics-and-shapes.md, physics-arcade.md

几何类(Circle、Ellipse、Line、Polygon、Rectangle、Triangle)、相交检测,以及数学工具(Vector2、Vector3、Matrix4、角度计算、距离计算、插值、缓动、随机数、对齐、取值限制)。
相关技能:graphics-and-shapes.md、physics-arcade.md

Quick Start

快速入门

js
// Create geometry objects (these are data only, not renderable)
const rect = new Phaser.Geom.Rectangle(10, 20, 200, 100);
const circle = new Phaser.Geom.Circle(400, 300, 50);
const line = new Phaser.Geom.Line(0, 0, 100, 100);

// Point containment
rect.contains(50, 50);    // true
circle.contains(410, 310); // true

// Intersection test
Phaser.Geom.Intersects.CircleToRectangle(circle, rect); // boolean

// Math utilities
const v = new Phaser.Math.Vector2(3, 4);
v.length();      // 5
v.normalize();   // {x: 0.6, y: 0.8}

const dist = Phaser.Math.Distance.Between(0, 0, 100, 100);
const angle = Phaser.Math.Angle.Between(0, 0, 100, 100);
const clamped = Phaser.Math.Clamp(150, 0, 100); // 100

js
// 创建几何对象(仅存储数据,不可渲染)
const rect = new Phaser.Geom.Rectangle(10, 20, 200, 100);
const circle = new Phaser.Geom.Circle(400, 300, 50);
const line = new Phaser.Geom.Line(0, 0, 100, 100);

// 点包含检测
rect.contains(50, 50);    // 返回true
circle.contains(410, 310); // 返回true

// 相交检测
Phaser.Geom.Intersects.CircleToRectangle(circle, rect); // 返回布尔值

// 数学工具使用
const v = new Phaser.Math.Vector2(3, 4);
v.length();      // 返回5
v.normalize();   // 返回{x: 0.6, y: 0.8}

const dist = Phaser.Math.Distance.Between(0, 0, 100, 100);
const angle = Phaser.Math.Angle.Between(0, 0, 100, 100);
const clamped = Phaser.Math.Clamp(150, 0, 100); // 返回100

Core Concepts

核心概念

Geometry objects are pure data containers holding coordinates and dimensions. They are NOT game objects and cannot be added to the display list. To render geometry, use the Graphics game object or Shape game objects (see graphics-and-shapes.md).
Every geom class has a
type
property set to a
Phaser.Geom
constant for fast type checks.
All geom classes share a common instance method pattern:
  • contains(x, y)
    -- point-in-shape test
  • getPoint(position, output?)
    -- point at normalized position (0-1) on perimeter
  • getPoints(quantity, stepRate?, output?)
    -- evenly spaced points on perimeter
  • getRandomPoint(output?)
    -- random point inside the shape
  • setTo(...)
    -- reset all properties
  • setEmpty()
    -- zero out the shape
  • setPosition(x, y)
    -- move origin/center
Each geom type also has a folder of static helper functions (e.g.,
Phaser.Geom.Rectangle.Contains
,
Phaser.Geom.Circle.Area
).

几何对象是纯数据容器,仅存储坐标和尺寸信息。它们不是游戏对象,无法添加到显示列表中。若要渲染几何图形,请使用Graphics游戏对象或Shape游戏对象(详见graphics-and-shapes.md)。
每个几何类都有一个
type
属性,值为
Phaser.Geom
常量,用于快速类型检查。
所有几何类共享一套通用的实例方法:
  • contains(x, y)
    -- 点是否在图形内部的检测
  • getPoint(position, output?)
    -- 获取图形周长上归一化位置(0-1)对应的点
  • getPoints(quantity, stepRate?, output?)
    -- 获取周长上均匀分布的点
  • getRandomPoint(output?)
    -- 获取图形内部的随机点
  • setTo(...)
    -- 重置所有属性
  • setEmpty()
    -- 将图形置为空(尺寸归零)
  • setPosition(x, y)
    -- 移动图形的原点/中心点
每个几何类型还拥有一个静态辅助函数文件夹(例如
Phaser.Geom.Rectangle.Contains
Phaser.Geom.Circle.Area
)。

Geometry Classes

几何类

ClassNamespaceConstructorKey Properties
Circle
Phaser.Geom.Circle
(x, y, radius)
x
,
y
,
radius
,
diameter
,
left
,
right
,
top
,
bottom
Ellipse
Phaser.Geom.Ellipse
(x, y, width, height)
x
,
y
,
width
,
height
,
left
,
right
,
top
,
bottom
Line
Phaser.Geom.Line
(x1, y1, x2, y2)
x1
,
y1
,
x2
,
y2
,
left
,
right
,
top
,
bottom
Polygon
Phaser.Geom.Polygon
(points)
area
,
points
(array of Vector2Like)
Rectangle
Phaser.Geom.Rectangle
(x, y, width, height)
x
,
y
,
width
,
height
,
left
,
right
,
top
,
bottom
,
centerX
,
centerY
Triangle
Phaser.Geom.Triangle
(x1, y1, x2, y2, x3, y3)
x1
,
y1
,
x2
,
y2
,
x3
,
y3
类名命名空间构造函数核心属性
Circle
Phaser.Geom.Circle
(x, y, radius)
x
,
y
,
radius
,
diameter
,
left
,
right
,
top
,
bottom
Ellipse
Phaser.Geom.Ellipse
(x, y, width, height)
x
,
y
,
width
,
height
,
left
,
right
,
top
,
bottom
Line
Phaser.Geom.Line
(x1, y1, x2, y2)
x1
,
y1
,
x2
,
y2
,
left
,
right
,
top
,
bottom
Polygon
Phaser.Geom.Polygon
(points)
area
,
points
(Vector2Like数组)
Rectangle
Phaser.Geom.Rectangle
(x, y, width, height)
x
,
y
,
width
,
height
,
left
,
right
,
top
,
bottom
,
centerX
,
centerY
Triangle
Phaser.Geom.Triangle
(x1, y1, x2, y2, x3, y3)
x1
,
y1
,
x2
,
y2
,
x3
,
y3

Rectangle Static Helpers

Rectangle静态辅助函数

Phaser.Geom.Rectangle.*
: Area, Ceil, CeilAll, CenterOn, Clone, Contains, ContainsPoint, ContainsRect, CopyFrom, Decompose, Equals, FitInside, FitOutside, Floor, FloorAll, FromPoints, FromXY, GetAspectRatio, GetCenter, GetPoint, GetPoints, GetSize, Inflate, Intersection, MarchingAnts, MergePoints, MergeRect, MergeXY, Offset, OffsetPoint, Overlaps, Perimeter, PerimeterPoint, Random, RandomOutside, SameDimensions, Scale, Union.
Phaser.Geom.Rectangle.*
: Area、Ceil、CeilAll、CenterOn、Clone、Contains、ContainsPoint、ContainsRect、CopyFrom、Decompose、Equals、FitInside、FitOutside、Floor、FloorAll、FromPoints、FromXY、GetAspectRatio、GetCenter、GetPoint、GetPoints、GetSize、Inflate、Intersection、MarchingAnts、MergePoints、MergeRect、MergeXY、Offset、OffsetPoint、Overlaps、Perimeter、PerimeterPoint、Random、RandomOutside、SameDimensions、Scale、Union。

Circle Static Helpers

Circle静态辅助函数

Phaser.Geom.Circle.*
: Area, Circumference, CircumferencePoint, Clone, Contains, ContainsPoint, ContainsRect, CopyFrom, Equals, GetBounds, GetPoint, GetPoints, Offset, OffsetPoint, Random.
Phaser.Geom.Circle.*
: Area、Circumference、CircumferencePoint、Clone、Contains、ContainsPoint、ContainsRect、CopyFrom、Equals、GetBounds、GetPoint、GetPoints、Offset、OffsetPoint、Random。

Line Static Helpers

Line静态辅助函数

Phaser.Geom.Line.*
: Angle, BresenhamPoints, CenterOn, Clone, CopyFrom, Equals, Extend, GetEasedPoints, GetMidPoint, GetNearestPoint, GetNormal, GetPoint, GetPoints, GetShortestDistance, Height, Length, NormalAngle, NormalX, NormalY, Offset, PerpSlope, Random, ReflectAngle, Rotate, RotateAroundPoint, RotateAroundXY, SetToAngle, Slope, Width.
Phaser.Geom.Line.*
: Angle、BresenhamPoints、CenterOn、Clone、CopyFrom、Equals、Extend、GetEasedPoints、GetMidPoint、GetNearestPoint、GetNormal、GetPoint、GetPoints、GetShortestDistance、Height、Length、NormalAngle、NormalX、NormalY、Offset、PerpSlope、Random、ReflectAngle、Rotate、RotateAroundPoint、RotateAroundXY、SetToAngle、Slope、Width。

Triangle Static Helpers

Triangle静态辅助函数

Phaser.Geom.Triangle.*
: Area, BuildEquilateral, BuildFromPolygon, BuildRight, CenterOn, Centroid, CircumCenter, CircumCircle, Clone, Contains, ContainsArray, ContainsPoint, CopyFrom, Decompose, Equals, GetPoint, GetPoints, InCenter, Offset, Perimeter, Random, Rotate, RotateAroundPoint, RotateAroundXY.
Phaser.Geom.Triangle.*
: Area、BuildEquilateral、BuildFromPolygon、BuildRight、CenterOn、Centroid、CircumCenter、CircumCircle、Clone、Contains、ContainsArray、ContainsPoint、CopyFrom、Decompose、Equals、GetPoint、GetPoints、InCenter、Offset、Perimeter、Random、Rotate、RotateAroundPoint、RotateAroundXY。

Polygon Input Formats

Polygon输入格式

The Polygon constructor accepts multiple formats for the
points
argument:
  • Space-separated string:
    '40 0 40 20 100 20 100 80'
  • Array of
    {x, y}
    objects
  • Flat number array:
    [x1, y1, x2, y2, ...]
  • Array of
    [x, y]
    sub-arrays

Polygon构造函数的
points
参数支持多种格式:
  • 空格分隔字符串:
    '40 0 40 20 100 20 100 80'
  • {x, y}
    对象数组
  • 扁平化数字数组:
    [x1, y1, x2, y2, ...]
  • [x, y]
    子数组组成的数组

Intersection Tests

相交检测

All under
Phaser.Geom.Intersects
.
所有相交检测函数都在
Phaser.Geom.Intersects
命名空间下。

Boolean Tests (return
true
/
false
)

布尔值检测(返回
true
/
false

FunctionDescription
CircleToCircle(circleA, circleB)
Two circles overlap
CircleToRectangle(circle, rect)
Circle overlaps rectangle
LineToCircle(line, circle)
Line segment intersects circle
LineToLine(line1, line2, out?)
Two line segments cross; writes point to
out
LineToRectangle(line, rect)
Line segment intersects rectangle
PointToLine(point, line, lineThickness?)
Point lies on/near line
PointToLineSegment(point, line)
Point lies on finite line segment
RectangleToRectangle(rectA, rectB)
Two rectangles overlap
RectangleToTriangle(rect, triangle)
Rectangle overlaps triangle
RectangleToValues(rect, left, right, top, bottom, tolerance?)
Rectangle overlaps LRTB bounds
TriangleToCircle(triangle, circle)
Triangle overlaps circle
TriangleToLine(triangle, line)
Triangle intersects line
TriangleToTriangle(triA, triB)
Two triangles overlap
函数描述
CircleToCircle(circleA, circleB)
两个圆形是否重叠
CircleToRectangle(circle, rect)
圆形与矩形是否重叠
LineToCircle(line, circle)
线段与圆形是否相交
LineToLine(line1, line2, out?)
两条线段是否交叉;将交点写入
out
参数
LineToRectangle(line, rect)
线段与矩形是否相交
PointToLine(point, line, lineThickness?)
点是否在直线上/附近
PointToLineSegment(point, line)
点是否在有限线段上
RectangleToRectangle(rectA, rectB)
两个矩形是否重叠
RectangleToTriangle(rect, triangle)
矩形与三角形是否重叠
RectangleToValues(rect, left, right, top, bottom, tolerance?)
矩形是否与LRTB边界重叠
TriangleToCircle(triangle, circle)
三角形与圆形是否重叠
TriangleToLine(triangle, line)
三角形与直线是否相交
TriangleToTriangle(triA, triB)
两个三角形是否重叠

Get Intersection Points (return
Vector2[]
)

获取交点(返回
Vector2[]

FunctionDescription
GetCircleToCircle(circleA, circleB, out?)
Intersection points of two circles
GetCircleToRectangle(circle, rect, out?)
Points where circle meets rectangle edges
GetLineToCircle(line, circle, out?)
Points where line crosses circle
GetLineToLine(line1, line2, out?)
Single intersection point of two lines
GetLineToPoints(line, points, out?)
Intersection with a series of points forming edges
GetLineToPolygon(line, polygon, out?)
Closest intersection with polygon edges
GetLineToRectangle(line, rect, out?)
Points where line crosses rectangle
GetRaysFromPointToPolygon(x, y, polygon)
Ray-cast from point to polygon edges
GetRectangleIntersection(rectA, rectB, out?)
Overlapping rectangle region
GetRectangleToRectangle(rectA, rectB, out?)
Edge intersection points
GetRectangleToTriangle(rect, triangle, out?)
Edge intersection points
GetTriangleToCircle(triangle, circle, out?)
Edge intersection points
GetTriangleToLine(triangle, line, out?)
Edge intersection points
GetTriangleToTriangle(triA, triB, out?)
Edge intersection points

函数描述
GetCircleToCircle(circleA, circleB, out?)
两个圆形的交点
GetCircleToRectangle(circle, rect, out?)
圆形与矩形边缘的交点
GetLineToCircle(line, circle, out?)
直线与圆形的交点
GetLineToLine(line1, line2, out?)
两条直线的交点
GetLineToPoints(line, points, out?)
直线与一系列点组成的边的交点
GetLineToPolygon(line, polygon, out?)
直线与多边形边缘的最近交点
GetLineToRectangle(line, rect, out?)
直线与矩形的交点
GetRaysFromPointToPolygon(x, y, polygon)
从点到多边形边缘的射线交点
GetRectangleIntersection(rectA, rectB, out?)
两个矩形的重叠区域
GetRectangleToRectangle(rectA, rectB, out?)
两个矩形边缘的交点
GetRectangleToTriangle(rect, triangle, out?)
矩形与三角形边缘的交点
GetTriangleToCircle(triangle, circle, out?)
三角形与圆形边缘的交点
GetTriangleToLine(triangle, line, out?)
三角形与直线的交点
GetTriangleToTriangle(triA, triB, out?)
两个三角形边缘的交点

Math Functions by Category

按类别划分的数学函数

All under
Phaser.Math
unless noted.
除非特别说明,所有函数都在
Phaser.Math
命名空间下。

Constants

常量

ConstantValue
Phaser.Math.TAU
PI * 2 (v4 addition)
Phaser.Math.PI_OVER_2
PI / 2
Phaser.Math.EPSILON
1.0e-6
Phaser.Math.DEG_TO_RAD
PI / 180
Phaser.Math.RAD_TO_DEG
180 / PI
Phaser.Math.RND
Global
RandomDataGenerator
instance (seeded via game config
seed
)
常量
Phaser.Math.TAU
PI * 2(v4新增)
Phaser.Math.PI_OVER_2
PI / 2
Phaser.Math.EPSILON
1.0e-6
Phaser.Math.DEG_TO_RAD
PI / 180
Phaser.Math.RAD_TO_DEG
180 / PI
Phaser.Math.RND
全局
RandomDataGenerator
实例(通过游戏配置
seed
参数设置种子)

Angle Functions (
Phaser.Math.Angle.*
)

角度函数(
Phaser.Math.Angle.*

FunctionDescription
Between(x1, y1, x2, y2)
Angle in radians between two points
BetweenPoints(point1, point2)
Same, taking
{x,y}
objects
BetweenY(x1, y1, x2, y2)
Angle from vertical axis
BetweenPointsY(point1, point2)
Same, taking objects
CounterClockwise(angle)
Convert to counter-clockwise
GetClockwiseDistance(from, to)
Clockwise angular distance
GetCounterClockwiseDistance(from, to)
Counter-clockwise angular distance
GetShortestDistance(from, to)
Shortest angular distance (signed)
Normalize(angle)
Normalize to [0, 2PI)
Random()
Random angle in radians
RandomDegrees()
Random angle in degrees
Reverse(angle)
Reverse (add PI)
RotateTo(currentAngle, targetAngle, lerp?)
Step toward target angle
ShortestBetween(angle1, angle2)
Shortest difference in degrees
Wrap(angle)
Wrap to (-PI, PI]
WrapDegrees(angle)
Wrap to (-180, 180]
函数描述
Between(x1, y1, x2, y2)
两点之间的弧度角度
BetweenPoints(point1, point2)
同上,参数为
{x,y}
对象
BetweenY(x1, y1, x2, y2)
与垂直轴的夹角
BetweenPointsY(point1, point2)
同上,参数为对象
CounterClockwise(angle)
转换为逆时针角度
GetClockwiseDistance(from, to)
顺时针方向的角度距离
GetCounterClockwiseDistance(from, to)
逆时针方向的角度距离
GetShortestDistance(from, to)
最短角度距离(带符号)
Normalize(angle)
将角度归一化到[0, 2PI)范围
Random()
随机弧度角度
RandomDegrees()
随机角度(度数)
Reverse(angle)
反转角度(加PI)
RotateTo(currentAngle, targetAngle, lerp?)
逐步向目标角度旋转
ShortestBetween(angle1, angle2)
角度的最小差值(度数)
Wrap(angle)
将角度包裹到(-PI, PI]范围
WrapDegrees(angle)
将角度包裹到(-180, 180]范围

Distance Functions (
Phaser.Math.Distance.*
)

距离函数(
Phaser.Math.Distance.*

FunctionDescription
Between(x1, y1, x2, y2)
Euclidean distance
BetweenPoints(a, b)
Same, taking
{x,y}
objects
BetweenPointsSquared(a, b)
Squared distance (avoids sqrt)
Chebyshev(x1, y1, x2, y2)
Chebyshev (chessboard) distance
Power(x1, y1, x2, y2, pow)
Minkowski distance with custom power
Snake(x1, y1, x2, y2)
Manhattan/taxicab distance
Squared(x1, y1, x2, y2)
Squared Euclidean distance
函数描述
Between(x1, y1, x2, y2)
欧几里得距离
BetweenPoints(a, b)
同上,参数为
{x,y}
对象
BetweenPointsSquared(a, b)
平方距离(避免开根号运算)
Chebyshev(x1, y1, x2, y2)
切比雪夫(棋盘式)距离
Power(x1, y1, x2, y2, pow)
自定义幂次的闵可夫斯基距离
Snake(x1, y1, x2, y2)
曼哈顿/出租车距离
Squared(x1, y1, x2, y2)
平方欧几里得距离

Interpolation (
Phaser.Math.Interpolation.*
)

插值函数(
Phaser.Math.Interpolation.*

FunctionDescription
BezierInterpolation(v, k)
Bezier curve through control points
CatmullRomInterpolation(v, k)
Catmull-Rom spline through points
CubicBezierInterpolation(t, p0, p1, p2, p3)
Cubic Bezier between four values
LinearInterpolation(v, k)
Linear through array of values
QuadraticBezierInterpolation(t, p0, p1, p2)
Quadratic Bezier
SmoothStepInterpolation(t, min, max)
Hermite smooth step
SmootherStepInterpolation(t, min, max)
Ken Perlin's smoother step
函数描述
BezierInterpolation(v, k)
通过控制点的贝塞尔曲线插值
CatmullRomInterpolation(v, k)
通过点的Catmull-Rom样条插值
CubicBezierInterpolation(t, p0, p1, p2, p3)
四个值之间的三次贝塞尔插值
LinearInterpolation(v, k)
数组值之间的线性插值
QuadraticBezierInterpolation(t, p0, p1, p2)
二次贝塞尔插值
SmoothStepInterpolation(t, min, max)
埃尔米特平滑步进插值
SmootherStepInterpolation(t, min, max)
Ken Perlin的更平滑步进插值

Snap Functions (
Phaser.Math.Snap.*
)

对齐函数(
Phaser.Math.Snap.*

FunctionDescription
To(value, gap, start?, divide?)
Snap to nearest increment
Floor(value, gap, start?, divide?)
Snap down to increment
Ceil(value, gap, start?, divide?)
Snap up to increment
函数描述
To(value, gap, start?, divide?)
将值对齐到最近的增量
Floor(value, gap, start?, divide?)
将值向下对齐到增量
Ceil(value, gap, start?, divide?)
将值向上对齐到增量

Fuzzy Comparison (
Phaser.Math.Fuzzy.*
)

模糊比较(
Phaser.Math.Fuzzy.*

FunctionDescription
Equal(a, b, epsilon?)
a approximately equals b
LessThan(a, b, epsilon?)
a < b within epsilon
GreaterThan(a, b, epsilon?)
a > b within epsilon
Ceil(value, epsilon?)
Fuzzy ceiling
Floor(value, epsilon?)
Fuzzy floor
函数描述
Equal(a, b, epsilon?)
a与b是否近似相等
LessThan(a, b, epsilon?)
a是否在epsilon范围内小于b
GreaterThan(a, b, epsilon?)
a是否在epsilon范围内大于b
Ceil(value, epsilon?)
模糊向上取整
Floor(value, epsilon?)
模糊向下取整

Easing Functions (
Phaser.Math.Easing.*
)

缓动函数(
Phaser.Math.Easing.*

Each type has
.In
,
.Out
,
.InOut
variants. Used primarily by tweens (pass string names like
'Sine.easeOut'
).
TypeString Keys
Back
Back.easeIn
,
Back.easeOut
,
Back.easeInOut
Bounce
Bounce.easeIn
,
Bounce.easeOut
,
Bounce.easeInOut
Circular
Circ.easeIn
,
Circ.easeOut
,
Circ.easeInOut
Cubic
Cubic.easeIn
,
Cubic.easeOut
,
Cubic.easeInOut
Elastic
Elastic.easeIn
,
Elastic.easeOut
,
Elastic.easeInOut
Expo
Expo.easeIn
,
Expo.easeOut
,
Expo.easeInOut
Linear
Linear
(no variants)
Quadratic
Quad.easeIn
,
Quad.easeOut
,
Quad.easeInOut
Quartic
Quart.easeIn
,
Quart.easeOut
,
Quart.easeInOut
Quintic
Quint.easeIn
,
Quint.easeOut
,
Quint.easeInOut
Sine
Sine.easeIn
,
Sine.easeOut
,
Sine.easeInOut
Stepped
Stepped
(no variants)
Power aliases:
Power0
= Linear,
Power1
= Quad.Out,
Power2
= Cubic.Out,
Power3
= Quart.Out,
Power4
= Quint.Out.
Short names also work:
'Quad'
= Quad.Out,
'Sine'
= Sine.Out, etc.
每种类型都有
.In
.Out
.InOut
变体。主要用于补间动画(传入字符串名称,如
'Sine.easeOut'
)。
类型字符串键
Back
Back.easeIn
,
Back.easeOut
,
Back.easeInOut
Bounce
Bounce.easeIn
,
Bounce.easeOut
,
Bounce.easeInOut
Circular
Circ.easeIn
,
Circ.easeOut
,
Circ.easeInOut
Cubic
Cubic.easeIn
,
Cubic.easeOut
,
Cubic.easeInOut
Elastic
Elastic.easeIn
,
Elastic.easeOut
,
Elastic.easeInOut
Expo
Expo.easeIn
,
Expo.easeOut
,
Expo.easeInOut
Linear
Linear
(无变体)
Quadratic
Quad.easeIn
,
Quad.easeOut
,
Quad.easeInOut
Quartic
Quart.easeIn
,
Quart.easeOut
,
Quart.easeInOut
Quintic
Quint.easeIn
,
Quint.easeOut
,
Quint.easeInOut
Sine
Sine.easeIn
,
Sine.easeOut
,
Sine.easeInOut
Stepped
Stepped
(无变体)
幂别名:
Power0
= Linear,
Power1
= Quad.Out,
Power2
= Cubic.Out,
Power3
= Quart.Out,
Power4
= Quint.Out。
短名称同样有效:
'Quad'
= Quad.Out,
'Sine'
= Sine.Out等。

Core Math Helpers (directly on
Phaser.Math
)

核心数学辅助函数(直接在
Phaser.Math
下)

FunctionDescription
Between(min, max)
Random integer in [min, max]
FloatBetween(min, max)
Random float in [min, max]
Clamp(value, min, max)
Constrain value to range
Wrap(value, min, max)
Wrap value within range
Within(a, b, tolerance)
Check if a is within tolerance of b
Percent(value, min, max, upperMax?)
Value as percentage of range
FromPercent(percent, min, max)
Value from percentage of range
DegToRad(degrees)
Convert degrees to radians
RadToDeg(radians)
Convert radians to degrees
Linear(p0, p1, t)
Lerp between two values
LinearXY(v1, v2, t, out?)
Lerp between two Vector2Like objects
SmoothStep(x, min, max)
Hermite smooth step
SmootherStep(x, min, max)
Perlin smoother step
Average(values)
Mean of number array
Median(values)
Median of number array
CeilTo(value, place?, base?)
Ceil to decimal place
FloorTo(value, place?, base?)
Floor to decimal place
RoundTo(value, place?, base?)
Round to decimal place
RoundAwayFromZero(value)
Round away from zero
MaxAdd(value, amount, max)
Add clamped to max
MinSub(value, amount, min)
Subtract clamped to min
Difference(a, b)
Absolute difference
IsEven(value)
Integer is even
IsEvenStrict(value)
Strictly even (not zero)
Factorial(value)
Factorial
Rotate(point, angle)
Rotate point around origin
RotateAround(point, cx, cy, angle)
Rotate point around custom center
RotateAroundDistance(point, cx, cy, angle, dist)
Rotate at fixed distance
TransformXY(x, y, posX, posY, rotation, scaleX, scaleY, output?)
Full 2D transform
GetSpeed(distance, time)
Speed from distance and time
RandomXY(vector, scale?)
Set vector to random unit direction
函数描述
Between(min, max)
[min, max]范围内的随机整数
FloatBetween(min, max)
[min, max]范围内的随机浮点数
Clamp(value, min, max)
将值限制在指定范围内
Wrap(value, min, max)
将值包裹在指定范围内
Within(a, b, tolerance)
检查a是否在b的容差范围内
Percent(value, min, max, upperMax?)
值在范围内的百分比
FromPercent(percent, min, max)
根据百分比获取范围内对应的值
DegToRad(degrees)
将度数转换为弧度
RadToDeg(radians)
将弧度转换为度数
Linear(p0, p1, t)
两个值之间的线性插值
LinearXY(v1, v2, t, out?)
两个Vector2Like对象之间的线性插值
SmoothStep(x, min, max)
埃尔米特平滑步进
SmootherStep(x, min, max)
Perlin更平滑步进
Average(values)
数字数组的平均值
Median(values)
数字数组的中位数
CeilTo(value, place?, base?)
将值向上取整到指定小数位
FloorTo(value, place?, base?)
将值向下取整到指定小数位
RoundTo(value, place?, base?)
将值四舍五入到指定小数位
RoundAwayFromZero(value)
向远离零的方向取整
MaxAdd(value, amount, max)
增加值但不超过最大值
MinSub(value, amount, min)
减少值但不低于最小值
Difference(a, b)
绝对值差
IsEven(value)
整数是否为偶数
IsEvenStrict(value)
是否为严格偶数(非零)
Factorial(value)
阶乘
Rotate(point, angle)
绕原点旋转点
RotateAround(point, cx, cy, angle)
绕自定义中心点旋转点
RotateAroundDistance(point, cx, cy, angle, dist)
保持固定距离旋转点
TransformXY(x, y, posX, posY, rotation, scaleX, scaleY, output?)
完整的2D变换
GetSpeed(distance, time)
根据距离和时间计算速度
RandomXY(vector, scale?)
将向量设置为随机单位方向

Power-of-Two (
Phaser.Math.Pow2.*
)

2的幂相关函数(
Phaser.Math.Pow2.*

FunctionDescription
GetPowerOfTwo(value)
Next power of two >= value
IsValuePowerOfTwo(value)
Check if value is power of two
IsSizePowerOfTwo(width, height)
Check if both dimensions are power of two

函数描述
GetPowerOfTwo(value)
大于等于value的下一个2的幂
IsValuePowerOfTwo(value)
检查value是否为2的幂
IsSizePowerOfTwo(width, height)
检查宽高是否均为2的幂

Vector2 Quick Reference

Vector2速查

Phaser.Math.Vector2
-- 2D vector used throughout Phaser for positions, velocities, directions.
Constructor:
new Vector2(x?, y?)
or
new Vector2({x, y})
. If only
x
given,
y
defaults to
x
.
MethodReturnsDescription
set(x, y)
/
setTo(x, y)
thisSet components
setToPolar(angle, length?)
thisSet from angle + length
copy(src)
/
setFromObject(obj)
thisCopy from Vector2Like
clone()
Vector2New copy
add(src)
/
subtract(src)
thisComponent-wise add/subtract
multiply(src)
/
divide(src)
thisComponent-wise multiply/divide
scale(value)
thisMultiply both components by scalar
negate()
thisFlip sign of both components
normalize()
thisSet length to 1
normalizeRightHand()
thisPerpendicular (right-hand rule)
normalizeLeftHand()
thisPerpendicular (left-hand rule)
limit(max)
thisCap length to max
setLength(length)
thisScale to exact length
length()
numberMagnitude
lengthSq()
numberSquared magnitude (no sqrt)
distance(src)
numberDistance to another vector
distanceSq(src)
numberSquared distance
dot(src)
numberDot product
cross(src)
number2D cross product (scalar)
angle()
numberAngle in radians from positive x-axis
setAngle(angle)
thisRotate to angle, keeping length
rotate(delta)
thisRotate by delta radians
lerp(src, t)
thisLinear interpolate toward src
reflect(normal)
thisReflect off surface normal
mirror(axis)
thisMirror across axis vector
project(src)
thisProject onto another vector
equals(v)
booleanExact equality
fuzzyEquals(v, epsilon?)
booleanApproximate equality
ceil()
/
floor()
/
invert()
thisComponent transforms
reset()
thisSet to (0, 0)
transformMat3(mat)
thisTransform by Matrix3
transformMat4(mat)
thisTransform by Matrix4
Static:
Vector2.ZERO
,
Vector2.RIGHT
,
Vector2.LEFT
,
Vector2.UP
,
Vector2.DOWN
,
Vector2.ONE
.

Phaser.Math.Vector2
—— Phaser中用于表示位置、速度、方向的2D向量。
构造函数:
new Vector2(x?, y?)
new Vector2({x, y})
。若仅传入
x
y
默认等于
x
方法返回值描述
set(x, y)
/
setTo(x, y)
this设置向量分量
setToPolar(angle, length?)
this通过角度+长度设置向量
copy(src)
/
setFromObject(obj)
this从Vector2Like对象复制值
clone()
Vector2创建向量副本
add(src)
/
subtract(src)
this分量级加减
multiply(src)
/
divide(src)
this分量级乘除
scale(value)
this两个分量乘以标量
negate()
this翻转两个分量的符号
normalize()
this将向量长度设置为1
normalizeRightHand()
this生成右手规则的垂直向量
normalizeLeftHand()
this生成左手规则的垂直向量
limit(max)
this将向量长度限制为max
setLength(length)
this将向量缩放到指定长度
length()
number向量的模长
lengthSq()
number向量模长的平方(避免开根号)
distance(src)
number到另一个向量的距离
distanceSq(src)
number到另一个向量的平方距离
dot(src)
number点积
cross(src)
number2D叉积(标量)
angle()
number与x轴正方向的夹角(弧度)
setAngle(angle)
this旋转到指定角度,保持长度不变
rotate(delta)
this旋转delta弧度
lerp(src, t)
this向目标向量线性插值
reflect(normal)
this沿表面法线反射向量
mirror(axis)
this沿轴向量镜像向量
project(src)
this将向量投影到另一个向量上
equals(v)
boolean精确相等判断
fuzzyEquals(v, epsilon?)
boolean近似相等判断
ceil()
/
floor()
/
invert()
this分量级变换
reset()
this将向量设置为(0, 0)
transformMat3(mat)
this通过Matrix3变换向量
transformMat4(mat)
this通过Matrix4变换向量
静态常量:
Vector2.ZERO
,
Vector2.RIGHT
,
Vector2.LEFT
,
Vector2.UP
,
Vector2.DOWN
,
Vector2.ONE

Vector3 Quick Reference

Vector3速查

Phaser.Math.Vector3
-- 3D vector for camera projections, lighting, 3D math.
Constructor:
new Vector3(x?, y?, z?)
or
new Vector3({x, y, z})
.
Key methods (same patterns as Vector2 plus):
up()
,
min(v)
,
max(v)
,
addVectors(a, b)
,
subVectors(a, b)
,
crossVectors(a, b)
,
cross(v)
,
addScalar(s)
,
addScale(v, scale)
,
fromArray(array, offset?)
,
setFromMatrixPosition(mat4)
,
setFromMatrixColumn(mat4, index)
,
applyMatrix3(mat)
,
applyMatrix4(mat)
,
transformCoordinates(mat)
,
transformQuat(q)
,
project(mat)
,
projectViewMatrix(view, proj)
,
unproject(viewport, invProjView)
.

Phaser.Math.Vector3
—— 用于相机投影、光照、3D数学计算的3D向量。
构造函数:
new Vector3(x?, y?, z?)
new Vector3({x, y, z})
核心方法(与Vector2模式相同,新增以下方法):
up()
,
min(v)
,
max(v)
,
addVectors(a, b)
,
subVectors(a, b)
,
crossVectors(a, b)
,
cross(v)
,
addScalar(s)
,
addScale(v, scale)
,
fromArray(array, offset?)
,
setFromMatrixPosition(mat4)
,
setFromMatrixColumn(mat4, index)
,
applyMatrix3(mat)
,
applyMatrix4(mat)
,
transformCoordinates(mat)
,
transformQuat(q)
,
project(mat)
,
projectViewMatrix(view, proj)
,
unproject(viewport, invProjView)

Matrix4 Quick Reference

Matrix4速查

Phaser.Math.Matrix4
-- 4x4 matrix for 3D transforms, projection, and view matrices. Backed by
Float32Array(16)
.
Constructor:
new Matrix4(m?)
-- copies from existing Matrix4, or defaults to identity.
Key methods:
clone()
,
set(src)
,
copy(src)
,
identity()
,
transpose()
,
invert()
,
adjoint()
,
determinant()
,
multiply(src)
,
multiplyLocal(src)
,
translate(v)
,
scale(v)
,
rotate(angle, axis)
,
rotateX(angle)
,
rotateY(angle)
,
rotateZ(angle)
,
fromRotationTranslation(q, v)
,
fromQuat(q)
,
frustum(...)
,
perspective(fovy, aspect, near, far)
,
perspectiveLH(width, height, near, far)
,
ortho(left, right, bottom, top, near, far)
,
lookAt(eye, center, up)
,
lookAtRH(eye, target, up)
,
setWorldMatrix(rotation, position, scale, viewMatrix?, projectionMatrix?)
.
Also:
Phaser.Math.Matrix3
-- 3x3 matrix for 2D transforms and normal matrices.

Phaser.Math.Matrix4
—— 用于3D变换、投影和视图矩阵的4x4矩阵。底层基于
Float32Array(16)
构造函数:
new Matrix4(m?)
—— 从现有Matrix4复制,或默认创建单位矩阵。
核心方法:
clone()
,
set(src)
,
copy(src)
,
identity()
,
transpose()
,
invert()
,
adjoint()
,
determinant()
,
multiply(src)
,
multiplyLocal(src)
,
translate(v)
,
scale(v)
,
rotate(angle, axis)
,
rotateX(angle)
,
rotateY(angle)
,
rotateZ(angle)
,
fromRotationTranslation(q, v)
,
fromQuat(q)
,
frustum(...)
,
perspective(fovy, aspect, near, far)
,
perspectiveLH(width, height, near, far)
,
ortho(left, right, bottom, top, near, far)
,
lookAt(eye, center, up)
,
lookAtRH(eye, target, up)
,
setWorldMatrix(rotation, position, scale, viewMatrix?, projectionMatrix?)
此外还有:
Phaser.Math.Matrix3
—— 用于2D变换和法向量矩阵的3x3矩阵。

RandomDataGenerator

RandomDataGenerator

Phaser.Math.RandomDataGenerator
-- seeded PRNG. Global instance at
Phaser.Math.RND
(seeded via game config
seed
property).
js
const rnd = Phaser.Math.RND; // or new Phaser.Math.RandomDataGenerator(['my-seed'])

rnd.integer();              // random integer in [0, 2^32]
rnd.frac();                 // random float in [0, 1)
rnd.between(1, 10);         // random integer in [1, 10]
rnd.integerInRange(1, 10);  // alias for between
rnd.realInRange(0.5, 1.5);  // random float in [0.5, 1.5]
rnd.normal();               // normal distribution around 0
rnd.angle();                // random angle in radians (-PI to PI)
rnd.rotation();             // random rotation in radians (same range)
rnd.pick(array);            // random element from array
rnd.weightedPick(array);    // weighted toward end of array
rnd.sign();                 // -1 or 1
rnd.uuid();                 // RFC4122 v4 UUID string
rnd.shuffle(array);         // in-place Fisher-Yates shuffle
rnd.state(state?);          // get/set serializable state for save/load
Create reproducible sequences by providing seeds:
new RandomDataGenerator(['level-42'])
.

Phaser.Math.RandomDataGenerator
—— 支持种子的伪随机数生成器。全局实例为
Phaser.Math.RND
(通过游戏配置
seed
属性设置种子)。
js
const rnd = Phaser.Math.RND; // 或 new Phaser.Math.RandomDataGenerator(['my-seed'])

rnd.integer();              // [0, 2^32]范围内的随机整数
rnd.frac();                 // [0, 1)范围内的随机浮点数
rnd.between(1, 10);         // [1, 10]范围内的随机整数
rnd.integerInRange(1, 10);  // between的别名
rnd.realInRange(0.5, 1.5);  // [0.5, 1.5]范围内的随机浮点数
rnd.normal();               // 以0为中心的正态分布随机数
rnd.angle();                // 随机弧度角度(-PI到PI)
rnd.rotation();             // 随机旋转角度(同上述范围)
rnd.pick(array);            // 从数组中随机选取元素
rnd.weightedPick(array);    // 偏向数组末尾的加权随机选取
rnd.sign();                 // 返回-1或1
rnd.uuid();                 // RFC4122 v4格式的UUID字符串
rnd.shuffle(array);         // 原地Fisher-Yates洗牌
rnd.state(state?);          // 获取/设置可序列化状态,用于保存/加载
通过传入种子创建可复现的随机序列:
new RandomDataGenerator(['level-42'])

Color Utilities

颜色工具

Color Class (
Phaser.Display.Color
)

Color类(
Phaser.Display.Color

A mutable RGBA color representation with automatic conversion to WebGL floats, HSV, CSS strings, and packed integers.
js
// Construction
const color = new Phaser.Display.Color(255, 0, 0, 255);     // RGBA (0-255)

// Creation helpers (return Color instances)
const c1 = Phaser.Display.Color.ValueToColor('#ff0000');     // hex string, integer, or object
const c2 = Phaser.Display.Color.HexStringToColor('#ff0000');
const c3 = Phaser.Display.Color.RGBStringToColor('rgb(255,0,0)');
const c4 = Phaser.Display.Color.HSVToRGB(0.5, 1, 1);        // returns { r, g, b, color }

// Properties
color.r; color.g; color.b; color.a;   // 0-255 integers
color.redGL; color.greenGL; color.blueGL; color.alphaGL;  // 0-1 floats (WebGL)
color.color;    // packed 24-bit integer (0xRRGGBB)
color.color32;  // packed 32-bit integer (0xAARRGGBB)
color.rgba;     // CSS string 'rgba(r,g,b,a)'
color.h; color.s; color.v;  // HSV representation (read-only, auto-updated)
可变的RGBA颜色表示,支持自动转换为WebGL浮点数、HSV、CSS字符串和打包整数。
js
// 构造方式
const color = new Phaser.Display.Color(255, 0, 0, 255);     // RGBA(0-255)

// 创建辅助方法(返回Color实例)
const c1 = Phaser.Display.Color.ValueToColor('#ff0000');     // 支持十六进制字符串、整数或对象
const c2 = Phaser.Display.Color.HexStringToColor('#ff0000');
const c3 = Phaser.Display.Color.RGBStringToColor('rgb(255,0,0)');
const c4 = Phaser.Display.Color.HSVToRGB(0.5, 1, 1);        // 返回{ r, g, b, color }

// 属性
color.r; color.g; color.b; color.a;   // 0-255整数
color.redGL; color.greenGL; color.blueGL; color.alphaGL;  // 0-1浮点数(WebGL用)
color.color;    // 24位打包整数(0xRRGGBB)
color.color32;  // 32位打包整数(0xAARRGGBB)
color.rgba;     // CSS格式字符串'rgba(r,g,b,a)'
color.h; color.s; color.v;  // HSV表示(只读,自动更新)

Color Manipulation

颜色操作

js
// Adjustment methods (amount is typically 0-100, returns the Color instance)
color.brighten(25);      // increase brightness
color.saturate(50);      // increase saturation
color.desaturate(30);    // decrease saturation
color.lighten(20);       // increase lightness
color.darken(10);        // decrease lightness

// Utility methods
color.random();          // set to random RGB values (optional min/max range)
color.gray(128);         // set to grayscale shade (0-255)

// Setting values
color.setTo(255, 128, 0, 255);           // RGBA
color.setFromRGB({ r: 255, g: 128, b: 0, a: 255 });
color.setFromHSV(0.1, 0.8, 1.0);        // HSV (0-1 range)
js
// 调整方法(amount通常为0-100,返回Color实例)
color.brighten(25);      // 增加亮度
color.saturate(50);      // 增加饱和度
color.desaturate(30);    // 降低饱和度
color.lighten(20);       // 增加明度
color.darken(10);        // 降低明度

// 工具方法
color.random();          // 设置为随机RGB值(可选指定最小/最大范围)
color.gray(128);         // 设置为指定灰度值(0-255)

// 设置值
color.setTo(255, 128, 0, 255);           // RGBA
color.setFromRGB({ r: 255, g: 128, b: 0, a: 255 });
color.setFromHSV(0.1, 0.8, 1.0);        // HSV(0-1范围)

Color Interpolation (
Phaser.Display.Color.Interpolate
)

颜色插值(
Phaser.Display.Color.Interpolate

Interpolate between colors over a given length. Returns
{ r, g, b, a, color }
.
js
// Between raw RGB values
const result = Phaser.Display.Color.Interpolate.RGBWithRGB(
    255, 0, 0,    // start color (r, g, b)
    0, 0, 255,    // end color (r, g, b)
    100,          // length (number of steps)
    50            // index (current step)
);  // returns midpoint purple { r, g, b, a, color }

// Between two Color objects
const mid = Phaser.Display.Color.Interpolate.ColorWithColor(color1, color2, 100, 50);

// HSV interpolation (v4): smooth hue transition
const hsvResult = Phaser.Display.Color.Interpolate.HSVWithHSV(0, 1, 1, 0.5, 1, 1, 100, 50);

在指定步数内插值两种颜色。返回
{ r, g, b, a, color }
js
// 原始RGB值之间插值
const result = Phaser.Display.Color.Interpolate.RGBWithRGB(
    255, 0, 0,    // 起始颜色(r, g, b)
    0, 0, 255,    // 结束颜色(r, g, b)
    100,          // 总步数
    50            // 当前步骤索引
);  // 返回中点紫色{ r, g, b, a, color }

// 两个Color对象之间插值
const mid = Phaser.Display.Color.Interpolate.ColorWithColor(color1, color2, 100, 50);

// HSV插值(v4新增):平滑的色相过渡
const hsvResult = Phaser.Display.Color.Interpolate.HSVWithHSV(0, 1, 1, 0.5, 1, 1, 100, 50);

Gotchas

注意事项

  1. Geom objects are not game objects. They have no
    scene
    , no
    setPosition
    from the display list, no texture. Use Graphics or Shape game objects to render them.
  2. Point class removed in v4. Use
    Phaser.Math.Vector2
    or plain
    {x, y}
    objects instead. The
    GEOM_CONST.POINT
    (3) exists but the Point class does not.
  3. Angles are in radians throughout the math API. Use
    Phaser.Math.DegToRad()
    and
    RadToDeg()
    for conversion. The
    Phaser.Math.TAU
    constant (2 * PI) is new in v4.
  4. Vector2 methods mutate in place and return
    this
    for chaining. Call
    .clone()
    first if you need to preserve the original:
    const result = v.clone().add(other)
    .
  5. Squared distance is faster than Euclidean distance (avoids
    Math.sqrt
    ). Use
    Distance.Squared
    or
    vec.distanceSq()
    for comparisons where the actual distance value is not needed.
  6. Intersection Get functions allocate arrays.* Pass a reusable
    out
    array to avoid garbage collection pressure in hot loops.
  7. EaseMap short names default to the
    .Out
    variant.
    'Quad'
    means
    Quadratic.Out
    , not
    Quadratic.In
    . Use full string keys like
    'Quad.easeIn'
    for other variants.
  8. RandomDataGenerator state is serializable. Call
    rnd.state()
    to get a string you can store, and
    rnd.state(savedString)
    to restore it for deterministic replay.
  9. Polygon.contains uses ray-casting (even/odd rule). Complex self-intersecting polygons may give unexpected results.
  10. Matrix4.val is a Float32Array. Access elements directly via
    mat.val[index]
    using column-major order (OpenGL convention).

  1. 几何对象不是游戏对象。它们没有
    scene
    属性,没有显示列表的
    setPosition
    方法,也没有纹理。请使用Graphics或Shape游戏对象来渲染它们。
  2. v4中移除了Point类。请使用
    Phaser.Math.Vector2
    或普通
    {x, y}
    对象替代。
    GEOM_CONST.POINT
    (值为3)仍然存在,但Point类已被移除。
  3. 数学API中的角度均为弧度。使用
    Phaser.Math.DegToRad()
    RadToDeg()
    进行转换。
    Phaser.Math.TAU
    常量(2 * PI)是v4新增的。
  4. Vector2方法会原地修改向量并返回
    this
    以支持链式调用。如果需要保留原始向量,请先调用
    .clone()
    const result = v.clone().add(other)
  5. 平方距离比欧几里得距离更快(避免
    Math.sqrt
    运算)。当不需要实际距离值,仅用于比较时,请使用
    Distance.Squared
    vec.distanceSq()
  6. 相交检测的Get*函数会分配数组。在高频循环中,请传入可复用的
    out
    数组以避免垃圾回收压力。
  7. EaseMap短名称默认对应.Out变体
    'Quad'
    表示
    Quadratic.Out
    ,而非
    Quadratic.In
    。如需其他变体,请使用完整字符串键,如
    'Quad.easeIn'
  8. RandomDataGenerator的状态可序列化。调用
    rnd.state()
    获取可存储的字符串,调用
    rnd.state(savedString)
    恢复状态以实现确定性重放。
  9. Polygon.contains使用射线投射法(奇偶规则)。复杂的自相交多边形可能会产生意外结果。
  10. Matrix4.val是Float32Array。使用列主序(OpenGL约定)通过
    mat.val[index]
    直接访问元素。

Source File Map

源文件映射

AreaPath
Geom classes
src/geom/{circle,ellipse,line,polygon,rectangle,triangle}/
Geom constants
src/geom/const.js
Intersection tests
src/geom/intersects/
Vector2
src/math/Vector2.js
Vector3
src/math/Vector3.js
Vector4
src/math/Vector4.js
Matrix3
src/math/Matrix3.js
Matrix4
src/math/Matrix4.js
Quaternion
src/math/Quaternion.js
Euler
src/math/Euler.js
Angle functions
src/math/angle/
Distance functions
src/math/distance/
Easing functions
src/math/easing/
(+
EaseMap.js
for string keys)
Fuzzy comparison
src/math/fuzzy/
Interpolation
src/math/interpolation/
Snap functions
src/math/snap/
Power-of-two
src/math/pow2/
RandomDataGenerator
src/math/random-data-generator/RandomDataGenerator.js
Math constants
src/math/const.js
Color class
src/display/color/Color.js
Color utilities
src/display/color/
(ValueToColor, HexStringToColor, RGBStringToColor, HSVToRGB, Interpolate)
Core math helpers
src/math/
(Clamp.js, Between.js, Wrap.js, Linear.js, etc.)
领域路径
几何类
src/geom/{circle,ellipse,line,polygon,rectangle,triangle}/
几何常量
src/geom/const.js
相交检测
src/geom/intersects/
Vector2
src/math/Vector2.js
Vector3
src/math/Vector3.js
Vector4
src/math/Vector4.js
Matrix3
src/math/Matrix3.js
Matrix4
src/math/Matrix4.js
Quaternion
src/math/Quaternion.js
Euler
src/math/Euler.js
角度函数
src/math/angle/
距离函数
src/math/distance/
缓动函数
src/math/easing/
(+
EaseMap.js
用于字符串键映射)
模糊比较
src/math/fuzzy/
插值函数
src/math/interpolation/
对齐函数
src/math/snap/
2的幂相关
src/math/pow2/
RandomDataGenerator
src/math/random-data-generator/RandomDataGenerator.js
数学常量
src/math/const.js
Color类
src/display/color/Color.js
颜色工具
src/display/color/
(ValueToColor、HexStringToColor、RGBStringToColor、HSVToRGB、Interpolate)
核心数学辅助函数
src/math/
(Clamp.js、Between.js、Wrap.js、Linear.js等)