画板视图(ArtboardView)
脚本对象所在的画板,来自 context:artboard()。脚本并不拥有它,因此可以遍历并移动其中的节点,但不能绘制、推进或实例化它。对象消失后,它读起来是空的,其中的节点则是单位变换。
字段(Fields)
width
画板的宽度。
local artboard = context:artboard()
if artboard then
print(artboard.width)
end
height
画板的高度。
local artboard = context:artboard()
if artboard then
print(artboard.height)
end
children
画板的顶层节点。
local artboard = context:artboard()
if artboard then
for _, child in artboard.children do print(child.name) end
end
方法(Methods)
bounds
bounds() -> (Vector, Vector)
画板包围盒的最小点和最大点。
local artboard = context:artboard()
if artboard then
local min, max = artboard:bounds()
print(max.x - min.x, max.y - min.y)
end
node
node(name: string) -> NodeData?
具有该导出名称的节点;没有时为 nil。
local artboard = context:artboard()
local hand = if artboard then artboard:node('Hand') else nil
if hand then
hand.rotation = math.pi / 4
end