Skip to content

Commit

Permalink
feat: coord 坐标转换
Browse files Browse the repository at this point in the history
  • Loading branch information
yelikang committed Aug 21, 2024
1 parent dc6ca1a commit a14c3c5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/x6/src/graph/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class Graph extends Basecoat<EventArgs> {
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)
Expand Down Expand Up @@ -889,7 +889,10 @@ export class Graph extends Basecoat<EventArgs> {

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
Expand All @@ -915,7 +918,10 @@ export class Graph extends Basecoat<EventArgs> {

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
Expand Down

0 comments on commit a14c3c5

Please sign in to comment.