Token导航 LogoToken导航

Agent Skill · 待分类

geometry-and-math(几何和数学)

geometry-and-math 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

geometry-and-math 是待分类类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为权限未标注;许可证信息还不明确,第三方扫描已通过,按安装量在待分类类的 11,209 个 Skill 里排第 3,442。

总安装 1,011周安装 43GitHub Stars 39,530下载 354核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:geometry-and-math(几何和数学)
来源仓库:https://github.com/phaserjs/phaser
仓库路径:skills/geometry-and-math
安装命令:
npx skills add https://github.com/phaserjs/phaser --skill geometry-and-math
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/phaserjs/phaser --skill geometry-and-math

这个 Skill 是做什么的

这个 Skill 的分类还没最终确定,用法以来源仓库的说明为准。

geometry-and-math 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息。适合在 Codex、Claude、Cursor、Gemini CLI 中围绕仓库状态、代码变更或协作事项进行整理。可结合来源仓库和原始 README 核验具体用法,通过 npx 命令安装。

安装前建议确认权限范围、维护状态及是否会触发联网或文件操作。适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

来源仓库内路径:skills/geometry-and-math

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/phaserjs/phaser --skill geometry-and-math;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    权限没有明确标注,第一次使用时只给一个无关紧要的任务,观察它到底读了哪些文件和网络。

常见问题

6 条

geometry-and-math 怎么安装?

在终端执行 npx skills add https://github.com/phaserjs/phaser --skill geometry-and-math。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

geometry-and-math 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

geometry-and-math 需要什么权限?

权限级别没有明确标注。第一次使用时建议只给无关紧要的任务,观察它实际读写了哪些内容。

geometry-and-math 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

geometry-and-math 用的人多吗?

公开数据是累计安装 1,011 次,近一周安装 43 次,下载 354 次,GitHub 39,530 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

geometry-and-math 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。
  • 来源仓库有 39,530 星,维护活跃度相对可查。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理待分类类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

待分类类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
infsh-cli

infsh CLI · Codex、Claude

4,374,576382权限未标注未明确未收录
ai-video-generation

AI 视频生成 · Codex、Claude

4,313,376382调用外部服务未明确有提醒
lark-openapi-explorer

云雀 OpenAPI 浏览器 · Codex、Claude

2,064,1209,011需要联网未明确有提醒
lark-workflow-standup-report

Lark 工作流程站立报告 · Codex、Claude

2,041,6328,978需要联网未明确通过
use-my-browser

使用我的浏览器 · Codex、Claude

1,848,49140操作浏览器未明确未通过
geometry-and-math

几何和数学 · 本页

1,01139,530权限未标注未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Phaser 4 — Geometry and Math

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


Quick Start

// 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

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).


Geometry Classes

ClassNamespaceConstructorKey Properties
CirclePhaser.Geom.Circle(x, y, radius)x, y, radius, diameter, left, right, top, bottom
EllipsePhaser.Geom.Ellipse(x, y, width, height)x, y, width, height, left, right, top, bottom
LinePhaser.Geom.Line(x1, y1, x2, y2)x1, y1, x2, y2, left, right, top, bottom
PolygonPhaser.Geom.Polygon(points)area, points (array of Vector2Like)
RectanglePhaser.Geom.Rectangle(x, y, width, height)x, y, width, height, left, right, top, bottom, centerX, centerY
TrianglePhaser.Geom.Triangle(x1, y1, x2, y2, x3, y3)x1, y1, x2, y2, x3, y3

Rectangle Static Helpers

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

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

Line Static Helpers

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

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

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

Intersection Tests

All under Phaser.Geom.Intersects.

Boolean Tests (return 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

Get Intersection Points (return 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

Math Functions by Category

All under Phaser.Math unless noted.

Constants

ConstantValue
Phaser.Math.TAUPI * 2 (v4 addition)
Phaser.Math.PI_OVER_2PI / 2
Phaser.Math.EPSILON1.0e-6
Phaser.Math.DEG_TO_RADPI / 180
Phaser.Math.RAD_TO_DEG180 / PI
Phaser.Math.RNDGlobal RandomDataGenerator instance (seeded via game config seed)

Angle Functions (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]

Distance Functions (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

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

Snap Functions (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

Fuzzy Comparison (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

Easing Functions (Phaser.Math.Easing.*)

Each type has .In, .Out, .InOut variants. Used primarily by tweens (pass string names like 'Sine.easeOut').

TypeString Keys
BackBack.easeIn, Back.easeOut, Back.easeInOut
BounceBounce.easeIn, Bounce.easeOut, Bounce.easeInOut
CircularCirc.easeIn, Circ.easeOut, Circ.easeInOut
CubicCubic.easeIn, Cubic.easeOut, Cubic.easeInOut
ElasticElastic.easeIn, Elastic.easeOut, Elastic.easeInOut
ExpoExpo.easeIn, Expo.easeOut, Expo.easeInOut
LinearLinear (no variants)
QuadraticQuad.easeIn, Quad.easeOut, Quad.easeInOut
QuarticQuart.easeIn, Quart.easeOut, Quart.easeInOut
QuinticQuint.easeIn, Quint.easeOut, Quint.easeInOut
SineSine.easeIn, Sine.easeOut, Sine.easeInOut
SteppedStepped (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.

Core Math Helpers (directly on 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

Power-of-Two (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

Vector2 Quick Reference

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.


Vector3 Quick Reference

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).


Matrix4 Quick Reference

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.


RandomDataGenerator

Phaser.Math.RandomDataGenerator -- seeded PRNG. Global instance at Phaser.Math.RND (seeded via game config seed property).

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']).


Color Utilities

Color Class (Phaser.Display.Color)

A mutable RGBA color representation with automatic conversion to WebGL floats, HSV, CSS strings, and packed integers.

// 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)

Color Manipulation

// 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)

Color Interpolation (Phaser.Display.Color.Interpolate)

Interpolate between colors over a given length. Returns {r, g, b, a, color}.

// 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);

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).

Source File Map

AreaPath
Geom classessrc/geom/{circle,ellipse,line,polygon,rectangle,triangle}/
Geom constantssrc/geom/const.js
Intersection testssrc/geom/intersects/
Vector2src/math/Vector2.js
Vector3src/math/Vector3.js
Vector4src/math/Vector4.js
Matrix3src/math/Matrix3.js
Matrix4src/math/Matrix4.js
Quaternionsrc/math/Quaternion.js
Eulersrc/math/Euler.js
Angle functionssrc/math/angle/
Distance functionssrc/math/distance/
Easing functionssrc/math/easing/ (+ EaseMap.js for string keys)
Fuzzy comparisonsrc/math/fuzzy/
Interpolationsrc/math/interpolation/
Snap functionssrc/math/snap/
Power-of-twosrc/math/pow2/
RandomDataGeneratorsrc/math/random-data-generator/RandomDataGenerator.js
Math constantssrc/math/const.js
Color classsrc/display/color/Color.js
Color utilitiessrc/display/color/ (ValueToColor, HexStringToColor, RGBStringToColor, HSVToRGB, Interpolate)
Core math helperssrc/math/ (Clamp.js, Between.js, Wrap.js, Linear.js, etc.)

平台分布

Codex

37.83%
按下载量换算134

Claude

29.87%
按下载量换算106

Cursor

18.28%
按下载量换算65

Gemini CLI

10.32%
按下载量换算37

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

权限未标注

当前来源未能明确判断权限范围,默认进入异常复核队列。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills