From a14c3c58ac8968596fe4ddeed5e863aba9d905f9 Mon Sep 17 00:00:00 2001 From: yelikang <530331059@qq.com> Date: Wed, 21 Aug 2024 16:43:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20coord=20=E5=9D=90=E6=A0=87=E8=BD=AC?= =?UTF-8?q?=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/x6/src/graph/graph.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/x6/src/graph/graph.ts b/packages/x6/src/graph/graph.ts index 1f2b45161b..fe558303e4 100644 --- a/packages/x6/src/graph/graph.ts +++ b/packages/x6/src/graph/graph.ts @@ -52,7 +52,7 @@ export class Graph extends Basecoat { this.css = new Css(this) this.view = new GraphView(this) this.defs = new Defs(this) - // 坐标?(用于捕捉交互的元素?) + // 坐标(用于画布与客户端/浏览器的坐标转换) this.coord = new Coord(this) this.transform = new Transform(this) this.highlight = new Highlight(this) @@ -889,7 +889,10 @@ export class Graph extends Basecoat { return this.coord.localToPagePoint(x, y) } - + /** + * 画布坐标转换为客户端坐标(浏览器坐标) + * @param rect + */ clientToLocal(rect: Rectangle.RectangleLike): Rectangle clientToLocal(x: number, y: number, width: number, height: number): Rectangle clientToLocal(p: Point.PointLike): Point @@ -915,7 +918,10 @@ export class Graph extends Basecoat { return this.coord.clientToLocalPoint(x, y) } - + /** + * 浏览器坐标转换为画布端坐标 + * @param rect + */ localToClient(rect: Rectangle.RectangleLike): Rectangle localToClient(x: number, y: number, width: number, height: number): Rectangle localToClient(p: Point.PointLike): Point