大网数据广告活动
Web 标准与前端开发

Geometry interfaces

· 52CE 我爱测

Geometry interfaces** is a CSS module that provides interfaces for working with 3D and 2D graphics — in particular, for working with points, rectangles, quadrilaterals and transformation matrices (for operations that translate/move, scale, rotate, skew/shear/slant, and flip graph

Geometry Interfaces

Geometry interfaces is a CSS module that provides interfaces for working with 3D and 2D graphics — in particular, for working with points, rectangles, quadrilaterals and transformation matrices (for operations that translate/move, scale, rotate, skew/shear/slant, and flip graphics, as well as for multiplying/chaining and inverting/undoing those operations).

As a web developer, you don't always use the geometry interfaces directly, but instead use other features that rely on them behind the scenes: parts of CSS Transforms, the Canvas API, the WebXR Device API, and (more directly) VideoFrame.visibleRect, Element.getClientRects(), and Element.getBoundingClientRect().

[!NOTE] The geometry interfaces are intended for other web APIs like the ones listed above, rather than as a general-purpose linear algebra library. The transformation methods, such as DOMMatrixReadOnly.transformPoint(), are provided for convenience and may be significantly slower than equivalent hand-written JavaScript due to internal overhead. For computation-intensive code, profile different approaches and consider using plain JavaScript objects or arrays for intermediate calculations.

Interfaces

  • DOMMatrix
    • : Represents a transformation matrix, for operations that translate/move, scale, rotate, skew/shear/slant, and flip graphics, as well as for multiplying/chaining and inverting/undoing those operations.
  • DOMMatrixReadOnly
    • : Read-only version of DOMMatrix.
  • DOMPoint
    • : Represents a 2D or 3D point in a coordinate system; it includes values for the coordinates in up to three dimensions, as well as an optional perspective value.
  • DOMPointReadOnly
    • : Read-only version of DOMPoint.
  • DOMQuad
    • : Represents a collection of four DOMPoint objects defining the corners of a quadrilateral.
  • DOMRect
    • : Represents the size and position of a rectangle.
  • DOMRectReadOnly
    • : Read-only version of DOMRect.

Examples

The Path2D.addPath() and CanvasPattern.setTransform() articles have examples that use some of the geometry interfaces.

Specifications

Browser compatibility

See also

  • Path2D.addPath()
  • CanvasPattern.setTransform()
  • CanvasRenderingContext2D.getTransform()
  • CanvasRenderingContext2D.setTransform()
  • CSSTransformValue.toMatrix()
  • CSSTransformComponent.toMatrix()
  • Element.getBoundingClientRect()
  • Element.getClientRects()
  • VideoFrame.visibleRect
  • XRLightEstimate
  • XRRigidTransform

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。