jpfun 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +200 -200
- package/README.md +191 -133
- package/dist/diagnostic.js +5 -2
- package/dist/fraction.d.ts +24 -0
- package/dist/fraction.js +132 -0
- package/dist/functions/ASTtypes.d.ts +24 -7
- package/dist/functions/ASTtypes.js +35 -16
- package/dist/functions/adjust/index.d.ts +2 -0
- package/dist/functions/adjust/index.js +193 -0
- package/dist/functions/bar/index.d.ts +8 -0
- package/dist/functions/bar/index.js +48 -19
- package/dist/functions/beam/auto.js +35 -18
- package/dist/functions/beam/index.js +10 -6
- package/dist/functions/beam/layout.d.ts +3 -2
- package/dist/functions/beam/layout.js +42 -64
- package/dist/functions/box/index.js +35 -34
- package/dist/functions/br/index.js +14 -12
- package/dist/functions/dash/index.js +37 -5
- package/dist/functions/default.js +14 -7
- package/dist/functions/div/index.d.ts +16 -0
- package/dist/functions/div/index.js +51 -23
- package/dist/functions/dot/index.js +16 -8
- package/dist/functions/grace/index.d.ts +8 -18
- package/dist/functions/grace/index.js +98 -99
- package/dist/functions/head/index.d.ts +2 -0
- package/dist/functions/head/index.js +492 -0
- package/dist/functions/key/index.js +98 -5
- package/dist/functions/meter/index.d.ts +2 -0
- package/dist/functions/meter/index.js +154 -0
- package/dist/functions/note/accidentals.d.ts +24 -3
- package/dist/functions/note/accidentals.js +31 -1
- package/dist/functions/note/index.js +60 -80
- package/dist/functions/page/index.d.ts +9 -2
- package/dist/functions/page/index.js +50 -4
- package/dist/functions/set/index.js +42 -34
- package/dist/functions/stack/index.js +39 -34
- package/dist/functions/symbol/index.d.ts +21 -0
- package/dist/functions/symbol/index.js +94 -0
- package/dist/functions/symbol/ornament.d.ts +15 -0
- package/dist/functions/symbol/ornament.js +73 -0
- package/dist/functions/symbol/shape.d.ts +22 -0
- package/dist/functions/symbol/shape.js +48 -0
- package/dist/functions/symbol/symbols/accent.d.ts +2 -0
- package/dist/functions/symbol/symbols/accent.js +24 -0
- package/dist/functions/symbol/symbols/f.d.ts +2 -0
- package/dist/functions/symbol/symbols/f.js +55 -0
- package/dist/functions/symbol/symbols/fermata.d.ts +2 -0
- package/dist/functions/symbol/symbols/fermata.js +24 -0
- package/dist/functions/symbol/symbols/mordent.d.ts +2 -0
- package/dist/functions/symbol/symbols/mordent.js +43 -0
- package/dist/functions/symbol/symbols/p.d.ts +2 -0
- package/dist/functions/symbol/symbols/p.js +61 -0
- package/dist/functions/symbol/symbols/tr.d.ts +2 -0
- package/dist/functions/symbol/symbols/tr.js +75 -0
- package/dist/functions/tempo/glyph.d.ts +12 -0
- package/dist/functions/tempo/glyph.js +30 -0
- package/dist/functions/tempo/index.js +53 -3
- package/dist/functions/text/index.js +78 -26
- package/dist/functions/tie/index.js +103 -128
- package/dist/functions/tuplet/index.d.ts +2 -0
- package/dist/functions/tuplet/index.js +211 -0
- package/dist/functions/{over → up}/index.d.ts +1 -0
- package/dist/functions/up/index.js +370 -0
- package/dist/functions/voice/index.js +125 -108
- package/dist/functions/volta/index.d.ts +2 -0
- package/dist/functions/volta/index.js +227 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/jpfun.min.js +143 -0
- package/dist/layout/engine.d.ts +4 -11
- package/dist/layout/engine.js +100 -66
- package/dist/layout/model.d.ts +8 -1
- package/dist/layout/model.js +16 -6
- package/dist/layout/path.d.ts +19 -0
- package/dist/layout/path.js +101 -0
- package/dist/layout/types.d.ts +51 -18
- package/dist/layout/types.js +3 -1
- package/dist/lowering/loweringContext.d.ts +19 -23
- package/dist/lowering/loweringContext.js +179 -187
- package/dist/lowering/track.d.ts +33 -10
- package/dist/lowering/track.js +6 -6
- package/dist/lowering/types.d.ts +57 -43
- package/dist/lowering/types.js +20 -4
- package/dist/parser/parse-utils/call-utils.d.ts +0 -2
- package/dist/parser/parse-utils/call-utils.js +0 -6
- package/dist/parser/parse-utils/note-utils.d.ts +8 -0
- package/dist/parser/parse-utils/note-utils.js +35 -13
- package/dist/parser/parse-utils/string-utils.d.ts +8 -0
- package/dist/parser/parse-utils/string-utils.js +20 -0
- package/dist/parser/parserContext.d.ts +8 -5
- package/dist/parser/parserContext.js +38 -33
- package/dist/parser/preprocess.js +17 -11
- package/dist/playback/compile.d.ts +18 -0
- package/dist/playback/compile.js +401 -0
- package/dist/playback/event.d.ts +91 -0
- package/dist/playback/event.js +87 -0
- package/dist/playback/time.d.ts +14 -0
- package/dist/playback/time.js +81 -0
- package/dist/playback/types.d.ts +128 -0
- package/dist/playback/types.js +3 -0
- package/dist/render/canvas.d.ts +4 -4
- package/dist/render/canvas.js +20 -5
- package/dist/render/index.d.ts +1 -0
- package/dist/render/index.js +1 -0
- package/dist/render/paint.d.ts +8 -0
- package/dist/render/paint.js +101 -0
- package/dist/render/svg.d.ts +3 -3
- package/dist/render/svg.js +10 -8
- package/dist/render/text.d.ts +17 -0
- package/dist/render/text.js +35 -0
- package/dist/render/types.d.ts +1 -1
- package/grammar.md +217 -122
- package/package.json +14 -9
- package/dist/functions/over/index.js +0 -307
|
@@ -1,307 +0,0 @@
|
|
|
1
|
-
import { ASTNodeBase, ASTFunctionNode, ASTTextNode, ASTLabelNode, ASTBraceNode } from "../ASTtypes.js";
|
|
2
|
-
import { ErrorDiagnostic } from "../../diagnostic.js";
|
|
3
|
-
import { isVisualTemporalNode, TemporalNodeBase, } from "../../lowering/types.js";
|
|
4
|
-
import { prepareLayoutHost } from "../../layout/engine.js";
|
|
5
|
-
/**
|
|
6
|
-
* 函数 up 的设计经历:
|
|
7
|
-
* up 最初的设计是为了解决和弦的柱状音符,进一步拓展到会标记在音符上方的内容,比如小节线上方的小节号、音符上方的变速记号、番茄简谱里的音符注释
|
|
8
|
-
* 于是含义变为了“空间纵向堆叠”。为了让功能更加强大,本来设计是允许 up 每个元素不限制类型的,想放什么就放什么,
|
|
9
|
-
* 这就导致每个元素是独立渲染的,也就是谱中谱,作用域什么的都很复杂(跨作用域格外麻烦),我对实现效果也不满意
|
|
10
|
-
* 而且有三个问题:
|
|
11
|
-
* 1. 排版上不好对齐。只有一个元素可以直接用anchor进行对齐,而多个,甚至是嵌套,对齐锚点应该选择哪个呢?
|
|
12
|
-
* 2. 时间上不好对齐。如果某个元素里面包含了多个事件,在 onTimeState 时应该如何处理?
|
|
13
|
-
* 3. ColType 类型不好确定。如果每个元素都只有一个,那么 ColType 可以直接取最小值,但是如果某个元素里面有多个事件,那么 ColType 应该取哪个呢?
|
|
14
|
-
*
|
|
15
|
-
* ColType 属于一个时间位置,不属于任意大的 AST 子树。所以每个元素必须有以下接口:
|
|
16
|
-
* - box
|
|
17
|
-
* - t/T
|
|
18
|
-
* - colType
|
|
19
|
-
* - onTimeState
|
|
20
|
-
*
|
|
21
|
-
* 此时 up 的每个元素就只允许为一个 VisualTemporalNode,不再需要处理子内容了
|
|
22
|
-
*/
|
|
23
|
-
class UpFunction extends ASTFunctionNode {
|
|
24
|
-
static def = {
|
|
25
|
-
name: ["up"],
|
|
26
|
-
description: "把同一时间位置的可见对象向上堆叠",
|
|
27
|
-
example: `@up(content1, content2, ...)
|
|
28
|
-
语法糖: ^
|
|
29
|
-
{content1} ^ {content2} ^ ...
|
|
30
|
-
表示content1和content2在时间上完全重叠,通常用于和声等需要对齐的场景。可以有任意多个参数,至少需要两个参数。
|
|
31
|
-
`,
|
|
32
|
-
allowExtraArgs: true,
|
|
33
|
-
extraArgType: "content",
|
|
34
|
-
args: [],
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* 语义确定后,把和弦的修饰交还给最下面的成员
|
|
38
|
-
*
|
|
39
|
-
* lowering 期间修饰必须挂在和弦上,自动连梁之类的 augmenter 才看得到它的节奏;
|
|
40
|
-
* 但渲染上「最下面的成员代表整个和弦」,由它按普通音符的规则承载修饰,
|
|
41
|
-
* 减时线才会落在数字与下八度点之间,而不是压在整个和弦盒的下面。
|
|
42
|
-
* 交还后和弦自身不再有 addon,排版阶段不必再动它。
|
|
43
|
-
*/
|
|
44
|
-
static loweringFinalize = (result) => {
|
|
45
|
-
for (const column of result.columns) {
|
|
46
|
-
for (const node of column) {
|
|
47
|
-
// addon 非空就意味着当初从第一个成员提升过,成员必定存在
|
|
48
|
-
if (!(node instanceof UpTemporal) || !node.addon)
|
|
49
|
-
continue;
|
|
50
|
-
node.members[0].addon = node.addon;
|
|
51
|
-
node.addon = void 0;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
/** 和弦自己会产生 UpTemporal,标签直接指向整个和弦(内部没有 note 时也能标注) */
|
|
56
|
-
labelable() { return this; }
|
|
57
|
-
static deSugarAtom(source, start, _end) {
|
|
58
|
-
if (source[start] === '^') {
|
|
59
|
-
const node = {
|
|
60
|
-
kind: "sugar",
|
|
61
|
-
data: UpFunction,
|
|
62
|
-
span: { start, end: start + 1 },
|
|
63
|
-
};
|
|
64
|
-
return { next: start + 1, node };
|
|
65
|
-
}
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
// 这段代码同 stack
|
|
69
|
-
static deSugarRelation(ctx, nodes, at) {
|
|
70
|
-
const n = nodes[at++];
|
|
71
|
-
if (!(n.kind === "sugar" && n.data === UpFunction))
|
|
72
|
-
return null;
|
|
73
|
-
// 找上一个非文本节点 实现忽略中间内容的作用
|
|
74
|
-
// 另一个做法是如果上一个不是可用节点就报错
|
|
75
|
-
let left = ctx.nodes.length - 1;
|
|
76
|
-
for (; left >= 0; left--) {
|
|
77
|
-
if (ctx.nodes[left] instanceof ASTTextNode)
|
|
78
|
-
continue;
|
|
79
|
-
break;
|
|
80
|
-
}
|
|
81
|
-
let overNode = left >= 0 ? ctx.nodes[left] : null;
|
|
82
|
-
if (overNode === null) {
|
|
83
|
-
throw new ErrorDiagnostic("UP_NO_TARGET", "@up语法糖错误: 左边没有找到可叠加的目标", n.span);
|
|
84
|
-
}
|
|
85
|
-
/** 左操作数在 ctx.nodes 中的起点;只有这一段会被 up 吞并,更早的节点必须保留 */
|
|
86
|
-
let replaceFrom = left;
|
|
87
|
-
// 对 label 的特判: 目标变为label到被标记的节点范围内的所有节点
|
|
88
|
-
if (overNode instanceof ASTLabelNode) {
|
|
89
|
-
const tgt = overNode.parent;
|
|
90
|
-
for (let j = left - 1; j >= 0; j--) {
|
|
91
|
-
if (ctx.nodes[j] === tgt) {
|
|
92
|
-
overNode = new ASTBraceNode({
|
|
93
|
-
start: tgt.sourceSpan.start,
|
|
94
|
-
end: overNode.sourceSpan.end,
|
|
95
|
-
}, ctx.nodes.slice(j, left + 1), null);
|
|
96
|
-
replaceFrom = j;
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
if (!(overNode instanceof UpFunction)) {
|
|
102
|
-
const newNode = new UpFunction(n.span, new Map(), ctx);
|
|
103
|
-
newNode.addContent(overNode);
|
|
104
|
-
overNode = newNode;
|
|
105
|
-
}
|
|
106
|
-
// 找到下一个非文本节点 通过全量后续解析的方式进行 还是有些trick
|
|
107
|
-
const storage = ctx.nodes;
|
|
108
|
-
ctx.nodes = [];
|
|
109
|
-
ctx.makeNodes(nodes, at);
|
|
110
|
-
for (let i = 0; i < ctx.nodes.length; i++) {
|
|
111
|
-
// 后向跳过文本节点 和上面保持一致
|
|
112
|
-
const right = ctx.nodes[i];
|
|
113
|
-
if (right instanceof ASTTextNode)
|
|
114
|
-
continue;
|
|
115
|
-
overNode.addContent(right);
|
|
116
|
-
storage.length = replaceFrom;
|
|
117
|
-
storage.push(overNode);
|
|
118
|
-
while (++i < ctx.nodes.length)
|
|
119
|
-
storage.push(ctx.nodes[i]);
|
|
120
|
-
ctx.nodes = storage;
|
|
121
|
-
return nodes.length;
|
|
122
|
-
}
|
|
123
|
-
throw new ErrorDiagnostic("UP_NO_TARGET", "@up语法糖错误: 右边没有找到可叠加的目标", n.span);
|
|
124
|
-
}
|
|
125
|
-
contents = [];
|
|
126
|
-
size;
|
|
127
|
-
get children() { return this.contents; }
|
|
128
|
-
/** up 的参数复用普通 hook,并收敛为单个可见 Temporal 成员 */
|
|
129
|
-
loweringEnter(ctx, track) {
|
|
130
|
-
const members = [];
|
|
131
|
-
// 成员不是外层分组的成员,和弦才是;否则 voice 的歌词会按下标错位
|
|
132
|
-
ctx.isolateFromLoweringGroups(() => {
|
|
133
|
-
for (const content of this.contents) {
|
|
134
|
-
// 摊平所有时间列取全部事件,和弦要求恰好一个
|
|
135
|
-
const [member, ...rest] = ctx.trackedEvents(content, 0, track).columns.flat();
|
|
136
|
-
if (!member || rest.length > 0 || !isVisualTemporalNode(member)) {
|
|
137
|
-
throw new ErrorDiagnostic("E_UP_INVALID_CHILD", "@up 的每个参数必须恰好产生一个可见 Temporal,且不能包含多声部结构", content.sourceSpan);
|
|
138
|
-
}
|
|
139
|
-
members.push(member);
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
return [new UpTemporal(this, members)];
|
|
143
|
-
}
|
|
144
|
-
constructor(span, args, ctx, parent = null) {
|
|
145
|
-
super(span, parent);
|
|
146
|
-
this.size = ctx.fontSize;
|
|
147
|
-
for (const [, value] of args) {
|
|
148
|
-
if (value instanceof ASTNodeBase) {
|
|
149
|
-
this.addContent(value);
|
|
150
|
-
continue;
|
|
151
|
-
}
|
|
152
|
-
const c = ctx.parseArgWithType(value.start, value.end, "content", span.start);
|
|
153
|
-
if (c !== null) {
|
|
154
|
-
this.addContent(c);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
addContent(node) {
|
|
159
|
-
if (node instanceof UpFunction)
|
|
160
|
-
this.combine(node);
|
|
161
|
-
else {
|
|
162
|
-
this.contents.push(node);
|
|
163
|
-
node.parent = this;
|
|
164
|
-
const s = node.sourceSpan;
|
|
165
|
-
this.sourceSpan.start = Math.min(this.sourceSpan.start, s.start);
|
|
166
|
-
this.sourceSpan.end = Math.max(this.sourceSpan.end, s.end);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
toString(source) {
|
|
170
|
-
return `@up(${this.contents.map(c => c.toString(source)).join(", ")})`;
|
|
171
|
-
}
|
|
172
|
-
combine(ano) {
|
|
173
|
-
this.sourceSpan.start = Math.min(this.sourceSpan.start, ano.sourceSpan.start);
|
|
174
|
-
this.sourceSpan.end = Math.max(this.sourceSpan.end, ano.sourceSpan.end);
|
|
175
|
-
for (const c of ano.contents)
|
|
176
|
-
c.parent = this;
|
|
177
|
-
this.contents.push(...ano.contents);
|
|
178
|
-
ano.contents.length = 0;
|
|
179
|
-
return this;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
export const UpNode = UpFunction;
|
|
183
|
-
class UpTemporal extends TemporalNodeBase {
|
|
184
|
-
members;
|
|
185
|
-
/** 每个成员相对本盒左上角的局部偏移,onPlaced 时同步为绝对坐标 */
|
|
186
|
-
offsets = [];
|
|
187
|
-
constructor(ast, members) {
|
|
188
|
-
super();
|
|
189
|
-
this.ast = ast;
|
|
190
|
-
this.members = members;
|
|
191
|
-
this.T = members[0]?.T ?? 0;
|
|
192
|
-
this.t = 0;
|
|
193
|
-
this.type = 2 /* ColType.DEFAULT */;
|
|
194
|
-
this.initLayoutBox();
|
|
195
|
-
// 第一个成员决定和弦的时值,它的修饰语义也随之成为整个和弦的修饰,
|
|
196
|
-
// 自动连梁等语义处理才能看到这个和弦的节奏;
|
|
197
|
-
// 随后外层 LoweringGroup 会在同一 addon 上继续累加
|
|
198
|
-
const leadAddon = members[0]?.addon;
|
|
199
|
-
if (leadAddon)
|
|
200
|
-
this.addon = { ...leadAddon };
|
|
201
|
-
for (const member of members) {
|
|
202
|
-
if (member.type < this.type)
|
|
203
|
-
this.type = member.type;
|
|
204
|
-
// 堆叠在一起的成员共享同一个时值,由第一个成员决定;
|
|
205
|
-
// 本来就没有时长的成员(标注、小节线等)保持 0,不会被拉长
|
|
206
|
-
if (member.T !== 0)
|
|
207
|
-
member.T = this.T;
|
|
208
|
-
// 修饰已经提升到和弦上,成员不再单独绘制,
|
|
209
|
-
// 否则和弦内部会出现多余的减时线或附点
|
|
210
|
-
member.addon = void 0;
|
|
211
|
-
// 成员不进入全局 columns,对外由和弦代表:
|
|
212
|
-
// 写在成员上的标签因此能直接做 @beam / @tie 的端点
|
|
213
|
-
member.foldedInto = this;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
/** 所有成员属于 up 的同一个全局时间位置,但分别读取同一份状态快照。 */
|
|
217
|
-
onTimeState(state) {
|
|
218
|
-
for (const member of this.members) {
|
|
219
|
-
member.t = this.t;
|
|
220
|
-
member.track = this.track;
|
|
221
|
-
member.layoutLine = this.layoutLine;
|
|
222
|
-
member.onTimeState?.({ ...state });
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* 第一个成员留在轨道基线上,其余成员按书写顺序依次向上叠放
|
|
227
|
-
*
|
|
228
|
-
* 成员不进入全局 columns,因此它们的准备、定位和绘制都由本节点负责;
|
|
229
|
-
* 准备直接复用引擎的 prepareLayoutHost,保证成员的装饰、端口与顶层对象完全一致。
|
|
230
|
-
*/
|
|
231
|
-
prepareLayout(context) {
|
|
232
|
-
this.offsets.length = 0;
|
|
233
|
-
for (const member of this.members)
|
|
234
|
-
prepareLayoutHost(member, context);
|
|
235
|
-
const first = this.members[0];
|
|
236
|
-
if (!first) {
|
|
237
|
-
this.box.w = this.box.h = 0;
|
|
238
|
-
this.box.anchor = this.box.visualAxis = 0;
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
// 横向:所有成员共用一个对齐点,升降号不会把和弦推离时间列中心
|
|
242
|
-
let anchor = 0;
|
|
243
|
-
let right = 0;
|
|
244
|
-
let leftReach = 0;
|
|
245
|
-
let rightReach = 0;
|
|
246
|
-
for (const member of this.members) {
|
|
247
|
-
const box = member.box;
|
|
248
|
-
anchor = Math.max(anchor, box.anchor);
|
|
249
|
-
right = Math.max(right, box.w - box.anchor);
|
|
250
|
-
leftReach = Math.max(leftReach, box.anchor - (member.ports["body.left"]?.x ?? 0));
|
|
251
|
-
rightReach = Math.max(rightReach, (member.ports["body.right"]?.x ?? box.w) - box.anchor);
|
|
252
|
-
}
|
|
253
|
-
// 纵向:以第一个成员的盒顶为 0 向上堆叠得到负坐标,最后整体下移
|
|
254
|
-
const gap = this.ast.size * 0.12;
|
|
255
|
-
let cursor = 0;
|
|
256
|
-
for (const member of this.members) {
|
|
257
|
-
if (member !== first)
|
|
258
|
-
cursor -= gap + member.box.h;
|
|
259
|
-
this.offsets.push({ x: anchor - member.box.anchor, y: cursor });
|
|
260
|
-
}
|
|
261
|
-
const top = cursor; // 堆叠严格向上,最后一个成员就是最高点
|
|
262
|
-
for (const offset of this.offsets)
|
|
263
|
-
offset.y -= top;
|
|
264
|
-
this.box.w = anchor + right;
|
|
265
|
-
this.box.h = first.box.h - top;
|
|
266
|
-
this.box.anchor = anchor;
|
|
267
|
-
// 和弦用最下面的成员对齐轨道基线,上方成员只向上撑开行高
|
|
268
|
-
this.box.visualAxis = first.box.visualAxis - top;
|
|
269
|
-
// 端口:最下面的成员代表整个和弦,把它发布的端口原样上提,
|
|
270
|
-
// 减时线、歌词等端口于是与普通音符完全一致,关系函数不需要认识 up
|
|
271
|
-
const firstOffset = this.offsets[0];
|
|
272
|
-
for (const name in first.ports) {
|
|
273
|
-
const port = first.ports[name];
|
|
274
|
-
this.ports[name] = { x: firstOffset.x + port.x, y: firstOffset.y + port.y };
|
|
275
|
-
}
|
|
276
|
-
// 核心范围取全体成员的并集,减时线才能盖住最宽的数字
|
|
277
|
-
this.ports["body.left"] = { x: anchor - leftReach, y: this.box.visualAxis };
|
|
278
|
-
this.ports["body.right"] = { x: anchor + rightReach, y: this.box.visualAxis };
|
|
279
|
-
// 唯一的例外:连音线要接到和弦顶部
|
|
280
|
-
const last = this.members[this.members.length - 1];
|
|
281
|
-
const lastOffset = this.offsets[this.members.length - 1];
|
|
282
|
-
const lastTiePort = last.ports["tie.top"];
|
|
283
|
-
this.ports["tie.top"] = {
|
|
284
|
-
x: anchor,
|
|
285
|
-
y: lastOffset.y + (lastTiePort ? lastTiePort.y : 0),
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
/** 引擎每次改变本节点坐标后,按准备阶段保存的局部偏移重算成员绝对坐标 */
|
|
289
|
-
onPlaced() {
|
|
290
|
-
for (let i = 0; i < this.members.length; i++) {
|
|
291
|
-
const offset = this.offsets[i];
|
|
292
|
-
if (!offset)
|
|
293
|
-
continue;
|
|
294
|
-
const member = this.members[i];
|
|
295
|
-
member.box.x = this.box.x + offset.x;
|
|
296
|
-
member.box.y = this.box.y + offset.y;
|
|
297
|
-
member.onPlaced?.();
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
paint(painter) {
|
|
301
|
-
for (const member of this.members) {
|
|
302
|
-
member.paint(painter);
|
|
303
|
-
for (const decoration of member.decorations)
|
|
304
|
-
decoration.paint(painter);
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
}
|