pixso.viewport
pixso.viewport
对象可以用来读取或设置当前画布的可视区域的信息。
- Type:
interface ViewportAPI {
center: Vector;
zoom: number;
scrollAndZoomIntoView(nodes: ReadonlyArray<BaseNode>): void;
readonly bounds: Rect;
}
center
- Type:
Vector
interface Vector {
readonly x: number;
readonly y: number;
}
读取或设置可视区的中心点。
zoom
- Type:
number
读取或设置画布的缩放比例,值为 1
代表缩放比例为 100%
,值为 0.5
代表缩放比例为 50%
。
scrollAndZoomIntoView
- Type:
scrollAndZoomIntoView(nodes: ReadonlyArray<BaseNode>): void
自动设置视口坐标,使节点在屏幕上可见。它等价于快捷键 Shift-2。
position
- Readonly:
true
- Type:
Vector
获取当前画布的左上角在浏览器坐标系中的位置。
bounds
- Readonly:
true
- Type:
Rect
interface Rect {
readonly x: number;
readonly y: number;
readonly width: number;
readonly height: number;
}
当前在屏幕上可见的页面视口的边界。(x, y)
对应于屏幕的左上角。调整窗口大小或显示/隐藏标尺/UI 等用户操作将更改视口的边界。