Commit 07f8f244 authored by rockyl's avatar rockyl

交互上下文增加坐标内转外功能

增加dynamic类型
parent ac74cb04
......@@ -2,3 +2,4 @@
export type color = string;
export type resource = any;
export type raw = any;
export type dynamic = string;
\ No newline at end of file
......@@ -188,14 +188,21 @@ export function pagePosToCanvasPos(pageX, pageY, identifier?, isLocalPos:boolean
* 画布坐标转页面坐标
* @param x
* @param y
* @param isLocalPos
*/
export function canvasPosToPagePos(x, y){
let doc = document.documentElement;
let box = _canvas.getBoundingClientRect();
export function canvasPosToPagePos(x, y, isLocalPos:boolean = true){
x = x * _scaleX;
y = y * _scaleY;
if(!isLocalPos){
let box = _canvas.getBoundingClientRect();
let doc = document.documentElement;
let left = box.left + window.pageXOffset - doc.clientLeft;
let top = box.top + window.pageYOffset - doc.clientTop;
x += left;
y += top;
}
return {
x, y,
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment