@yft-design/engine 0.0.5 → 0.0.6

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.
@@ -0,0 +1,75 @@
1
+ /**
2
+ * PSD 文字变形(Warp Text)网格数学——批次 365 自 Patchy(github.com/SethRobinson/Patchy)
3
+ * core/warp_mesh.cpp 逐式移植:15 种变形样式的控制网格构造 + 水平/垂直失真施加 +
4
+ * Bernstein 曲面前向求值 + 前向格点构建 + 闭式逆双线性。
5
+ *
6
+ * Patchy 用 COM 自动化抓 Photoshop 2026 实际生成的网格,58 组 capture 拟合到 1e-4
7
+ * (最大残差 2.4e-6 px)——「样式 + 参数 → 控制点网格」的构造法 Adobe 从未公开,
8
+ * 本模块是该逆向的唯一权威数学源,公式改动须以 Patchy 上游为据。
9
+ *
10
+ * 语义锚点(warp.md「Warp Text」节):
11
+ * - 变形作用于文本 bounds 布局盒而非墨迹盒;PS 每次重排自行重推盒,引擎消费方
12
+ * 同样以节点布局盒实时求值(不落盘缓存盒)。
13
+ * - 失真施加顺序:先按行(v,绕该行两边缘点中点缩放)、后按列(u,同规则),
14
+ * so_persp capture 以 ~1e-7 px 钉死该顺序与中点锚定。
15
+ * - warpRotate=Vrtc = 水平构造在 (h,w) 上做、x/y 互换回装、布局转置(twist 除外
16
+ * ——PS 对 Hrzn/Vrtc 烘出同一网格,方向不变量)。
17
+ * 纯函数无 DOM,jsdom 可测(smartObjectHomography.spec 同范式)。
18
+ */
19
+ import type { Mat } from './mat2d';
20
+ /** PSD TySh warp 的 5 标量(主仓 parseText 自 psd-lib text.warp 直录;style 用 psd-lib 解码词表) */
21
+ export interface PsdTextWarpParams {
22
+ style: string;
23
+ /** bend(-100~100,warpValue) */
24
+ bend: number;
25
+ /** 水平失真(-100~100,warpPerspective) */
26
+ horizontal: number;
27
+ /** 垂直失真(-100~100,warpPerspectiveOther) */
28
+ vertical: number;
29
+ rotate: 'horizontal' | 'vertical';
30
+ }
31
+ /** 变形控制网格:uOrder×vOrder 行主序扁平控制点(identity 时就是盒网格) */
32
+ export interface WarpMeshGrid {
33
+ uOrder: number;
34
+ vOrder: number;
35
+ xs: number[];
36
+ ys: number[];
37
+ }
38
+ /** 前向重采样格点:doc 像素坐标与源像素坐标逐点成对(cell 逆双线性的输入) */
39
+ export interface WarpSurfaceGrid {
40
+ columns: number;
41
+ rows: number;
42
+ docXs: number[];
43
+ docYs: number[];
44
+ sourceXs: number[];
45
+ sourceYs: number[];
46
+ }
47
+ /** 盒网格(uOrder×vOrder 控制点铺在 left/top/right/bottom 上;order 钳 [2,4]) */
48
+ export declare const identityWarpMesh: (left: number, top: number, right: number, bottom: number, uOrder: number, vOrder: number) => WarpMeshGrid;
49
+ /** 张量积 Bernstein 曲面在 (u, v) 的前向求值(u/v 可越 [0,1]——Bernstein 外推覆盖出盒墨迹) */
50
+ export declare const evaluateWarpMesh: (mesh: WarpMeshGrid, u: number, v: number) => {
51
+ x: number;
52
+ y: number;
53
+ };
54
+ /** 可生成样式判定(psd-lib 词表;none/custom 等 COM 烘焙形态由位图兜底,不走生成器) */
55
+ export declare const isGeneratableWarpStyle: (style: string) => boolean;
56
+ /** 样式 + bend + 方向 → 控制网格(Vrtc = 换轴构造;twist 方向不变量不转置) */
57
+ export declare const generateStyleWarpMesh: (style: string, value: number, rotateVertical: boolean, width: number, height: number) => WarpMeshGrid | undefined;
58
+ /** 水平/垂直失真(Warp Text 对话框两失真项):先 v 行后 u 列,每行/列绕其两边缘
59
+ * 点的中点缩放 1+(2·t-1)·percent/100(so_persp capture 以 ~1e-7 px 钉死顺序与中点规则) */
60
+ export declare const applyWarpDistortion: (mesh: WarpMeshGrid, horizontalPercent: number, verticalPercent: number) => void;
61
+ /** 参数 → 完整变形网格(样式构造 + 失真施加)。身份参数(全 0)返回 undefined 由调用方走常规管线。 */
62
+ export declare const generatePsdWarpMesh: (params: PsdTextWarpParams, width: number, height: number) => WarpMeshGrid | undefined;
63
+ /** 元素 raw.psdWarp 的有效变形判定:形状合法 + 样式可生成 + 至少一参数非 0。
64
+ * 身份/不可生成(none、custom COM 烘焙形态)→ null,渲染走位图/常规管线。 */
65
+ export declare const activePsdTextWarp: (raw: unknown) => PsdTextWarpParams | null;
66
+ /** 源位图窗口 → 前向重采样格点。窗口是源位图的墨迹裁剪(参数区间 [u0,u1]×[v0,v1]
67
+ * 覆盖出盒墨迹的 Bernstein 外推),affine 把网格盒空间合成到输出像素空间
68
+ * (fabric Mat 列向量约定)。源像素 = fraction × sourceSize(窗口即整张源位图)。 */
69
+ export declare const buildWarpSurfaceGridOverWindow: (mesh: WarpMeshGrid, boxLeft: number, boxTop: number, boxRight: number, boxBottom: number, windowLeft: number, windowTop: number, windowRight: number, windowBottom: number, sourceWidth: number, sourceHeight: number, affine: Mat, maxCellDocPixels: number, maxCells: number) => WarpSurfaceGrid | undefined;
70
+ /** 闭式逆双线性:解 p(s,t) = (1-s)(1-t)p00 + s(1-t)p10 + st·p11 + (1-s)t·p01 = (x,y)。
71
+ * 叉积消 t 得 s 的一元二次;无解(点在格外)返回 undefined。 */
72
+ export declare const invertBilinearCell: (x: number, y: number, x00: number, y00: number, x10: number, y10: number, x11: number, y11: number, x01: number, y01: number) => {
73
+ s: number;
74
+ t: number;
75
+ } | undefined;
@@ -0,0 +1,469 @@
1
+ /**
2
+ * PSD 文字变形(Warp Text)网格数学——批次 365 自 Patchy(github.com/SethRobinson/Patchy)
3
+ * core/warp_mesh.cpp 逐式移植:15 种变形样式的控制网格构造 + 水平/垂直失真施加 +
4
+ * Bernstein 曲面前向求值 + 前向格点构建 + 闭式逆双线性。
5
+ *
6
+ * Patchy 用 COM 自动化抓 Photoshop 2026 实际生成的网格,58 组 capture 拟合到 1e-4
7
+ * (最大残差 2.4e-6 px)——「样式 + 参数 → 控制点网格」的构造法 Adobe 从未公开,
8
+ * 本模块是该逆向的唯一权威数学源,公式改动须以 Patchy 上游为据。
9
+ *
10
+ * 语义锚点(warp.md「Warp Text」节):
11
+ * - 变形作用于文本 bounds 布局盒而非墨迹盒;PS 每次重排自行重推盒,引擎消费方
12
+ * 同样以节点布局盒实时求值(不落盘缓存盒)。
13
+ * - 失真施加顺序:先按行(v,绕该行两边缘点中点缩放)、后按列(u,同规则),
14
+ * so_persp capture 以 ~1e-7 px 钉死该顺序与中点锚定。
15
+ * - warpRotate=Vrtc = 水平构造在 (h,w) 上做、x/y 互换回装、布局转置(twist 除外
16
+ * ——PS 对 Hrzn/Vrtc 烘出同一网格,方向不变量)。
17
+ * 纯函数无 DOM,jsdom 可测(smartObjectHomography.spec 同范式)。
18
+ */
19
+ const ZERO_BEND = 1e-9;
20
+ const CELL_EPSILON = 1e-9;
21
+ /** Bernstein 基(order 2/3/4 = 一次/二次/三次),返回长度 4 的权重(尾部补零) */
22
+ const bernsteinWeights = (order, t) => {
23
+ const s = 1 - t;
24
+ if (order === 2)
25
+ return [s, t, 0, 0];
26
+ if (order === 3)
27
+ return [s * s, 2 * s * t, t * t, 0];
28
+ return [s * s * s, 3 * s * s * t, 3 * s * t * t, t * t * t];
29
+ };
30
+ /** 盒网格(uOrder×vOrder 控制点铺在 left/top/right/bottom 上;order 钳 [2,4]) */
31
+ export const identityWarpMesh = (left, top, right, bottom, uOrder, vOrder) => {
32
+ const mesh = {
33
+ uOrder: Math.min(4, Math.max(2, uOrder)),
34
+ vOrder: Math.min(4, Math.max(2, vOrder)),
35
+ xs: [],
36
+ ys: []
37
+ };
38
+ for (let row = 0; row < mesh.vOrder; row++) {
39
+ const fv = mesh.vOrder === 1 ? 0 : row / (mesh.vOrder - 1);
40
+ for (let column = 0; column < mesh.uOrder; column++) {
41
+ const fu = mesh.uOrder === 1 ? 0 : column / (mesh.uOrder - 1);
42
+ mesh.xs.push(left + (right - left) * fu);
43
+ mesh.ys.push(top + (bottom - top) * fv);
44
+ }
45
+ }
46
+ return mesh;
47
+ };
48
+ /** 张量积 Bernstein 曲面在 (u, v) 的前向求值(u/v 可越 [0,1]——Bernstein 外推覆盖出盒墨迹) */
49
+ export const evaluateWarpMesh = (mesh, u, v) => {
50
+ const wu = bernsteinWeights(mesh.uOrder, u);
51
+ const wv = bernsteinWeights(mesh.vOrder, v);
52
+ let x = 0;
53
+ let y = 0;
54
+ for (let row = 0; row < mesh.vOrder; row++) {
55
+ for (let column = 0; column < mesh.uOrder; column++) {
56
+ const weight = wu[column] * wv[row];
57
+ x += weight * mesh.xs[row * mesh.uOrder + column];
58
+ y += weight * mesh.ys[row * mesh.uOrder + column];
59
+ }
60
+ }
61
+ return { x, y };
62
+ };
63
+ /** 经典三次贝塞尔圆弧近似的一行:水平弦 (ax,y)..(bx,y)、圆心角 2θ、bulgeUp 时向 -y 鼓出
64
+ * (内容空间 +y 向下)。手柄长 (4/3)·tan(θ/2)·R,端点切线自弦转 θ(E9 capture 逐点吻合)。 */
65
+ const appendArcRow = (mesh, ax, bx, y, theta, bulgeUp) => {
66
+ const sinTheta = Math.sin(theta);
67
+ const cosTheta = Math.cos(theta);
68
+ const radius = (bx - ax) / (2 * sinTheta);
69
+ const handle = (4 / 3) * Math.tan(theta / 2) * radius;
70
+ const dy = bulgeUp ? -handle * sinTheta : handle * sinTheta;
71
+ mesh.xs.push(ax, ax + handle * cosTheta, bx - handle * cosTheta, bx);
72
+ mesh.ys.push(y, y + dy, y + dy, y);
73
+ };
74
+ const appendIdentityRow = (mesh, width, y) => {
75
+ mesh.xs.push(0, width / 3, (2 * width) / 3, width);
76
+ mesh.ys.push(y, y, y, y);
77
+ };
78
+ /** 4×n 网格纵向镜像(y → height − y,行序倒转):PS 负 bend 的 arc 就是正 bend 的上下翻转 */
79
+ const mirrorMeshVertically = (mesh, height) => {
80
+ const mirrored = { uOrder: mesh.uOrder, vOrder: mesh.vOrder, xs: [], ys: [] };
81
+ for (let row = 0; row < mesh.vOrder; row++) {
82
+ const sourceRow = mesh.vOrder - 1 - row;
83
+ for (let column = 0; column < mesh.uOrder; column++) {
84
+ const to = row * mesh.uOrder + column;
85
+ const from = sourceRow * mesh.uOrder + column;
86
+ mirrored.xs[to] = mesh.xs[from];
87
+ mirrored.ys[to] = height - mesh.ys[from];
88
+ }
89
+ }
90
+ return mirrored;
91
+ };
92
+ /** warpRotate=Vrtc 的换轴装回:水平构造在 (h,w) 上做、x/y 互换、布局转置(e9 vrtc capture) */
93
+ const swapMeshAxes = (mesh) => {
94
+ const swapped = { uOrder: mesh.vOrder, vOrder: mesh.uOrder, xs: [], ys: [] };
95
+ for (let row = 0; row < mesh.vOrder; row++) {
96
+ for (let column = 0; column < mesh.uOrder; column++) {
97
+ const from = row * mesh.uOrder + column;
98
+ const to = column * mesh.vOrder + row;
99
+ swapped.xs[to] = mesh.ys[from];
100
+ swapped.ys[to] = mesh.xs[from];
101
+ }
102
+ }
103
+ return swapped;
104
+ };
105
+ /** 15 样式的水平构造(warp.md §样式网格构造 逐式对应);style 词表 = psd-lib warpStyle 解码值 */
106
+ const generateHorizontalStyleMesh = (style, value, width, height) => {
107
+ const bend = Math.min(100, Math.max(-100, value));
108
+ const theta = (Math.abs(bend) * Math.PI) / 200;
109
+ // flag/wave/rise 的位移尺度基于高度而非宽度(E9b capture)
110
+ const displacement = (2 * height * bend) / 100;
111
+ let mesh = { uOrder: 4, vOrder: style === 'wave' ? 3 : 2, xs: [], ys: [] };
112
+ if (style === 'arcLower' || style === 'arcUpper') {
113
+ if (Math.abs(bend) < ZERO_BEND)
114
+ return identityWarpMesh(0, 0, width, height, 4, 2);
115
+ // 一边保持原位;另一边正 bend 向盒外拱、负 bend 拱进盒内(e9c capture)
116
+ appendIdentityRow(mesh, width, 0);
117
+ appendArcRow(mesh, 0, width, height, theta, bend < 0);
118
+ return style === 'arcUpper' ? mirrorMeshVertically(mesh, height) : mesh;
119
+ }
120
+ if (style === 'fish') {
121
+ // flag 的 S 曲线在上缘、下缘反向 S——首尾被掐(e9c:内部列上 -/+d、下 +/-d)
122
+ appendIdentityRow(mesh, width, 0);
123
+ appendIdentityRow(mesh, width, height);
124
+ mesh.ys[1] -= displacement;
125
+ mesh.ys[2] += displacement;
126
+ mesh.ys[5] += displacement;
127
+ mesh.ys[6] -= displacement;
128
+ return mesh;
129
+ }
130
+ if (style === 'fisheye') {
131
+ // 4×4 仅四个内部点动:各沿到最近角点的连线移 bend/50(+50 时恰好坐在角点上)
132
+ mesh = identityWarpMesh(0, 0, width, height, 4, 4);
133
+ const t = bend / 50;
134
+ for (let row = 1; row <= 2; row++) {
135
+ for (let column = 1; column <= 2; column++) {
136
+ const index = row * 4 + column;
137
+ const cornerX = column === 1 ? 0 : width;
138
+ const cornerY = row === 1 ? 0 : height;
139
+ mesh.xs[index] += t * (cornerX - mesh.xs[index]);
140
+ mesh.ys[index] += t * (cornerY - mesh.ys[index]);
141
+ }
142
+ }
143
+ return mesh;
144
+ }
145
+ if (style === 'inflate' || style === 'squeeze') {
146
+ // 二次 3×3 面片:角点与中心钉死,边中点每 50% bend 滑轴长的 1/4。inflate 四边
147
+ // 全外推;squeeze 上下外推、左右内捏(e9c capture)
148
+ mesh = identityWarpMesh(0, 0, width, height, 3, 3);
149
+ const dx = (width * bend) / 200;
150
+ const dy = (height * bend) / 200;
151
+ mesh.ys[1] -= dy;
152
+ mesh.ys[7] += dy;
153
+ if (style === 'inflate') {
154
+ mesh.xs[3] -= dx;
155
+ mesh.xs[5] += dx;
156
+ }
157
+ else {
158
+ mesh.xs[3] += dx;
159
+ mesh.xs[5] -= dx;
160
+ }
161
+ return mesh;
162
+ }
163
+ if (style === 'twist') {
164
+ // 4×4 内环切向环流:各内部点朝下一环位移动(正 bend 顺时针、负逆时针),
165
+ // 每 100% bend 移满轴长(e9c capture)
166
+ mesh = identityWarpMesh(0, 0, width, height, 4, 4);
167
+ const moveX = (width * Math.abs(bend)) / 100;
168
+ const moveY = (height * Math.abs(bend)) / 100;
169
+ if (bend > 0) {
170
+ mesh.xs[5] += moveX;
171
+ mesh.ys[6] += moveY;
172
+ mesh.xs[10] -= moveX;
173
+ mesh.ys[9] -= moveY;
174
+ }
175
+ else if (bend < 0) {
176
+ mesh.ys[5] += moveY;
177
+ mesh.xs[6] -= moveX;
178
+ mesh.ys[10] -= moveY;
179
+ mesh.xs[9] += moveX;
180
+ }
181
+ return mesh;
182
+ }
183
+ if (style === 'shellLower' || style === 'shellUpper') {
184
+ if (Math.abs(bend) < ZERO_BEND)
185
+ return identityWarpMesh(0, 0, width, height, 4, 4);
186
+ // 两行保持 identity;第三行端点绕锚角旋转 θ(正 bend 锚顶角、负 bend 锚底角)、
187
+ // 内部保持 identity;壳缘自身正 bend 绕远角(半径 height)外扬成弧、负 bend 沿
188
+ // 原弦向盒内收弧(e9c/e9d capture)
189
+ const sinTheta = Math.sin(theta);
190
+ const cosTheta = Math.cos(theta);
191
+ mesh = { uOrder: 4, vOrder: 4, xs: [], ys: [] };
192
+ appendIdentityRow(mesh, width, 0);
193
+ appendIdentityRow(mesh, width, height / 3);
194
+ if (bend > 0) {
195
+ const radius = (2 * height) / 3;
196
+ mesh.xs.push(-radius * sinTheta, width / 3, (2 * width) / 3, width + radius * sinTheta);
197
+ mesh.ys.push(radius * cosTheta, (2 * height) / 3, (2 * height) / 3, radius * cosTheta);
198
+ appendArcRow(mesh, -height * sinTheta, width + height * sinTheta, height * cosTheta, theta, false);
199
+ }
200
+ else {
201
+ const radius = height / 3;
202
+ mesh.xs.push(-radius * sinTheta, width / 3, (2 * width) / 3, width + radius * sinTheta);
203
+ mesh.ys.push(height - radius * cosTheta, (2 * height) / 3, (2 * height) / 3, height - radius * cosTheta);
204
+ appendArcRow(mesh, 0, width, height, theta, true);
205
+ }
206
+ return style === 'shellUpper' ? mirrorMeshVertically(mesh, height) : mesh;
207
+ }
208
+ if (style === 'arc') {
209
+ if (Math.abs(bend) < ZERO_BEND)
210
+ return identityWarpMesh(0, 0, width, height, 4, 2);
211
+ const sinTheta = Math.sin(theta);
212
+ // 顶角绕底角外摆(半径 = height);两缘同圆心角画弧——带厚恒为 height
213
+ appendArcRow(mesh, -height * sinTheta, width + height * sinTheta, height * (1 - Math.cos(theta)), theta, true);
214
+ appendArcRow(mesh, 0, width, height, theta, true);
215
+ return bend < 0 ? mirrorMeshVertically(mesh, height) : mesh;
216
+ }
217
+ if (style === 'arch' || style === 'bulge') {
218
+ if (Math.abs(bend) < ZERO_BEND)
219
+ return identityWarpMesh(0, 0, width, height, 4, 2);
220
+ const topUp = bend > 0;
221
+ appendArcRow(mesh, 0, width, 0, theta, topUp);
222
+ // arch:两缘同向拱(列刚体平移);bulge:下缘反向拱(带被撑鼓)
223
+ appendArcRow(mesh, 0, width, height, theta, style === 'bulge' ? !topUp : topUp);
224
+ return mesh;
225
+ }
226
+ if (style === 'flag') {
227
+ appendIdentityRow(mesh, width, 0);
228
+ appendIdentityRow(mesh, width, height);
229
+ mesh.ys[1] -= displacement;
230
+ mesh.ys[2] += displacement;
231
+ mesh.ys[5] -= displacement;
232
+ mesh.ys[6] += displacement;
233
+ return mesh;
234
+ }
235
+ if (style === 'wave') {
236
+ appendIdentityRow(mesh, width, 0);
237
+ appendIdentityRow(mesh, width, height / 2);
238
+ appendIdentityRow(mesh, width, height);
239
+ // 两缘行保持水平;仅中间行摆动(且与 flag 的 S 反向)
240
+ mesh.ys[5] += displacement;
241
+ mesh.ys[6] -= displacement;
242
+ return mesh;
243
+ }
244
+ if (style === 'rise') {
245
+ // 刚体列坡道:左半控制点纵向整体平移 d
246
+ appendIdentityRow(mesh, width, 0);
247
+ appendIdentityRow(mesh, width, height);
248
+ mesh.ys[0] += displacement;
249
+ mesh.ys[1] += displacement;
250
+ mesh.ys[4] += displacement;
251
+ mesh.ys[5] += displacement;
252
+ return mesh;
253
+ }
254
+ return undefined;
255
+ };
256
+ /** 可生成样式判定(psd-lib 词表;none/custom 等 COM 烘焙形态由位图兜底,不走生成器) */
257
+ export const isGeneratableWarpStyle = (style) => {
258
+ return (style === 'arc' ||
259
+ style === 'arch' ||
260
+ style === 'bulge' ||
261
+ style === 'flag' ||
262
+ style === 'wave' ||
263
+ style === 'rise' ||
264
+ style === 'arcLower' ||
265
+ style === 'arcUpper' ||
266
+ style === 'shellLower' ||
267
+ style === 'shellUpper' ||
268
+ style === 'fish' ||
269
+ style === 'fisheye' ||
270
+ style === 'inflate' ||
271
+ style === 'squeeze' ||
272
+ style === 'twist');
273
+ };
274
+ /** 样式 + bend + 方向 → 控制网格(Vrtc = 换轴构造;twist 方向不变量不转置) */
275
+ export const generateStyleWarpMesh = (style, value, rotateVertical, width, height) => {
276
+ if (!isGeneratableWarpStyle(style) || width <= 0 || height <= 0)
277
+ return undefined;
278
+ if (!rotateVertical || style === 'twist')
279
+ return generateHorizontalStyleMesh(style, value, width, height);
280
+ const horizontal = generateHorizontalStyleMesh(style, value, height, width);
281
+ return horizontal ? swapMeshAxes(horizontal) : undefined;
282
+ };
283
+ /** 水平/垂直失真(Warp Text 对话框两失真项):先 v 行后 u 列,每行/列绕其两边缘
284
+ * 点的中点缩放 1+(2·t-1)·percent/100(so_persp capture 以 ~1e-7 px 钉死顺序与中点规则) */
285
+ export const applyWarpDistortion = (mesh, horizontalPercent, verticalPercent) => {
286
+ const vertical = Math.min(100, Math.max(-100, verticalPercent));
287
+ const horizontal = Math.min(100, Math.max(-100, horizontalPercent));
288
+ if (vertical !== 0 && mesh.vOrder > 1) {
289
+ for (let row = 0; row < mesh.vOrder; row++) {
290
+ const first = row * mesh.uOrder;
291
+ const last = first + mesh.uOrder - 1;
292
+ const midX = (mesh.xs[first] + mesh.xs[last]) / 2;
293
+ const midY = (mesh.ys[first] + mesh.ys[last]) / 2;
294
+ const v = row / (mesh.vOrder - 1);
295
+ const scale = 1 + ((2 * v - 1) * vertical) / 100;
296
+ for (let column = 0; column < mesh.uOrder; column++) {
297
+ const index = first + column;
298
+ mesh.xs[index] = midX + (mesh.xs[index] - midX) * scale;
299
+ mesh.ys[index] = midY + (mesh.ys[index] - midY) * scale;
300
+ }
301
+ }
302
+ }
303
+ if (horizontal !== 0 && mesh.uOrder > 1) {
304
+ for (let column = 0; column < mesh.uOrder; column++) {
305
+ const first = column;
306
+ const last = (mesh.vOrder - 1) * mesh.uOrder + column;
307
+ const midX = (mesh.xs[first] + mesh.xs[last]) / 2;
308
+ const midY = (mesh.ys[first] + mesh.ys[last]) / 2;
309
+ const u = column / (mesh.uOrder - 1);
310
+ const scale = 1 + ((2 * u - 1) * horizontal) / 100;
311
+ for (let row = 0; row < mesh.vOrder; row++) {
312
+ const index = row * mesh.uOrder + column;
313
+ mesh.xs[index] = midX + (mesh.xs[index] - midX) * scale;
314
+ mesh.ys[index] = midY + (mesh.ys[index] - midY) * scale;
315
+ }
316
+ }
317
+ }
318
+ };
319
+ /** 参数 → 完整变形网格(样式构造 + 失真施加)。身份参数(全 0)返回 undefined 由调用方走常规管线。 */
320
+ export const generatePsdWarpMesh = (params, width, height) => {
321
+ const mesh = generateStyleWarpMesh(params.style, params.bend, params.rotate === 'vertical', width, height);
322
+ if (!mesh)
323
+ return undefined;
324
+ applyWarpDistortion(mesh, params.horizontal, params.vertical);
325
+ return mesh;
326
+ };
327
+ /** 元素 raw.psdWarp 的有效变形判定:形状合法 + 样式可生成 + 至少一参数非 0。
328
+ * 身份/不可生成(none、custom COM 烘焙形态)→ null,渲染走位图/常规管线。 */
329
+ export const activePsdTextWarp = (raw) => {
330
+ if (raw === null || typeof raw !== 'object')
331
+ return null;
332
+ const holder = raw;
333
+ const warp = holder.psdWarp;
334
+ if (warp === null || typeof warp !== 'object')
335
+ return null;
336
+ const w = warp;
337
+ const style = typeof w.style === 'string' ? w.style : '';
338
+ if (!isGeneratableWarpStyle(style))
339
+ return null;
340
+ const bend = Number(w.bend) || 0;
341
+ const horizontal = Number(w.horizontal) || 0;
342
+ const vertical = Number(w.vertical) || 0;
343
+ if (bend === 0 && horizontal === 0 && vertical === 0)
344
+ return null;
345
+ return { style, bend, horizontal, vertical, rotate: w.rotate === 'vertical' ? 'vertical' : 'horizontal' };
346
+ };
347
+ /** 源位图窗口 → 前向重采样格点。窗口是源位图的墨迹裁剪(参数区间 [u0,u1]×[v0,v1]
348
+ * 覆盖出盒墨迹的 Bernstein 外推),affine 把网格盒空间合成到输出像素空间
349
+ * (fabric Mat 列向量约定)。源像素 = fraction × sourceSize(窗口即整张源位图)。 */
350
+ export const buildWarpSurfaceGridOverWindow = (mesh, boxLeft, boxTop, boxRight, boxBottom, windowLeft, windowTop, windowRight, windowBottom, sourceWidth, sourceHeight, affine, maxCellDocPixels, maxCells) => {
351
+ const boxWidth = boxRight - boxLeft;
352
+ const boxHeight = boxBottom - boxTop;
353
+ const windowWidth = windowRight - windowLeft;
354
+ const windowHeight = windowBottom - windowTop;
355
+ if (boxWidth <= 0 || boxHeight <= 0 || windowWidth <= 0 || windowHeight <= 0 || sourceWidth <= 0 || sourceHeight <= 0 || maxCellDocPixels <= 0 || mesh.xs.length === 0) {
356
+ return undefined;
357
+ }
358
+ const u0 = (windowLeft - boxLeft) / boxWidth;
359
+ const u1 = (windowRight - boxLeft) / boxWidth;
360
+ const v0 = (windowTop - boxTop) / boxHeight;
361
+ const v1 = (windowBottom - boxTop) / boxHeight;
362
+ const mapPoint = (u, v) => {
363
+ const surface = evaluateWarpMesh(mesh, u, v);
364
+ return {
365
+ x: affine[0] * surface.x + affine[2] * surface.y + affine[4],
366
+ y: affine[1] * surface.x + affine[3] * surface.y + affine[5]
367
+ };
368
+ };
369
+ // 探针趟:由变形后窗口的输出范围定格点密度( Bernstein 外推干净覆盖出盒墨迹)
370
+ let minX = 0;
371
+ let maxX = 0;
372
+ let minY = 0;
373
+ let maxY = 0;
374
+ let firstProbe = true;
375
+ const probe = 8;
376
+ for (let row = 0; row <= probe; row++) {
377
+ const v = v0 + ((v1 - v0) * row) / probe;
378
+ for (let column = 0; column <= probe; column++) {
379
+ const u = u0 + ((u1 - u0) * column) / probe;
380
+ const doc = mapPoint(u, v);
381
+ if (firstProbe) {
382
+ minX = maxX = doc.x;
383
+ minY = maxY = doc.y;
384
+ firstProbe = false;
385
+ }
386
+ else {
387
+ minX = Math.min(minX, doc.x);
388
+ maxX = Math.max(maxX, doc.x);
389
+ minY = Math.min(minY, doc.y);
390
+ maxY = Math.max(maxY, doc.y);
391
+ }
392
+ }
393
+ }
394
+ const clampCells = Math.max(8, maxCells);
395
+ const cellsX = Math.min(clampCells, Math.max(8, Math.ceil((maxX - minX) / maxCellDocPixels)));
396
+ const cellsY = Math.min(clampCells, Math.max(8, Math.ceil((maxY - minY) / maxCellDocPixels)));
397
+ const grid = { columns: cellsX + 1, rows: cellsY + 1, docXs: [], docYs: [], sourceXs: [], sourceYs: [] };
398
+ for (let row = 0; row < grid.rows; row++) {
399
+ const fractionV = row / cellsY;
400
+ for (let column = 0; column < grid.columns; column++) {
401
+ const fractionU = column / cellsX;
402
+ const doc = mapPoint(u0 + (u1 - u0) * fractionU, v0 + (v1 - v0) * fractionV);
403
+ grid.docXs.push(doc.x);
404
+ grid.docYs.push(doc.y);
405
+ grid.sourceXs.push(fractionU * sourceWidth);
406
+ grid.sourceYs.push(fractionV * sourceHeight);
407
+ }
408
+ }
409
+ return grid;
410
+ };
411
+ /** 闭式逆双线性:解 p(s,t) = (1-s)(1-t)p00 + s(1-t)p10 + st·p11 + (1-s)t·p01 = (x,y)。
412
+ * 叉积消 t 得 s 的一元二次;无解(点在格外)返回 undefined。 */
413
+ export const invertBilinearCell = (x, y, x00, y00, x10, y10, x11, y11, x01, y01) => {
414
+ const ax = x10 - x00;
415
+ const ay = y10 - y00;
416
+ const bx = x01 - x00;
417
+ const by = y01 - y00;
418
+ const cx = x00 - x10 - x01 + x11;
419
+ const cy = y00 - y10 - y01 + y11;
420
+ const dx = x - x00;
421
+ const dy = y - y00;
422
+ const k2 = ax * cy - ay * cx;
423
+ const k1 = ax * by - ay * bx - (dx * cy - dy * cx);
424
+ const k0 = -(dx * by - dy * bx);
425
+ let s;
426
+ if (Math.abs(k2) < CELL_EPSILON) {
427
+ if (Math.abs(k1) < CELL_EPSILON)
428
+ return undefined;
429
+ s = -k0 / k1;
430
+ }
431
+ else {
432
+ const discriminant = k1 * k1 - 4 * k2 * k0;
433
+ if (discriminant < 0)
434
+ return undefined;
435
+ const root = Math.sqrt(discriminant);
436
+ const s0 = (-k1 + root) / (2 * k2);
437
+ const s1 = (-k1 - root) / (2 * k2);
438
+ const s0Valid = s0 >= -CELL_EPSILON && s0 <= 1 + CELL_EPSILON;
439
+ const s1Valid = s1 >= -CELL_EPSILON && s1 <= 1 + CELL_EPSILON;
440
+ if (s0Valid && s1Valid) {
441
+ s = Math.min(Math.max(s0, 0), 1);
442
+ }
443
+ else if (s0Valid) {
444
+ s = s0;
445
+ }
446
+ else if (s1Valid) {
447
+ s = s1;
448
+ }
449
+ else {
450
+ return undefined;
451
+ }
452
+ }
453
+ const tx = bx + cx * s;
454
+ const ty = by + cy * s;
455
+ let t;
456
+ if (Math.abs(tx) >= Math.abs(ty)) {
457
+ if (Math.abs(tx) < CELL_EPSILON)
458
+ return undefined;
459
+ t = (dx - ax * s) / tx;
460
+ }
461
+ else {
462
+ if (Math.abs(ty) < CELL_EPSILON)
463
+ return undefined;
464
+ t = (dy - ay * s) / ty;
465
+ }
466
+ if (s < -CELL_EPSILON || s > 1 + CELL_EPSILON || t < -CELL_EPSILON || t > 1 + CELL_EPSILON)
467
+ return undefined;
468
+ return { s: Math.min(Math.max(s, 0), 1), t: Math.min(Math.max(t, 0), 1) };
469
+ };
@@ -72,11 +72,16 @@ export interface SvgTextBitmap {
72
72
  /** 逻辑尺寸(quad 居中于对象中心——渲染 pushQuad 同构) */
73
73
  width: number;
74
74
  height: number;
75
+ /** 画布中心相对对象中心的逻辑偏移(批次 365 PSD 变形族:变形输出窗一般不对称
76
+ * 于对象中心;缺省 = 恒居中——arch 族等既有约定不变) */
77
+ offsetX?: number;
78
+ offsetY?: number;
75
79
  }
