29 lines
989 B
Plaintext
29 lines
989 B
Plaintext
// The scene has world positions; each finite viewport has its own camera.
|
|
count = ui.state(0)
|
|
increment = Button("共享计数 +1")
|
|
increment.onClick(count.increment)
|
|
card = Column(20, 12, TextBlock("世界里的 UI", 2), ui.textOf(count, "value", 3), increment)
|
|
card.boxWidth = 220
|
|
card.x = -60
|
|
card.y = 40
|
|
card.borderLeft = 2
|
|
card.borderColor = "#8CA5B8"
|
|
|
|
inner = CanvasViewport(200, 100, Scene2D(RectBlock(120, 60, 8, "#D4E6D9")))
|
|
inner.x = 260
|
|
inner.y = 40
|
|
world = Scene2D(card, inner)
|
|
left = CanvasViewport(460, 320, world)
|
|
left.camera.x = -100
|
|
right = CanvasViewport(320, 320, world)
|
|
right.camera.x = -80
|
|
right.camera.zoom = 0.65
|
|
// Set right.camera = left.camera to share a view explicitly.
|
|
|
|
views = Row(0, 20, left, right)
|
|
hud = Column(16, 8, TextBlock("一个世界,多个视角", 2), TextBlock("滚轮平移 · 空格/中键拖动 · 捏合或 Cmd/Ctrl+滚轮缩放"))
|
|
hud.alignSelf = "end"
|
|
page = Page()
|
|
page.title = "场景与视口"
|
|
page.render(Overlay(12, 0, views, hud))
|