Pixso 开放文档
插件 API
官方工具集
  • 中文
  • English
插件 API
官方工具集
  • 中文
  • English
  • 插件 API

    • 简介
    • 预备知识
    • manifest
    • 开发指南
    • 更新日志
    • Plugin API 文档

      • 概述
      • 全局对象

        • pixso
        • pixso.ui
        • pixso.host
        • pixso.mouse
        • pixso.editor
        • pixso.keyboard
        • pixso.fieldset
        • pixso.viewport
        • pixso.vectorEditor
        • pixso.stickyToolbar
        • pixso.clientStorage
        • pixso.serverStorage
      • 节点类型

        • BooleanOperationNode
        • ComponentNode
        • ComponentSetNode
        • DocumentNode
        • EllipseNode
        • FrameNode
        • GroupNode
        • InstanceNode
        • LineNode
        • PageNode
        • PolygonNode
        • RectangleNode
        • SectionNode
        • SliceNode
        • StarNode
        • TextNode
        • VectorNode
      • 样式类型

        • PaintStyle
        • TextStyle
        • EffectStyle
        • GridStyle
      • 数据类型

        • Action
        • ArcData
        • BlendMode
        • CommandItem
        • ComponentProperties-Related
        • Constraints
        • DialogType
        • DocumentationLink
        • Effect
        • EmbedData
        • ExportSettings
        • FontName
        • Guide
        • HandleMirroring
        • HyperlinkTarget
        • Image
        • LayoutGrid
        • LetterSpacing
        • Library
        • LineHeight
        • NodeChangeProperty
        • OverflowDirection
        • Overlay
        • Paint
        • PublishStatus
        • Reaction
        • Rect-related
        • RGB & RGBA
        • StickyToolbar
        • StrokeCap
        • StrokeJoin
        • StyleChangeProperty
        • TextCase
        • TextDecoration
        • TextListOptions
        • ThemeType
        • ToolType
        • Transition
        • Trigger
        • Vector
    • Host API 文档

      • 概述
      • Host API
  • 服务端 API

    • OpenAPI 文档
    • OpenAPI 文档
    • 事件订阅
    • 事件订阅
  • 客户端 API

    • 简介
    • 唤醒客户端
    • Web API
    • 更新日志

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 等用户操作将更改视口的边界。

Prev
pixso.fieldset
Next
pixso.vectorEditor