76
80
  /** 文本位图烘焙注入的族分派:warp 三族(变形本体位图化,无条件)、arc/circle
77
81
  * (bakeArcText)、vertical/plain(bakeTextEffects——仅带活跃特效时位图化,
78
- * 无特效返 null 走矢量)。null = 不可烘焙/无需位图,序列化器回退矢量路径。 */
79
- export type SvgTextBitmapFamily = 'arch' | 'waist' | 'flag' | 'arc' | 'circle' | 'vertical' | 'plain';
82
+ * 无特效返 null 走矢量)、psd(批次 365 bakePsdWarpText——PSD 变形文本无条件
83
+ * 位图化)。null = 不可烘焙/无需位图,序列化器回退矢量路径。 */
84
+ export type SvgTextBitmapFamily = 'arch' | 'waist' | 'flag' | 'arc' | 'circle' | 'vertical' | 'plain' | 'psd';
80
85
  export type SvgTextBitmapBaker = (raw: Record<string, unknown>, family: SvgTextBitmapFamily) => SvgTextBitmap | null;
81
86
  /** 一次导出运行的级配置(实例构造期给定,跨页共享) */
82
87
  export interface SvgExporterOptions {
@@ -159,9 +164,10 @@ export declare class SvgExporter {
159
164
  private emitShadowFilter;
160
165
  /** clipPath 形状 → defs;不支持形态返回 null(调用方 skip 节点) */
161
166
  private emitClipPath;
162
- /** 位图文本发射公共件:image 中心锚定(logicalW×H——渲染 pushQuad 同构)+
163
- * fabric 阴影 feDropShadow(位图不含 PSD 体系外的 raw.shadow)+ textScale
164
- * 绕中心缩放(emitText 家族语义级缩放同款) */
167
+ /** 位图文本发射公共件:image 中心锚定(logicalW×H——渲染 pushQuad 同构;
168
+ * PSD 变形族带 offsetX/Y 中心偏移——渲染侧同源)+ fabric 阴影 feDropShadow
169
+ * (位图不含 PSD 体系外的 raw.shadow)+ textScale 绕中心缩放(emitText
170
+ * 家族语义级缩放同款) */
165
171
  private emitBakedTextImage;
166
172
  private emitText;
167
173
  /**
@@ -36,6 +36,7 @@
36
36
  * 供 e2e/排障区分引擎产物与 fabric 产物。
37
37
  */
38
38
  import { gradientSpaceMatrix, parseGradientDecl } from '../core/gradient';
39
+ import { activePsdTextWarp } from '../core/warpMesh';
39
40
  import { invert, multiply, objectOwnMatrix } from '../core/mat2d';
40
41
  import { parsePathData } from '../core/pathData';
41
42
  import { computeTableLayout } from '../model/tableLayout';
@@ -710,16 +711,19 @@ export class SvgExporter {
710
711
  this.defs.push(`<clipPath id="${id}">${geometryElement(geometry, m, '')}</clipPath>`);
711
712
  return ` clip-path="url(#${id})"`;
712
713
  }
713
- /** 位图文本发射公共件:image 中心锚定(logicalW×H——渲染 pushQuad 同构)+
714
- * fabric 阴影 feDropShadow(位图不含 PSD 体系外的 raw.shadow)+ textScale
715
- * 绕中心缩放(emitText 家族语义级缩放同款) */
714
+ /** 位图文本发射公共件:image 中心锚定(logicalW×H——渲染 pushQuad 同构;
715
+ * PSD 变形族带 offsetX/Y 中心偏移——渲染侧同源)+ fabric 阴影 feDropShadow
716
+ * (位图不含 PSD 体系外的 raw.shadow)+ textScale 绕中心缩放(emitText
717
+ * 家族语义级缩放同款) */
716
718
  emitBakedTextImage(raw, baked) {
717
719
  const shadow = parseShadow(raw);
718
720
  if (shadow === undefined) {
719
721
  this.skip('shadow-unsupported');
720
722
  return null;
721
723
  }
722
- let out = `<image href="${escapeXml(baked.dataUrl)}" xlink:href="${escapeXml(baked.dataUrl)}" x="${fmt(-baked.width / 2)}" y="${fmt(-baked.height / 2)}" width="${fmt(baked.width)}" height="${fmt(baked.height)}"/>`;
724
+ const x0 = -baked.width / 2 + (baked.offsetX ?? 0);
725
+ const y0 = -baked.height / 2 + (baked.offsetY ?? 0);
726
+ let out = `<image href="${escapeXml(baked.dataUrl)}" xlink:href="${escapeXml(baked.dataUrl)}" x="${fmt(x0)}" y="${fmt(y0)}" width="${fmt(baked.width)}" height="${fmt(baked.height)}"/>`;
723
727
  if (shadow)
724
728
  out = `<g filter="url(#${this.emitShadowFilter(shadow)})">${out}</g>`;
725
729
  const tsx = num(raw, 'textScaleX', 1) || 1;
@@ -738,6 +742,15 @@ export class SvgExporter {
738
742
  const warp = warpKindOf(raw);
739
743
  if (warp)
740
744
  return this.emitWarpedText(raw, warp);
745
+ // 批次 365 PSD 变形文本:转正态(renderSrc 已删,位图 <image> 分支不再命中)
746
+ // 的 psdWarp 无条件位图化;烘焙失败/注入缺省回退下方常规矢量管线(内容
747
+ // 保留、变形丢失——warp 族「烘焙失败特效丢失」同族登记近似)
748
+ if (activePsdTextWarp(raw)) {
749
+ const baked = this.options.bakeTextBitmap?.(raw, 'psd') ?? null;
750
+ if (baked)
751
+ return this.emitBakedTextImage(raw, baked);
752
+ this.skip('text-psdwarp-bitmap-fallback');
753
+ }
741
754
  const width = num(raw, 'width', NaN);
742
755
  const height = num(raw, 'height', NaN);
743
756
  if (!Number.isFinite(width) || !Number.isFinite(height)) {
package/dist/index.d.ts CHANGED
@@ -52,6 +52,9 @@ export { bakeArcText, glyphStyleOf, type ArcBake } from './render/arcText';
52
52
  export { planTextHighlight, type TextsSegmentLike } from './render/textHighlight';
53
53
  export { glyphStyleAt, verticalGlyphOps } from './render/verticalText';
54
54
  export { bakeWarpedText, bakeTextEffects, type WarpBake, type WarpKind } from './render/warpText';
55
+ export { renderTextRuns, renderVerticalRuns, compositeWarpEffects } from './render/warpText';
56
+ export { bakePsdWarpText, type PsdWarpBake } from './render/psdWarpText';
57
+ export { activePsdTextWarp, generatePsdWarpMesh, generateStyleWarpMesh, applyWarpDistortion, buildWarpSurfaceGridOverWindow, identityWarpMesh, evaluateWarpMesh, invertBilinearCell, isGeneratableWarpStyle, type PsdTextWarpParams, type WarpMeshGrid, type WarpSurfaceGrid } from './core/warpMesh';
55
58
  export { type CharContour, type CharTransformation, type Abortable, type TDegree, type TMat2D, type TOriginX, type TOriginY, type TRadian, type XY } from './model/schema';
56
59
  export type { SerializedBaseProps, SerializedGradientProps, SerializedPatternProps, SerializedFillerProps, SerializedShadowProps, SerializedFillStrokeProps, SerializedClipPathProps, SerializedObjectPropsBase, SerializedCrossOrigin, SerializedImagePropsBase, SerializedLayoutManagerProps, SerializedGroupPropsBase, ImagePropsBase, GroupPropsBase, SchemaTextStyleDeclaration, SchemaTextStyle, SerializedTextPropsBase, SerializedITextPropsBase, SerializedTextboxPropsBase, SerializedArcTextPropsBase, SerializedRectPropsBase, SerializedLinePropsBase, SerializedPathPropsBase, SerializedMaskPropsBase, SerializedGifPropsBase, PatternOptions } from './model/schema';
57
60
  export type { TClassProperties, TCornerPoint, ObjectRef, TextStyleDeclaration, CompleteTextStyleDeclaration, TextStyle, TSize, ITextProps, SerializedRectProps, TBBox, TComplexPathData, TOptions, RectProps, TextboxProps, ImageFormat } from './model/fabricPrimitives';
package/dist/index.js CHANGED
@@ -54,3 +54,6 @@ export { bakeArcText, glyphStyleOf } from './render/arcText';
54
54
  export { planTextHighlight } from './render/textHighlight';
55
55
  export { glyphStyleAt, verticalGlyphOps } from './render/verticalText';
56
56
  export { bakeWarpedText, bakeTextEffects } from './render/warpText';
57
+ export { renderTextRuns, renderVerticalRuns, compositeWarpEffects } from './render/warpText';
58
+ export { bakePsdWarpText } from './render/psdWarpText';
59
+ export { activePsdTextWarp, generatePsdWarpMesh, generateStyleWarpMesh, applyWarpDistortion, buildWarpSurfaceGridOverWindow, identityWarpMesh, evaluateWarpMesh, invertBilinearCell, isGeneratableWarpStyle } from './core/warpMesh';
@@ -5,6 +5,7 @@ import { imageFiltersKey, parseImageFilters } from '../core/imageFilters';
5
5
  import { imageCornerRadius, rectCornerRadii } from '../core/roundedRect';
6
6
  import { AnimatedNode, GroupNode, MaskNode, PuzzleNode, rasterMaskSrc, textBitmapFillAlpha } from '../model/scene';
7
7
  import { warpTextKind } from './warpText';
8
+ import { activePsdTextWarp } from '../core/warpMesh';
8
9
  import { arcTextKind } from '../model/arcLayout';
9
10
  import { GLIsolator } from './GLIsolate';
10
11
  import { GLBlender } from './GLBlend';
@@ -319,6 +320,15 @@ export class SceneRenderer {
319
320
  this.text.renderWarpedText(node, warp);
320
321
  return;
321
322
  }
323
+ // 批次 365 PSD 文字变形:分派序在 renderSrc 位图(上分支)与 warp 三族之后
324
+ // ——TextImage 编辑转正(防线删 renderSrc、type 落 Textbox)后 raw.psdWarp
325
+ // 仍在场 → 参数化网格变形接管(「编辑后仍保持变形」);纯文本回退层带
326
+ // psdWarp 立即原生变形。被编辑的本节点走常规管线(PS 同构:编辑未变形文本)
327
+ const psdWarp = activePsdTextWarp(node.raw);
328
+ if (psdWarp && node !== this.host.editingNode) {
329
+ this.text.renderPsdWarpedText(node, psdWarp);
330
+ return;
331
+ }
322
332
  // P4-5b 弧形/圆形文本:ArcText/CircleText 逐字摆位(curvature=0 也走摆位
323
333
  // 机——radius=1e5 的近直渲染);双实现(GPU 批次 4)——逐字图集 quad /
324
334
  // 整图烘焙,zoom×dpr 供桶分派。被编辑的本节点走常规管线。分派在
@@ -8,6 +8,7 @@
8
8
  * 不可做模块级缓存。编辑态门控(变形文本在编辑中走常规管线)留在
9
9
  * SceneRenderer 的分派分支。
10
10
  */
11
+ import type { PsdTextWarpParams } from '../core/warpMesh';
11
12
  import type { SceneNode, TextNode } from '../model/scene';
12
13
  import { GlyphAtlas } from './GlyphAtlas';
13
14
  import { QuadBatch } from './QuadBatch';
@@ -19,6 +20,9 @@ export declare class TextRenderer {
19
20
  private readonly glyphAtlas;
20
21
  /** 变形文本烘焙缓存(P4-5a:节点 → {sig, tex, w, h}) */
21
22
  private warpBakes;
23
+ /** PSD 变形文本烘焙缓存(批次 365:节点 → {sig, tex, w, h, offX, offY}——
24
+ * 变形输出窗一般不对称于对象中心,quad 定位携带中心偏移) */
25
+ private psdWarpBakes;
22
26
  /** 弧形/圆形文本烘焙缓存(P4-5b:节点 → {sig, tex, w, h}) */
23
27
  private arcBakes;
24
28
  /** 虚线文本描边烘焙缓存(run 级栅格化;签名 = 文本+布局+描边+桶) */
@@ -38,6 +42,14 @@ export declare class TextRenderer {
38
42
  invalidateNodeBakes(node: SceneNode): void;
39
43
  /** 变形文本渲染(P4-5a):烘焙整图 quad(logicalW×logicalH 居中于对象中心) */
40
44
  renderWarpedText(node: TextNode, kind: WarpKind): void;
45
+ /**
46
+ * PSD 变形文本渲染(批次 365):renderSrc 位图优先链的编辑后承接——转正防线
47
+ * 删 renderSrc 后 raw.psdWarp 在场 → 布局盒重排 + 15 样式网格变形烘焙单 quad
48
+ * (bakePsdWarpText:Patchy 前向格点 + 逐 cell 逆双线性)。签名键与 warp 族
49
+ * 同源 + psdWarp 参数 JSON + 排版扩展键(charSpacing/lineHeight/vertical——
50
+ * 转正后重排的文本这些键都会改墨迹)。
51
+ */
52
+ renderPsdWarpedText(node: TextNode, params: PsdTextWarpParams): void;
41
53
  /**
42
54
  * 弧形/圆形文本渲染(P4-5b):双实现分发(GPU 迁移批次 4)——
43
55
  * 逐字图集 quad(缩放桶重栅格化,放大始终清晰)/ 整图烘焙 quad(Canvas 参考
@@ -9,7 +9,7 @@
9
9
  * SceneRenderer 的分派分支。
10
10
  */
11
11
  import { parseColor } from '../core/color';
12
- import { multiply } from '../core/mat2d';
12
+ import { composeMatrix, multiply } from '../core/mat2d';
13
13
  import { parsePsdEffects, psdEffectsKey } from '../core/psdEffects';
14
14
  import { isArcGlyphEnabled } from '../engineFlag';
15
15
  import { charJitterY, drawParagraphPrefix, fontDeclaration, graphemeSplit, lineDecorationRuns, maxCharJitterY, resolveStrokeDecl, verticalAnchorShiftX, verticalAnchorShiftY, verticalCharClass, verticalRenderAdvance } from '../model/textLayout';
@@ -18,6 +18,7 @@ import { bakeScrollText, scrollTextDecl } from './scrollText';
18
18
  import { bakeTextHighlight, planTextHighlight } from './textHighlight';
19
19
  import { drawVerticalGlyph, glyphStyleAt, verticalGlyphOps } from './verticalText';
20
20
  import { bakeWarpedText } from './warpText';
21
+ import { bakePsdWarpText } from './psdWarpText';
21
22
  import { bakeArcText, glyphStyleOf } from './arcText';
22
23
  import { computeArcTextLayout } from '../model/arcLayout';
23
24
  import { createTexture2D } from './textureUpload';
@@ -50,6 +51,9 @@ export class TextRenderer {
50
51
  glyphAtlas;
51
52
  /** 变形文本烘焙缓存(P4-5a:节点 → {sig, tex, w, h}) */
52
53
  warpBakes = new WeakMap();
54
+ /** PSD 变形文本烘焙缓存(批次 365:节点 → {sig, tex, w, h, offX, offY}——
55
+ * 变形输出窗一般不对称于对象中心,quad 定位携带中心偏移) */
56
+ psdWarpBakes = new WeakMap();
53
57
  /** 弧形/圆形文本烘焙缓存(P4-5b:节点 → {sig, tex, w, h}) */
54
58
  arcBakes = new WeakMap();
55
59
  /** 虚线文本描边烘焙缓存(run 级栅格化;签名 = 文本+布局+描边+桶) */
@@ -71,7 +75,7 @@ export class TextRenderer {
71
75
  * 烘焙随节点 GC,与既有 sig 更换/删除路径同语义)。
72
76
  */
73
77
  invalidateNodeBakes(node) {
74
- for (const bakes of [this.warpBakes, this.arcBakes, this.textDashBakes, this.scrollBakes, this.highlightBakes]) {
78
+ for (const bakes of [this.warpBakes, this.psdWarpBakes, this.arcBakes, this.textDashBakes, this.scrollBakes, this.highlightBakes]) {
75
79
  const bake = bakes.get(node);
76
80
  if (bake?.tex)
77
81
  this.gl.deleteTexture(bake.tex);
@@ -119,6 +123,55 @@ export class TextRenderer {
119
123
  }
120
124
  this.batch.pushQuad(node.matrix, bake.w, bake.h, [1, 1, 1, node.renderOpacity], bake.tex);
121
125
  }
126
+ /**
127
+ * PSD 变形文本渲染(批次 365):renderSrc 位图优先链的编辑后承接——转正防线
128
+ * 删 renderSrc 后 raw.psdWarp 在场 → 布局盒重排 + 15 样式网格变形烘焙单 quad
129
+ * (bakePsdWarpText:Patchy 前向格点 + 逐 cell 逆双线性)。签名键与 warp 族
130
+ * 同源 + psdWarp 参数 JSON + 排版扩展键(charSpacing/lineHeight/vertical——
131
+ * 转正后重排的文本这些键都会改墨迹)。
132
+ */
133
+ renderPsdWarpedText(node, params) {
134
+ const fxDecls = parsePsdEffects(node.raw.effects, { text: true });
135
+ const sig = [
136
+ node.raw.type,
137
+ node.raw.text,
138
+ JSON.stringify(node.raw.psdWarp ?? null),
139
+ node.raw.fontSize,
140
+ node.raw.fontFamily,
141
+ node.raw.fontWeight,
142
+ node.raw.fontStyle,
143
+ node.raw.width,
144
+ node.raw.height,
145
+ node.raw.lineHeight,
146
+ node.raw.charSpacing,
147
+ node.raw.vertical === true ? 1 : 0,
148
+ node.raw.fill,
149
+ node.raw.stroke,
150
+ node.raw.strokeWidth,
151
+ JSON.stringify(node.raw.styles ?? null),
152
+ JSON.stringify(node.raw.paragraph ?? null),
153
+ fxDecls ? psdEffectsKey(fxDecls) : ''
154
+ ].join(';');
155
+ let bake = this.psdWarpBakes.get(node);
156
+ if (bake && bake.sig !== sig) {
157
+ this.gl.deleteTexture(bake.tex);
158
+ bake = undefined;
159
+ }
160
+ if (!bake) {
161
+ const result = bakePsdWarpText(node, params, fxDecls);
162
+ if (!result) {
163
+ this.psdWarpBakes.set(node, undefined);
164
+ return;
165
+ }
166
+ const tex = createTexture2D(this.gl, result.canvas);
167
+ if (!tex)
168
+ return;
169
+ bake = { sig, tex, w: result.logicalW, h: result.logicalH, offX: result.offsetX, offY: result.offsetY };
170
+ this.psdWarpBakes.set(node, bake);
171
+ }
172
+ const m = bake.offX !== 0 || bake.offY !== 0 ? multiply(node.matrix, composeMatrix({ translateX: bake.offX, translateY: bake.offY })) : node.matrix;
173
+ this.batch.pushQuad(m, bake.w, bake.h, [1, 1, 1, node.renderOpacity], bake.tex);
174
+ }
122
175
  /**
123
176
  * 弧形/圆形文本渲染(P4-5b):双实现分发(GPU 迁移批次 4)——
124
177
  * 逐字图集 quad(缩放桶重栅格化,放大始终清晰)/ 整图烘焙 quad(Canvas 参考
@@ -0,0 +1,28 @@
1
+ /**
2
+ * PSD 文字变形(Warp Text)CPU 烘焙(批次 365)——core/warpMesh 的 15 样式控制
3
+ * 网格 × Patchy「前向格点 + 逐 cell 闭式逆双线性」重采样(4px 提交级 cell,
4
+ * first-writer-wins 折叠语义)。
5
+ *
6
+ * 消费链(SceneRenderer 分派序):TextImage 位图态 renderSrc 单 quad 优先(导入
7
+ * 保真)→ 编辑转正防线删 renderSrc 后 raw.psdWarp 在场 → 本件接管(「编辑后仍
8
+ * 保持变形」);纯文本回退层(导入无图层像素)带 psdWarp 立即原生变形。变形作用
9
+ * 于布局盒(PS bounds 盒语义——PS 每次重排自行重推盒,本件同样按节点当前盒实时
10
+ * 求值不落盘);重采样窗口裁到墨迹(Patchy wt_* 同款——近空盒的 Bernstein 外推
11
+ * 会把格点分辨率饿死在墨迹之外)。
12
+ *
13
+ * 脚手架与 render/warpText.ts 同源:run 渲染(CACHE_DPR=2 中心原点系)+ PSD 特效
14
+ * 合成(compositeWarpEffects)→ alpha>10 墨迹扫描 → 网格变形重采样 → putImageData。
15
+ * 输出 = 变形窗口外接矩形 + 画布中心相对对象中心的逻辑偏移(变形输出窗一般不对称
16
+ * 于对象中心——quad/SVG 定位须携带,arch 族的恒居中约定在此不成立)。
17
+ */
18
+ import { type PsdTextWarpParams } from '../core/warpMesh';
19
+ import type { TextNode } from '../model/scene';
20
+ import type { PsdEffectsDecls } from '../core/psdEffects';
21
+ import { type WarpBake } from './warpText';
22
+ /** PSD 变形烘焙产物:WarpBake 契约 + 输出窗中心的逻辑偏移(quad 定位用) */
23
+ export interface PsdWarpBake extends WarpBake {
24
+ offsetX: number;
25
+ offsetY: number;
26
+ }
27
+ /** PSD 变形文本整图烘焙(输出窗 = 变形后墨迹范围 + 1px AA 余量,中心偏移随行) */
28
+ export declare const bakePsdWarpText: (node: TextNode, params: PsdTextWarpParams, decls?: PsdEffectsDecls | null) => PsdWarpBake | null;
@@ -0,0 +1,212 @@
1
+ /**
2
+ * PSD 文字变形(Warp Text)CPU 烘焙(批次 365)——core/warpMesh 的 15 样式控制
3
+ * 网格 × Patchy「前向格点 + 逐 cell 闭式逆双线性」重采样(4px 提交级 cell,
4
+ * first-writer-wins 折叠语义)。
5
+ *
6
+ * 消费链(SceneRenderer 分派序):TextImage 位图态 renderSrc 单 quad 优先(导入
7
+ * 保真)→ 编辑转正防线删 renderSrc 后 raw.psdWarp 在场 → 本件接管(「编辑后仍
8
+ * 保持变形」);纯文本回退层(导入无图层像素)带 psdWarp 立即原生变形。变形作用
9
+ * 于布局盒(PS bounds 盒语义——PS 每次重排自行重推盒,本件同样按节点当前盒实时
10
+ * 求值不落盘);重采样窗口裁到墨迹(Patchy wt_* 同款——近空盒的 Bernstein 外推
11
+ * 会把格点分辨率饿死在墨迹之外)。
12
+ *
13
+ * 脚手架与 render/warpText.ts 同源:run 渲染(CACHE_DPR=2 中心原点系)+ PSD 特效
14
+ * 合成(compositeWarpEffects)→ alpha>10 墨迹扫描 → 网格变形重采样 → putImageData。
15
+ * 输出 = 变形窗口外接矩形 + 画布中心相对对象中心的逻辑偏移(变形输出窗一般不对称
16
+ * 于对象中心——quad/SVG 定位须携带,arch 族的恒居中约定在此不成立)。
17
+ */
18
+ import { buildWarpSurfaceGridOverWindow, evaluateWarpMesh, generatePsdWarpMesh, invertBilinearCell } from '../core/warpMesh';
19
+ import { compositeWarpEffects, renderTextRuns, renderVerticalRuns, warpEffectExtentPad } from './warpText';
20
+ const CACHE_DPR = 2;
21
+ /** 提交级 cell 尺寸(逻辑像素 ×CACHE_DPR——Patchy bake_warp_into_layer 同款 4px) */
22
+ const MAX_CELL_DOC_PIXELS = 4 * CACHE_DPR;
23
+ const MAX_CELLS = 384;
24
+ /** 探针趟:窗口参数区间经网格前向映射 + 盒→源画布仿射后的输出范围(设备像素) */
25
+ const probeOutputExtent = (mesh, u0, u1, v0, v1, meshToSource) => {
26
+ let minX = Infinity;
27
+ let maxX = -Infinity;
28
+ let minY = Infinity;
29
+ let maxY = -Infinity;
30
+ const probe = 8;
31
+ for (let row = 0; row <= probe; row++) {
32
+ const v = v0 + ((v1 - v0) * row) / probe;
33
+ for (let column = 0; column <= probe; column++) {
34
+ const u = u0 + ((u1 - u0) * column) / probe;
35
+ const surface = evaluateWarpMesh(mesh, u, v);
36
+ const x = meshToSource[0] * surface.x + meshToSource[2] * surface.y + meshToSource[4];
37
+ const y = meshToSource[1] * surface.x + meshToSource[3] * surface.y + meshToSource[5];
38
+ minX = Math.min(minX, x);
39
+ maxX = Math.max(maxX, x);
40
+ minY = Math.min(minY, y);
41
+ maxY = Math.max(maxY, y);
42
+ }
43
+ }
44
+ return { minX, maxX, minY, maxY };
45
+ };
46
+ /** PSD 变形文本整图烘焙(输出窗 = 变形后墨迹范围 + 1px AA 余量,中心偏移随行) */
47
+ export const bakePsdWarpText = (node, params, decls = null) => {
48
+ const layout = node.textLayout;
49
+ const fontSize = Number(node.raw.fontSize) || 40;
50
+ const boxW = typeof node.raw.width === 'number' ? node.raw.width : layout.width;
51
+ const boxH = typeof node.raw.height === 'number' ? node.raw.height : layout.height;
52
+ if (!(boxW > 0) || !(boxH > 0))
53
+ return null;
54
+ const padding = fontSize * 0.6;
55
+ const baseTextWidth = Math.max(layout.width, boxW, fontSize);
56
+ const baseTextHeight = Math.max(boxH, fontSize);
57
+ const fxPad = decls ? warpEffectExtentPad(decls) : 0;
58
+ const sourceW = Math.ceil(baseTextWidth + padding * 2 + fxPad * 2);
59
+ const sourceH = Math.ceil(baseTextHeight + padding * 2 + fxPad * 2);
60
+ const cacheW = sourceW * CACHE_DPR;
61
+ const cacheH = sourceH * CACHE_DPR;
62
+ if (!(cacheW > 0) || !(cacheH > 0) || cacheW > 8192 || cacheH > 8192)
63
+ return null;
64
+ const mesh = generatePsdWarpMesh(params, boxW, boxH);
65
+ if (!mesh)
66
+ return null;
67
+ // 源渲染:中心原点系 ×CACHE_DPR(盒居中于画布中心——对象中心即画布中心)
68
+ const canvas = document.createElement('canvas');
69
+ canvas.width = cacheW;
70
+ canvas.height = cacheH;
71
+ const ctx = canvas.getContext('2d', { willReadFrequently: true });
72
+ if (!ctx)
73
+ return null;
74
+ ctx.setTransform(CACHE_DPR, 0, 0, CACHE_DPR, cacheW / 2, cacheH / 2);
75
+ if (node.raw.vertical === true)
76
+ renderVerticalRuns(ctx, node);
77
+ else
78
+ renderTextRuns(ctx, node);
79
+ compositeWarpEffects(ctx, node, decls);
80
+ // 墨迹扫描(alpha > 10,warpText 同阈值)——重采样窗口裁到墨迹
81
+ const img = ctx.getImageData(0, 0, cacheW, cacheH);
82
+ const px = new Uint32Array(img.data.buffer);
83
+ let minX = cacheW;
84
+ let maxX = 0;
85
+ let minY = cacheH;
86
+ let maxY = 0;
87
+ let hasText = false;
88
+ for (let row = 0; row < cacheH; row++) {
89
+ for (let col = 0; col < cacheW; col++) {
90
+ if (((px[row * cacheW + col] >>> 24) & 0xff) > 10) {
91
+ hasText = true;
92
+ if (col < minX)
93
+ minX = col;
94
+ if (col > maxX)
95
+ maxX = col;
96
+ if (row < minY)
97
+ minY = row;
98
+ if (row > maxY)
99
+ maxY = row;
100
+ }
101
+ }
102
+ }
103
+ if (!hasText)
104
+ return null;
105
+ const srcX0 = minX;
106
+ const srcY0 = minY;
107
+ const srcW = maxX + 1 - minX;
108
+ const srcH = maxY + 1 - minY;
109
+ // 盒(mesh 空间 [0,boxW]×[0,boxH])→ 源画布设备像素的仿射(盒居中于画布)
110
+ const cx0 = ((sourceW - boxW) / 2) * CACHE_DPR;
111
+ const cy0 = ((sourceH - boxH) / 2) * CACHE_DPR;
112
+ const meshToSource = [CACHE_DPR, 0, 0, CACHE_DPR, cx0, cy0];
113
+ // 墨迹窗口(源设备像素)→ mesh 参数区间(可越 [0,1]——Bernstein 外推覆盖出盒墨迹)
114
+ const windowLeft = (srcX0 - cx0) / CACHE_DPR;
115
+ const windowRight = (srcX0 + srcW - cx0) / CACHE_DPR;
116
+ const windowTop = (srcY0 - cy0) / CACHE_DPR;
117
+ const windowBottom = (srcY0 + srcH - cy0) / CACHE_DPR;
118
+ const u0 = windowLeft / boxW;
119
+ const u1 = windowRight / boxW;
120
+ const v0 = windowTop / boxH;
121
+ const v1 = windowBottom / boxH;
122
+ // 输出窗:变形后窗口的设备范围 + 1px AA 余量
123
+ const extent = probeOutputExtent(mesh, u0, u1, v0, v1, meshToSource);
124
+ const outLeft = Math.floor(extent.minX) - 1;
125
+ const outTop = Math.floor(extent.minY) - 1;
126
+ const outW = Math.max(1, Math.ceil(extent.maxX + 1) - outLeft);
127
+ const outH = Math.max(1, Math.ceil(extent.maxY + 1) - outTop);
128
+ if (outW > 8192 || outH > 8192)
129
+ return null;
130
+ // 格点仿射:mesh → 输出画布像素(源仿射平移 -outLeft/-outTop)
131
+ const grid = buildWarpSurfaceGridOverWindow(mesh, 0, 0, boxW, boxH, windowLeft, windowTop, windowRight, windowBottom, srcW, srcH, [CACHE_DPR, 0, 0, CACHE_DPR, cx0 - outLeft, cy0 - outTop], MAX_CELL_DOC_PIXELS, MAX_CELLS);
132
+ if (!grid)
133
+ return null;
134
+ // 逐 cell 光栅化:cell 四边形 bbox 内逐像素闭式逆双线性 → (s,t) → 源像素双线性
135
+ // 采样;first-writer-wins(折叠处首写者胜,Patchy resample_warped_rgba8 同语义)
136
+ const out = ctx.createImageData(outW, outH);
137
+ const outPx = new Uint32Array(out.data.buffer);
138
+ const covered = new Uint8Array(outW * outH);
139
+ const sample = (fx, fy) => {
140
+ const x = Math.min(srcW - 1, Math.max(0, fx));
141
+ const y = Math.min(srcH - 1, Math.max(0, fy));
142
+ const x0 = Math.floor(x);
143
+ const y0 = Math.floor(y);
144
+ const x1 = Math.min(srcW - 1, x0 + 1);
145
+ const y1 = Math.min(srcH - 1, y0 + 1);
146
+ const tx = x - x0;
147
+ const ty = y - y0;
148
+ const a = px[(srcY0 + y0) * cacheW + (srcX0 + x0)];
149
+ const b = px[(srcY0 + y0) * cacheW + (srcX0 + x1)];
150
+ const c = px[(srcY0 + y1) * cacheW + (srcX0 + x1)];
151
+ const d = px[(srcY0 + y1) * cacheW + (srcX0 + x0)];
152
+ const aA = (a >>> 24) & 0xff;
153
+ const bA = (b >>> 24) & 0xff;
154
+ const cA = (c >>> 24) & 0xff;
155
+ const dA = (d >>> 24) & 0xff;
156
+ if (aA <= 10 && bA <= 10 && cA <= 10 && dA <= 10)
157
+ return 0;
158
+ const lerp = (v0, v1, t) => v0 + (v1 - v0) * t;
159
+ const r = Math.round(lerp(lerp(a & 0xff, b & 0xff, tx), lerp(d & 0xff, c & 0xff, tx), ty));
160
+ const g = Math.round(lerp(lerp((a >>> 8) & 0xff, (b >>> 8) & 0xff, tx), lerp((d >>> 8) & 0xff, (c >>> 8) & 0xff, tx), ty));
161
+ const bl = Math.round(lerp(lerp((a >>> 16) & 0xff, (b >>> 16) & 0xff, tx), lerp((d >>> 16) & 0xff, (c >>> 16) & 0xff, tx), ty));
162
+ const al = Math.round(lerp(lerp(aA, bA, tx), lerp(dA, cA, tx), ty));
163
+ return (al << 24) | (bl << 16) | (g << 8) | r;
164
+ };
165
+ for (let row = 0; row + 1 < grid.rows; row++) {
166
+ for (let column = 0; column + 1 < grid.columns; column++) {
167
+ const i00 = row * grid.columns + column;
168
+ const i10 = i00 + 1;
169
+ const i01 = i00 + grid.columns;
170
+ const i11 = i01 + 1;
171
+ const x00 = grid.docXs[i00];
172
+ const y00 = grid.docYs[i00];
173
+ const x10 = grid.docXs[i10];
174
+ const y10 = grid.docYs[i10];
175
+ const x11 = grid.docXs[i11];
176
+ const y11 = grid.docYs[i11];
177
+ const x01 = grid.docXs[i01];
178
+ const y01 = grid.docYs[i01];
179
+ const cellMinX = Math.max(0, Math.floor(Math.min(x00, x10, x11, x01)));
180
+ const cellMaxX = Math.min(outW - 1, Math.ceil(Math.max(x00, x10, x11, x01)));
181
+ const cellMinY = Math.max(0, Math.floor(Math.min(y00, y10, y11, y01)));
182
+ const cellMaxY = Math.min(outH - 1, Math.ceil(Math.max(y00, y10, y11, y01)));
183
+ for (let py = cellMinY; py <= cellMaxY; py++) {
184
+ for (let pxCur = cellMinX; pxCur <= cellMaxX; pxCur++) {
185
+ const index = py * outW + pxCur;
186
+ if (covered[index])
187
+ continue;
188
+ const st = invertBilinearCell(pxCur + 0.5, py + 0.5, x00, y00, x10, y10, x11, y11, x01, y01);
189
+ if (!st)
190
+ continue;
191
+ covered[index] = 1;
192
+ const { s, t } = st;
193
+ // 源坐标 = 四角源坐标的双线性(格点源坐标即 fraction×size,规则网格)
194
+ const sx = (1 - s) * (1 - t) * grid.sourceXs[i00] + s * (1 - t) * grid.sourceXs[i10] + s * t * grid.sourceXs[i11] + (1 - s) * t * grid.sourceXs[i01];
195
+ const sy = (1 - s) * (1 - t) * grid.sourceYs[i00] + s * (1 - t) * grid.sourceYs[i10] + s * t * grid.sourceYs[i11] + (1 - s) * t * grid.sourceYs[i01];
196
+ outPx[index] = sample(sx, sy);
197
+ }
198
+ }
199
+ }
200
+ }
201
+ const outCanvas = document.createElement('canvas');
202
+ outCanvas.width = outW;
203
+ outCanvas.height = outH;
204
+ const outCtx = outCanvas.getContext('2d');
205
+ if (!outCtx)
206
+ return null;
207
+ outCtx.putImageData(out, 0, 0);
208
+ // 输出画布中心相对对象中心(源画布中心)的逻辑偏移
209
+ const offsetX = (outLeft + outW / 2) / CACHE_DPR - sourceW / 2;
210
+ const offsetY = (outTop + outH / 2) / CACHE_DPR - sourceH / 2;
211
+ return { canvas: outCanvas, logicalW: outW / CACHE_DPR, logicalH: outH / CACHE_DPR, offsetX, offsetY };
212
+ };
@@ -25,6 +25,9 @@ export declare const warpTextKind: (raw: {
25
25
  type?: unknown;
26
26
  warpStrength?: unknown;
27
27
  }) => WarpKind | null;
28
+ /** 文本 run(同样式连续段)逐 run 画到 ctx(中心原点本地系,×CACHE_DPR)。
29
+ * 批次 365 起导出:psdWarpText 烘焙复用(PSD 变形文本的未变形源渲染同脚手架) */
30
+ export declare const renderTextRuns: (ctx: CanvasRenderingContext2D, node: TextNode) => void;
28
31
  export interface WarpBake {
29
32
  canvas: HTMLCanvasElement;
30
33
  logicalW: number;
@@ -44,8 +47,18 @@ export declare const bakeWarpShadowLayer: (decls: PsdDropShadowDecl[], source: H
44
47
  w: number;
45
48
  h: number;
46
49
  } | null;
50
+ /** 变形特效合成(fabric _renderText 同序:投影垫底 → run 文本 → solidFill → stroke)。
51
+ * ctx 为变形烘焙画布上下文(中心原点本地系 ×CACHE_DPR);投影在 run 之后合成,
52
+ * 用 destination-over 落到已有文本之下。批次 365 起导出(psdWarpText 复用) */
53
+ export declare const compositeWarpEffects: (ctx: CanvasRenderingContext2D, node: TextNode, decls: PsdEffectsDecls | null) => void;
47
54
  /** 变形文本整图烘焙(本地中心系 logicalW×logicalH,内容居中) */
48
55
  export declare const bakeWarpedText: (node: TextNode, kind: WarpKind, decls?: PsdEffectsDecls | null) => WarpBake | null;
56
+ /** 竖排逐字彩色渲染(shadowBake.drawTextGlyphs 竖排分支的彩色版):摆位/
57
+ * 姿态(verticalGlyphOps + drawVerticalGlyph)与 K-line jitter 同剪影口径,
58
+ * fill/stroke 逐字覆写与 renderTextRuns 同语义(fill 覆写 ?? 对象级、
59
+ * 描边 resolveStrokeDecl;paintFirst 逐字粒度不区分——竖排 quad 管线同款)。
60
+ * 批次 365 起导出(psdWarpText 竖排分支复用) */
61
+ export declare const renderVerticalRuns: (ctx: CanvasRenderingContext2D, node: TextNode) => void;
49
62
  /**
50
63
  * 常规/竖排文本 + PSD 特效整图烘焙(SVG 导出位图路径):横排复用
51
64
  * renderTextRuns、竖排 renderVerticalRuns,特效层 compositeWarpEffects 合成
@@ -34,8 +34,9 @@ export const warpTextKind = (raw) => {
34
34
  return null;
35
35
  };
36
36
  const CACHE_DPR = 2;
37
- /** 文本 run(同样式连续段)逐 run 画到 ctx(中心原点本地系,×CACHE_DPR) */
38
- const renderTextRuns = (ctx, node) => {
37
+ /** 文本 run(同样式连续段)逐 run 画到 ctx(中心原点本地系,×CACHE_DPR)。
38
+ * 批次 365 起导出:psdWarpText 烘焙复用(PSD 变形文本的未变形源渲染同脚手架) */
39
+ export const renderTextRuns = (ctx, node) => {
39
40
  const layout = node.textLayout;
40
41
  const style = node.textStyle;
41
42
  const baseStroke = node.textStroke;
@@ -149,8 +150,8 @@ export const bakeWarpShadowLayer = (decls, source, rs) => {
149
150
  };
150
151
  /** 变形特效合成(fabric _renderText 同序:投影垫底 → run 文本 → solidFill → stroke)。
151
152
  * ctx 为变形烘焙画布上下文(中心原点本地系 ×CACHE_DPR);投影在 run 之后合成,
152
- * 用 destination-over 落到已有文本之下。 */
153
- const compositeWarpEffects = (ctx, node, decls) => {
153
+ * 用 destination-over 落到已有文本之下。批次 365 起导出(psdWarpText 复用) */
154
+ export const compositeWarpEffects = (ctx, node, decls) => {
154
155
  if (!decls)
155
156
  return;
156
157
  if (decls.dropShadows.length === 0 && decls.solidFills.length === 0 && decls.strokes.length === 0)
@@ -309,8 +310,9 @@ export const bakeWarpedText = (node, kind, decls = null) => {
309
310
  /** 竖排逐字彩色渲染(shadowBake.drawTextGlyphs 竖排分支的彩色版):摆位/
310
311
  * 姿态(verticalGlyphOps + drawVerticalGlyph)与 K-line jitter 同剪影口径,
311
312
  * fill/stroke 逐字覆写与 renderTextRuns 同语义(fill 覆写 ?? 对象级、
312
- * 描边 resolveStrokeDecl;paintFirst 逐字粒度不区分——竖排 quad 管线同款)。 */
313
- const renderVerticalRuns = (ctx, node) => {
313
+ * 描边 resolveStrokeDecl;paintFirst 逐字粒度不区分——竖排 quad 管线同款)。
314
+ * 批次 365 起导出(psdWarpText 竖排分支复用) */
315
+ export const renderVerticalRuns = (ctx, node) => {
314
316
  const layout = node.textLayout;
315
317
  const style = node.textStyle;
316
318
  const baseStroke = node.textStroke;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yft-design/engine",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "yft-design 的 WebGL2 画布引擎:接受 fabric toObject 格式 JSON,输出 GL 画布 / 位图(任意倍率 FBO 读回)/ SVG(纯数据序列化器)",
5
5
  "repository": {
6
6
  "type": "git",