@yft-design/engine 0.0.0-stage → 0.0.2
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/README.md +39 -2
- package/assets/images/greyfloral.png +0 -0
- package/assets/images/honey_im_subtle.png +0 -0
- package/assets/images/nasty_fabric.png +0 -0
- package/assets/images/retina_wood.png +0 -0
- package/assets/images/rotate.png +0 -0
- package/dist/EngineCanvas.d.ts +500 -0
- package/dist/EngineCanvas.js +927 -0
- package/dist/core/canvasPerf.d.ts +23 -0
- package/dist/core/canvasPerf.js +170 -0
- package/dist/core/color.d.ts +52 -0
- package/dist/core/color.js +107 -0
- package/dist/core/distanceField.d.ts +15 -0
- package/dist/core/distanceField.js +92 -0
- package/dist/core/events.d.ts +34 -0
- package/dist/core/events.js +52 -0
- package/dist/core/gradient.d.ts +97 -0
- package/dist/core/gradient.js +175 -0
- package/dist/core/imageFilters.d.ts +150 -0
- package/dist/core/imageFilters.js +330 -0
- package/dist/core/mat2d.d.ts +151 -0
- package/dist/core/mat2d.js +241 -0
- package/dist/core/pathData.d.ts +53 -0
- package/dist/core/pathData.js +926 -0
- package/dist/core/pattern.d.ts +38 -0
- package/dist/core/pattern.js +40 -0
- package/dist/core/point.d.ts +59 -0
- package/dist/core/point.js +119 -0
- package/dist/core/psdEffects.d.ts +126 -0
- package/dist/core/psdEffects.js +158 -0
- package/dist/core/roundedRect.d.ts +62 -0
- package/dist/core/roundedRect.js +163 -0
- package/dist/core/shadow.d.ts +51 -0
- package/dist/core/shadow.js +47 -0
- package/dist/core/snap.d.ts +232 -0
- package/dist/core/snap.js +793 -0
- package/dist/core/stroke.d.ts +41 -0
- package/dist/core/stroke.js +44 -0
- package/dist/core/triangulate.d.ts +24 -0
- package/dist/core/triangulate.js +118 -0
- package/dist/debug/canvasInspection.d.ts +92 -0
- package/dist/debug/canvasInspection.js +113 -0
- package/dist/debug/pixelDiff.d.ts +22 -0
- package/dist/debug/pixelDiff.js +64 -0
- package/dist/debug/seed.d.ts +473 -0
- package/dist/debug/seed.js +3803 -0
- package/dist/decoders/gif2sprite.d.ts +9 -0
- package/dist/decoders/gif2sprite.js +84 -0
- package/dist/decoders/webp2sprite.d.ts +22 -0
- package/dist/decoders/webp2sprite.js +133 -0
- package/dist/engineFlag.d.ts +72 -0
- package/dist/engineFlag.js +86 -0
- package/dist/export/SceneExporter.d.ts +92 -0
- package/dist/export/SceneExporter.js +280 -0
- package/dist/export/glExport.d.ts +66 -0
- package/dist/export/glExport.js +79 -0
- package/dist/export/svgExport.d.ts +277 -0
- package/dist/export/svgExport.js +1790 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.js +48 -0
- package/dist/interact/animationPlayback.d.ts +125 -0
- package/dist/interact/animationPlayback.js +344 -0
- package/dist/interact/canvasInteractions.d.ts +50 -0
- package/dist/interact/canvasInteractions.js +150 -0
- package/dist/interact/cropSession.d.ts +123 -0
- package/dist/interact/cropSession.js +526 -0
- package/dist/interact/dblClick.d.ts +51 -0
- package/dist/interact/dblClick.js +106 -0
- package/dist/interact/expandSession.d.ts +107 -0
- package/dist/interact/expandSession.js +281 -0
- package/dist/interact/hotkeyActions.d.ts +16 -0
- package/dist/interact/hotkeyActions.js +41 -0
- package/dist/interact/pathSession.d.ts +141 -0
- package/dist/interact/pathSession.js +480 -0
- package/dist/interact/pointer.d.ts +106 -0
- package/dist/interact/pointer.js +1594 -0
- package/dist/interact/pointerTablePuzzle.d.ts +100 -0
- package/dist/interact/pointerTablePuzzle.js +358 -0
- package/dist/interact/pointerTransform.d.ts +86 -0
- package/dist/interact/pointerTransform.js +440 -0
- package/dist/interact/pointerTypes.d.ts +577 -0
- package/dist/interact/pointerTypes.js +96 -0
- package/dist/interact/snapGuide.d.ts +127 -0
- package/dist/interact/snapGuide.js +376 -0
- package/dist/interact/tableCellEditing.d.ts +61 -0
- package/dist/interact/tableCellEditing.js +198 -0
- package/dist/interact/tableInteraction.d.ts +55 -0
- package/dist/interact/tableInteraction.js +212 -0
- package/dist/interact/textEditing.d.ts +77 -0
- package/dist/interact/textEditing.js +410 -0
- package/dist/interact/warpFacade.d.ts +36 -0
- package/dist/interact/warpFacade.js +51 -0
- package/dist/interact/warpSession.d.ts +191 -0
- package/dist/interact/warpSession.js +582 -0
- package/dist/interact/wheelScroll.d.ts +62 -0
- package/dist/interact/wheelScroll.js +72 -0
- package/dist/model/alphaHit.d.ts +59 -0
- package/dist/model/alphaHit.js +262 -0
- package/dist/model/animation.d.ts +228 -0
- package/dist/model/animation.js +510 -0
- package/dist/model/arcLayout.d.ts +54 -0
- package/dist/model/arcLayout.js +307 -0
- package/dist/model/arcTextTransform.d.ts +7 -0
- package/dist/model/arcTextTransform.js +87 -0
- package/dist/model/compatEvents.d.ts +135 -0
- package/dist/model/compatEvents.js +73 -0
- package/dist/model/compatObject.d.ts +716 -0
- package/dist/model/compatObject.js +1579 -0
- package/dist/model/cropEdit.d.ts +118 -0
- package/dist/model/cropEdit.js +497 -0
- package/dist/model/document.d.ts +294 -0
- package/dist/model/document.js +572 -0
- package/dist/model/expandEdit.d.ts +93 -0
- package/dist/model/expandEdit.js +161 -0
- package/dist/model/fabricPrimitives.d.ts +156 -0
- package/dist/model/fabricPrimitives.js +9 -0
- package/dist/model/filler.d.ts +53 -0
- package/dist/model/filler.js +1 -0
- package/dist/model/groupAssemble.d.ts +7 -0
- package/dist/model/groupAssemble.js +98 -0
- package/dist/model/groupChildMove.d.ts +46 -0
- package/dist/model/groupChildMove.js +145 -0
- package/dist/model/groupResize.d.ts +78 -0
- package/dist/model/groupResize.js +108 -0
- package/dist/model/handles.d.ts +40 -0
- package/dist/model/handles.js +29 -0
- package/dist/model/imageMaskBake.d.ts +75 -0
- package/dist/model/imageMaskBake.js +136 -0
- package/dist/model/lineConstruct.d.ts +13 -0
- package/dist/model/lineConstruct.js +79 -0
- package/dist/model/maskCropEdit.d.ts +64 -0
- package/dist/model/maskCropEdit.js +90 -0
- package/dist/model/pathBackground.d.ts +51 -0
- package/dist/model/pathBackground.js +196 -0
- package/dist/model/pathConstruct.d.ts +27 -0
- package/dist/model/pathConstruct.js +55 -0
- package/dist/model/pathEdit.d.ts +114 -0
- package/dist/model/pathEdit.js +378 -0
- package/dist/model/puzzleEdit.d.ts +136 -0
- package/dist/model/puzzleEdit.js +742 -0
- package/dist/model/puzzleLayout.d.ts +91 -0
- package/dist/model/puzzleLayout.js +143 -0
- package/dist/model/scene.d.ts +1004 -0
- package/dist/model/scene.js +2841 -0
- package/dist/model/schema.d.ts +290 -0
- package/dist/model/schema.js +13 -0
- package/dist/model/shapePath.d.ts +14 -0
- package/dist/model/shapePath.js +136 -0
- package/dist/model/tableEdit.d.ts +196 -0
- package/dist/model/tableEdit.js +751 -0
- package/dist/model/tableFacade.d.ts +6 -0
- package/dist/model/tableFacade.js +808 -0
- package/dist/model/tableLayout.d.ts +85 -0
- package/dist/model/tableLayout.js +193 -0
- package/dist/model/textLayout.d.ts +357 -0
- package/dist/model/textLayout.js +822 -0
- package/dist/render/GLBlend.d.ts +40 -0
- package/dist/render/GLBlend.js +270 -0
- package/dist/render/GLContext.d.ts +25 -0
- package/dist/render/GLContext.js +48 -0
- package/dist/render/GLIsolate.d.ts +46 -0
- package/dist/render/GLIsolate.js +188 -0
- package/dist/render/GLTextureCache.d.ts +86 -0
- package/dist/render/GLTextureCache.js +187 -0
- package/dist/render/GlyphAtlas.d.ts +151 -0
- package/dist/render/GlyphAtlas.js +404 -0
- package/dist/render/MeshBatch.d.ts +123 -0
- package/dist/render/MeshBatch.js +416 -0
- package/dist/render/QuadBatch.d.ts +138 -0
- package/dist/render/QuadBatch.js +490 -0
- package/dist/render/SceneRenderer.d.ts +186 -0
- package/dist/render/SceneRenderer.js +700 -0
- package/dist/render/SourceManager.d.ts +121 -0
- package/dist/render/SourceManager.js +505 -0
- package/dist/render/TextRenderer.d.ts +140 -0
- package/dist/render/TextRenderer.js +795 -0
- package/dist/render/arcText.d.ts +40 -0
- package/dist/render/arcText.js +187 -0
- package/dist/render/batchOrder.d.ts +105 -0
- package/dist/render/batchOrder.js +168 -0
- package/dist/render/blendMode.d.ts +35 -0
- package/dist/render/blendMode.js +142 -0
- package/dist/render/clipMaskPainter.d.ts +17 -0
- package/dist/render/clipMaskPainter.js +121 -0
- package/dist/render/fontInvalidation.d.ts +25 -0
- package/dist/render/fontInvalidation.js +77 -0
- package/dist/render/fontInvalidationController.d.ts +76 -0
- package/dist/render/fontInvalidationController.js +114 -0
- package/dist/render/frameOverlay.d.ts +62 -0
- package/dist/render/frameOverlay.js +124 -0
- package/dist/render/framePipeline.d.ts +99 -0
- package/dist/render/framePipeline.js +95 -0
- package/dist/render/gpuFilterPasses.d.ts +25 -0
- package/dist/render/gpuFilterPasses.js +883 -0
- package/dist/render/gpuFx.d.ts +136 -0
- package/dist/render/gpuFx.js +614 -0
- package/dist/render/gpuImageFilters.d.ts +59 -0
- package/dist/render/gpuImageFilters.js +289 -0
- package/dist/render/gpuShadow.d.ts +52 -0
- package/dist/render/gpuShadow.js +289 -0
- package/dist/render/gradientRamp.d.ts +45 -0
- package/dist/render/gradientRamp.js +74 -0
- package/dist/render/imageEffects.d.ts +123 -0
- package/dist/render/imageEffects.js +390 -0
- package/dist/render/maskRender.d.ts +92 -0
- package/dist/render/maskRender.js +224 -0
- package/dist/render/progressiveLoad.d.ts +45 -0
- package/dist/render/progressiveLoad.js +86 -0
- package/dist/render/psdEffectPainter.d.ts +34 -0
- package/dist/render/psdEffectPainter.js +309 -0
- package/dist/render/puzzleClamp.d.ts +28 -0
- package/dist/render/puzzleClamp.js +30 -0
- package/dist/render/retainedFrame.d.ts +85 -0
- package/dist/render/retainedFrame.js +193 -0
- package/dist/render/ruler.d.ts +90 -0
- package/dist/render/ruler.js +287 -0
- package/dist/render/scrollText.d.ts +65 -0
- package/dist/render/scrollText.js +261 -0
- package/dist/render/selectionOverlay.d.ts +318 -0
- package/dist/render/selectionOverlay.js +921 -0
- package/dist/render/shaders.d.ts +38 -0
- package/dist/render/shaders.js +314 -0
- package/dist/render/shadowBake.d.ts +43 -0
- package/dist/render/shadowBake.js +202 -0
- package/dist/render/shadowPainter.d.ts +13 -0
- package/dist/render/shadowPainter.js +80 -0
- package/dist/render/sharedGpuPainters.d.ts +25 -0
- package/dist/render/sharedGpuPainters.js +40 -0
- package/dist/render/sourceHydration.d.ts +12 -0
- package/dist/render/sourceHydration.js +48 -0
- package/dist/render/strokeBake.d.ts +85 -0
- package/dist/render/strokeBake.js +515 -0
- package/dist/render/strokePainter.d.ts +28 -0
- package/dist/render/strokePainter.js +119 -0
- package/dist/render/strokeSdf.d.ts +35 -0
- package/dist/render/strokeSdf.js +74 -0
- package/dist/render/svgRaster.d.ts +46 -0
- package/dist/render/svgRaster.js +71 -0
- package/dist/render/tableOverlay.d.ts +38 -0
- package/dist/render/tableOverlay.js +233 -0
- package/dist/render/textHighlight.d.ts +117 -0
- package/dist/render/textHighlight.js +380 -0
- package/dist/render/textureUpload.d.ts +18 -0
- package/dist/render/textureUpload.js +26 -0
- package/dist/render/verticalText.d.ts +38 -0
- package/dist/render/verticalText.js +63 -0
- package/dist/render/warpText.d.ts +58 -0
- package/dist/render/warpText.js +380 -0
- package/dist/render/workspaceBackdrop.d.ts +35 -0
- package/dist/render/workspaceBackdrop.js +71 -0
- package/dist/render/workspaceChecker.d.ts +54 -0
- package/dist/render/workspaceChecker.js +170 -0
- package/dist/render/workspaceGlow.d.ts +51 -0
- package/dist/render/workspaceGlow.js +171 -0
- package/package.json +44 -3
|
@@ -0,0 +1,3803 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 确定性种子场景(main-webgl2 Phase 0,仅 dev 页面与 e2e 使用)。
|
|
3
|
+
*
|
|
4
|
+
* parity 验收的关键约束:引擎与 fabric 参考必须渲染「同一份对象 JSON」,
|
|
5
|
+
* 且场景可复现(固定 PRNG 种子)。整数对齐的矩形场景在两套光栅化器下
|
|
6
|
+
* 都无抗锯齿边缘,是逐像素比对的稳定基线;带旋转/缩放的场景用宽松容差。
|
|
7
|
+
*/
|
|
8
|
+
/** mulberry32:体积小、跨运行确定性足够(非加密场景) */
|
|
9
|
+
export const mulberry32 = (seed) => {
|
|
10
|
+
let a = seed >>> 0;
|
|
11
|
+
return () => {
|
|
12
|
+
a |= 0;
|
|
13
|
+
a = (a + 0x6d2b79f5) | 0;
|
|
14
|
+
let t = Math.imul(a ^ (a >>> 15), 1 | a);
|
|
15
|
+
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
|
|
16
|
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
const toHex = (n) => Math.round(n * 255)
|
|
20
|
+
.toString(16)
|
|
21
|
+
.padStart(2, '0');
|
|
22
|
+
/** 整数对齐矩形场景:坐标/尺寸取整、不透明填充,zoom=1 下两套光栅化器输出应逐像素一致。
|
|
23
|
+
* 刻意全不透明:半透明堆叠时 GL(浮点管线、每次写目标舍入一次)与 Canvas2D
|
|
24
|
+
* (uint8 逐次合成舍入)的舍入路径不同,会引入与本测试目标无关的稳定小偏差;
|
|
25
|
+
* 混合舍入 parity 属 Phase 1 议题(届时按预乘语义单独设计容差)。 */
|
|
26
|
+
export const makeRectScene = (count, seed = 42, bounds = { width: 2000, height: 1400 }) => {
|
|
27
|
+
const rand = mulberry32(seed);
|
|
28
|
+
const objects = [];
|
|
29
|
+
for (let i = 0; i < count; i++) {
|
|
30
|
+
const w = 20 + Math.floor(rand() * 120);
|
|
31
|
+
const h = 20 + Math.floor(rand() * 120);
|
|
32
|
+
objects.push({
|
|
33
|
+
type: 'rect',
|
|
34
|
+
id: `r${i}`,
|
|
35
|
+
left: Math.floor(rand() * (bounds.width - w)),
|
|
36
|
+
top: Math.floor(rand() * (bounds.height - h)),
|
|
37
|
+
width: w,
|
|
38
|
+
height: h,
|
|
39
|
+
scaleX: 1,
|
|
40
|
+
scaleY: 1,
|
|
41
|
+
angle: 0,
|
|
42
|
+
fill: `#${toHex(0.2 + rand() * 0.8)}${toHex(0.2 + rand() * 0.8)}${toHex(0.2 + rand() * 0.8)}`,
|
|
43
|
+
opacity: 1,
|
|
44
|
+
originX: 'left',
|
|
45
|
+
originY: 'top',
|
|
46
|
+
strokeWidth: 0,
|
|
47
|
+
visible: true
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return objects;
|
|
51
|
+
};
|
|
52
|
+
/** 素材图片链接(真实 URL,走 fetch → decode → 纹理链路,而非合成 dataURL)。
|
|
53
|
+
* 两类来源:
|
|
54
|
+
* - 本地打包素材(app PatternImages 图案族)经 Vite 静态 URL,dev/e2e 同源直出、离线可用;
|
|
55
|
+
* - 稿定素材 CDN 走 dev 代理 /gaoding-material(同源转发到 st0.dancf.com)。CDN 本身
|
|
56
|
+
* 不带 CORS 头,WebGL 纹理上传要求 CORS 干净,裸 https 链接会加载失败,必须走代理;
|
|
57
|
+
* resize,w_640 把 2400² 原图压到 640²,控制画布占比与解码成本。 */
|
|
58
|
+
const assetUrl = (path) => new URL(path, import.meta.url).href;
|
|
59
|
+
const MATERIAL_IMAGE_SRCS = [
|
|
60
|
+
assetUrl('../../assets/images/retina_wood.png'), // 512×512 木纹
|
|
61
|
+
assetUrl('../../assets/images/nasty_fabric.png'), // 198×200 织物
|
|
62
|
+
assetUrl('../../assets/images/greyfloral.png'), // 150×124 灰花卉
|
|
63
|
+
assetUrl('../../assets/images/honey_im_subtle.png'), // 179×132 蜂巢
|
|
64
|
+
assetUrl('../../assets/images/rotate.png'), // 200×200
|
|
65
|
+
'/gaoding-material/02/material_uploader/202106250601-e23c.jpg?x-oss-process=image/resize,w_640',
|
|
66
|
+
'/gaoding-material/02/material_uploader/202107060252-d51f.jpg?x-oss-process=image/resize,w_640'
|
|
67
|
+
];
|
|
68
|
+
/** 图片场景:真实素材链接 + 部分带缩放/旋转(宽松容差比对)。
|
|
69
|
+
* 不写 width/height——两侧统一回退位图 natural size(引擎 dims 兜底与 fabric
|
|
70
|
+
* FabricImage 默认同语义),种子因此无需预知素材尺寸;加载失败两侧都跳过该节点。
|
|
71
|
+
* 缩放只取放大(1~1.5):放大时 GL 双线性与 Canvas2D 过滤几乎一致;缩小的两侧
|
|
72
|
+
* 过滤算法差异是已知良好差异,属 Phase 1 议题。真实素材含硬边/高频细节,重采样
|
|
73
|
+
* 核差异远大于合成线性渐变,parity 靠降采样均值 + 放宽容差吸收(e2e 侧标注)。 */
|
|
74
|
+
export const makeImageScene = (count, seed = 7, bounds = { width: 2000, height: 1400 }) => {
|
|
75
|
+
const rand = mulberry32(seed);
|
|
76
|
+
const objects = [];
|
|
77
|
+
for (let i = 0; i < count; i++) {
|
|
78
|
+
const scale = 1 + rand() * 0.5;
|
|
79
|
+
objects.push({
|
|
80
|
+
type: 'image',
|
|
81
|
+
id: `img${i}`,
|
|
82
|
+
left: Math.floor(rand() * bounds.width),
|
|
83
|
+
top: Math.floor(rand() * bounds.height),
|
|
84
|
+
scaleX: scale,
|
|
85
|
+
scaleY: scale,
|
|
86
|
+
angle: Math.round(rand() * 4) * 15,
|
|
87
|
+
flipX: rand() > 0.7,
|
|
88
|
+
originX: 'left',
|
|
89
|
+
originY: 'top',
|
|
90
|
+
opacity: 1,
|
|
91
|
+
src: MATERIAL_IMAGE_SRCS[Math.floor(rand() * MATERIAL_IMAGE_SRCS.length)],
|
|
92
|
+
strokeWidth: 0,
|
|
93
|
+
visible: true
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
return objects;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* SVG 源场景(批次 39——「二维码/条形码 zoom 放大后模糊」回归)。
|
|
100
|
+
*
|
|
101
|
+
* 生产口径:二维码/条形码(QRCode/BarCode extends FabricImage)的 src 是
|
|
102
|
+
* data:image/svg+xml 矢量——Canvas2D drawImage 按当前变换光栅化恒清晰,
|
|
103
|
+
* 引擎纹理必须按需重光栅化(render/svgRaster)。场景全用 base64 SVG data
|
|
104
|
+
* URL(离线确定性):
|
|
105
|
+
* - qr0:QRCode 118×118(生产同尺寸,21×21 模块盘 + 三 finder)
|
|
106
|
+
* - qr1:QRCode 旋转 30° + scale 1.5(worldScale 口径的放大需求)
|
|
107
|
+
* - bar0:BarCode 200×80(jsbarcode 风:变宽条 + 静区)
|
|
108
|
+
* - svg0:svgimage 160×160(通用矢量图:圆 + 三角 + 环)
|
|
109
|
+
*/
|
|
110
|
+
export const makeSvgImageScene = () => {
|
|
111
|
+
const svgDataUrl = (svg) => `data:image/svg+xml;base64,${btoa(svg)}`;
|
|
112
|
+
// QR 风 21×21 模块盘:三 finder(7×7 双环)+ PRNG 数据模块(finder 区留空)
|
|
113
|
+
const N = 21;
|
|
114
|
+
const rand = mulberry32(39);
|
|
115
|
+
const inFinder = (x, y) => (x < 8 && y < 8) || (x > N - 9 && y < 8) || (x < 8 && y > N - 9);
|
|
116
|
+
let cells = '';
|
|
117
|
+
for (let y = 0; y < N; y++) {
|
|
118
|
+
for (let x = 0; x < N; x++) {
|
|
119
|
+
const on = inFinder(x, y) ? false : rand() > 0.52;
|
|
120
|
+
if (on)
|
|
121
|
+
cells += `<rect x="${x}" y="${y}" width="1" height="1"/>`;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
const finder = (fx, fy) => `<rect x="${fx}" y="${fy}" width="7" height="7" fill="none" stroke="#000" stroke-width="1"/>` + `<rect x="${fx + 2}" y="${fy + 2}" width="3" height="3"/>`;
|
|
125
|
+
const qrSvg = `<svg xmlns="http://www.w3.org/2000/svg" width="118" height="118" viewBox="0 0 ${N} ${N}">` +
|
|
126
|
+
`<rect width="${N}" height="${N}" fill="#fff"/><g fill="#000">${cells}</g>` +
|
|
127
|
+
`<g fill="#000">${finder(0, 0)}${finder(N - 7, 0)}${finder(0, N - 7)}</g></svg>`;
|
|
128
|
+
// 条码风:变宽黑白条(确定性序列)+ 上下静区
|
|
129
|
+
const brand = mulberry32(77);
|
|
130
|
+
let bars = '';
|
|
131
|
+
let bx = 4;
|
|
132
|
+
while (bx < 192) {
|
|
133
|
+
const w = 2 + Math.floor(brand() * 5);
|
|
134
|
+
bars += `<rect x="${bx}" y="12" width="${w}" height="56"/>`;
|
|
135
|
+
bx += w + 2 + Math.floor(brand() * 4);
|
|
136
|
+
}
|
|
137
|
+
const barSvg = `<svg xmlns="http://www.w3.org/2000/svg" width="200" height="80" viewBox="0 0 200 80">` + `<rect width="200" height="80" fill="#fff"/><g fill="#000">${bars}</g></svg>`;
|
|
138
|
+
const logoSvg = `<svg xmlns="http://www.w3.org/2000/svg" width="160" height="160" viewBox="0 0 160 160">` +
|
|
139
|
+
`<rect width="160" height="160" fill="#fff"/><circle cx="62" cy="66" r="40" fill="#1f66ff"/>` +
|
|
140
|
+
`<path d="M84 34 L140 118 L28 118 Z" fill="#ff8d23"/><circle cx="118" cy="106" r="22" fill="none" stroke="#111" stroke-width="6"/></svg>`;
|
|
141
|
+
const base = {
|
|
142
|
+
scaleX: 1,
|
|
143
|
+
scaleY: 1,
|
|
144
|
+
angle: 0,
|
|
145
|
+
originX: 'left',
|
|
146
|
+
originY: 'top',
|
|
147
|
+
opacity: 1,
|
|
148
|
+
strokeWidth: 0,
|
|
149
|
+
visible: true,
|
|
150
|
+
crossOrigin: 'anonymous'
|
|
151
|
+
};
|
|
152
|
+
return [
|
|
153
|
+
{ ...base, type: 'QRCode', id: 'qr0', left: 120, top: 100, src: svgDataUrl(qrSvg), codeContent: 'https://yft.design', codeOption: { codeStyle: 'A1', codeSpace: false, codeError: 0 } },
|
|
154
|
+
{
|
|
155
|
+
...base,
|
|
156
|
+
type: 'QRCode',
|
|
157
|
+
id: 'qr1',
|
|
158
|
+
left: 360,
|
|
159
|
+
top: 100,
|
|
160
|
+
angle: 30,
|
|
161
|
+
scaleX: 1.5,
|
|
162
|
+
scaleY: 1.5,
|
|
163
|
+
src: svgDataUrl(qrSvg),
|
|
164
|
+
codeContent: 'https://yft.design',
|
|
165
|
+
codeOption: { codeStyle: 'A1', codeSpace: false, codeError: 0 }
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
...base,
|
|
169
|
+
type: 'BarCode',
|
|
170
|
+
id: 'bar0',
|
|
171
|
+
left: 120,
|
|
172
|
+
top: 360,
|
|
173
|
+
src: svgDataUrl(barSvg),
|
|
174
|
+
codeContent: 'YFT-39',
|
|
175
|
+
codeOption: { format: 'code128', width: 2, height: 40, displayValue: true, background: '#ffffff' }
|
|
176
|
+
},
|
|
177
|
+
{ ...base, type: 'svgimage', id: 'svg0', left: 420, top: 320, src: svgDataUrl(logoSvg) }
|
|
178
|
+
];
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* 图片静态裁剪场景(B1):cropX/cropY 双序列化口径(legacy=缺省 width 含偏移、
|
|
182
|
+
* visible=width 即可见宽,应用 FabricImage.toObject/fromObject 的往返约定)。
|
|
183
|
+
* 素材用本地打包图(尺寸已知、离线可用):nasty_fabric 198×200、
|
|
184
|
+
* greyfloral 150×124、rotate 200×200、retina_wood 512×512。
|
|
185
|
+
* 覆盖:legacy 全偏移 / visible 口径 / 裁剪+旋转+翻转 / 裁剪+原生 shadow /
|
|
186
|
+
* 裁剪+PSD dropShadow(烘焙源子矩形)/ 单轴 legacy。
|
|
187
|
+
*/
|
|
188
|
+
export const makeCropImageScene = () => {
|
|
189
|
+
const base = {
|
|
190
|
+
type: 'image',
|
|
191
|
+
scaleX: 1,
|
|
192
|
+
scaleY: 1,
|
|
193
|
+
angle: 0,
|
|
194
|
+
originX: 'left',
|
|
195
|
+
originY: 'top',
|
|
196
|
+
opacity: 1,
|
|
197
|
+
strokeWidth: 0,
|
|
198
|
+
visible: true,
|
|
199
|
+
src: assetUrl('../../assets/images/nasty_fabric.png')
|
|
200
|
+
};
|
|
201
|
+
const fabricSrc = assetUrl('../../assets/images/greyfloral.png');
|
|
202
|
+
const rotateSrc = assetUrl('../../assets/images/rotate.png');
|
|
203
|
+
const woodSrc = assetUrl('../../assets/images/retina_wood.png');
|
|
204
|
+
return [
|
|
205
|
+
// cr0 legacy:可见 120×140 → 盘上 width=160/height=170(右缘坐标语义)
|
|
206
|
+
{ ...base, id: 'cr0', left: 60, top: 40, scaleX: 1.5, scaleY: 1.5, cropX: 40, cropY: 30, width: 160, height: 170 },
|
|
207
|
+
// cr1 visible:width/height 即可见尺寸(PDF 导入链路口径)
|
|
208
|
+
{ ...base, id: 'cr1', left: 320, top: 40, src: rotateSrc, cropX: 30, cropY: 20, width: 100, height: 80, cropSizeMode: 'visible' },
|
|
209
|
+
// cr2 legacy + 旋转 + 水平翻转:可见 100×86 → width=125/height=105
|
|
210
|
+
{ ...base, id: 'cr2', left: 560, top: 60, src: fabricSrc, angle: 30, flipX: true, scaleX: 1.6, scaleY: 1.6, cropX: 25, cropY: 19, width: 125, height: 105 },
|
|
211
|
+
// cr3 visible + 原生 shadow(剪影子矩形;composite 口径对拍)
|
|
212
|
+
{
|
|
213
|
+
...base,
|
|
214
|
+
id: 'cr3',
|
|
215
|
+
left: 60,
|
|
216
|
+
top: 320,
|
|
217
|
+
src: woodSrc,
|
|
218
|
+
scaleX: 0.9,
|
|
219
|
+
scaleY: 0.9,
|
|
220
|
+
cropX: 100,
|
|
221
|
+
cropY: 120,
|
|
222
|
+
width: 200,
|
|
223
|
+
height: 160,
|
|
224
|
+
cropSizeMode: 'visible',
|
|
225
|
+
shadow: { color: 'rgba(40,40,60,0.45)', blur: 12, offsetX: 10, offsetY: 10, affectStroke: false, nonScaling: false }
|
|
226
|
+
},
|
|
227
|
+
// cr4 visible + PSD dropShadow(bakePsdShadow 源子矩形)
|
|
228
|
+
{
|
|
229
|
+
...base,
|
|
230
|
+
id: 'cr4',
|
|
231
|
+
left: 360,
|
|
232
|
+
top: 340,
|
|
233
|
+
src: fabricSrc,
|
|
234
|
+
angle: 15,
|
|
235
|
+
scaleX: 1.8,
|
|
236
|
+
scaleY: 1.8,
|
|
237
|
+
cropX: 20,
|
|
238
|
+
cropY: 12,
|
|
239
|
+
width: 96,
|
|
240
|
+
height: 84,
|
|
241
|
+
cropSizeMode: 'visible',
|
|
242
|
+
effects: { dropShadow: [{ enabled: true, showInDialog: true, fill: 'rgba(60,50,40,0.45)', blur: 10, offsetX: 12, offsetY: 12 }] }
|
|
243
|
+
},
|
|
244
|
+
// cr5 legacy 单轴(cropY=0):可见宽=198−58=140、高=200 全高
|
|
245
|
+
{ ...base, id: 'cr5', left: 760, top: 330, scaleX: 1.3, scaleY: 0.8, cropX: 58, cropY: 0, width: 198, height: 200 }
|
|
246
|
+
];
|
|
247
|
+
};
|
|
248
|
+
/**
|
|
249
|
+
* 智能对象双击场景(P5-7):图片族节点带 PSD 导入产出的 smartObject 元数据
|
|
250
|
+
* (handlePSD.getImageElement + layer.placedLayer 形态,透视变形已烘焙进 src,
|
|
251
|
+
* smartObject 仅是编辑入口元数据)。覆盖双击派发与桥接映射的口径:
|
|
252
|
+
* - so0 全量元数据(id/placed/name/width/height/transform/parseStatus)
|
|
253
|
+
* - so1 缺 width/height/name(natural 198×200 回落 + layer 名回落)+ 旋转缩放
|
|
254
|
+
* - so2 无 smartObject 的普通图片(image:replace-requested 分支)
|
|
255
|
+
* e2e 经 dblclick → getEditingEventLog 断言映射后的 openSmartObjectDocument
|
|
256
|
+
* 参数(smartObjectOpenOptions 与 FabricImage.doubleClickHandler 同源)。
|
|
257
|
+
*/
|
|
258
|
+
export const makeSmartObjectScene = () => {
|
|
259
|
+
const base = {
|
|
260
|
+
type: 'image',
|
|
261
|
+
scaleX: 1,
|
|
262
|
+
scaleY: 1,
|
|
263
|
+
angle: 0,
|
|
264
|
+
originX: 'left',
|
|
265
|
+
originY: 'top',
|
|
266
|
+
opacity: 1,
|
|
267
|
+
strokeWidth: 0,
|
|
268
|
+
visible: true,
|
|
269
|
+
src: assetUrl('../../assets/images/nasty_fabric.png')
|
|
270
|
+
};
|
|
271
|
+
return [
|
|
272
|
+
{
|
|
273
|
+
...base,
|
|
274
|
+
id: 'so0',
|
|
275
|
+
left: 60,
|
|
276
|
+
top: 40,
|
|
277
|
+
layer: 'Hero Title',
|
|
278
|
+
smartObject: {
|
|
279
|
+
id: 'placed-1',
|
|
280
|
+
placed: 'plc-1',
|
|
281
|
+
name: 'hero-title',
|
|
282
|
+
type: 'image',
|
|
283
|
+
width: 480,
|
|
284
|
+
height: 360,
|
|
285
|
+
transform: [0, 0, 480, 0, 480, 360, 0, 360],
|
|
286
|
+
parseStatus: 'success'
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
...base,
|
|
291
|
+
id: 'so1',
|
|
292
|
+
left: 320,
|
|
293
|
+
top: 40,
|
|
294
|
+
angle: 15,
|
|
295
|
+
scaleX: 1.4,
|
|
296
|
+
scaleY: 1.2,
|
|
297
|
+
layer: 'Badge Layer',
|
|
298
|
+
smartObject: {
|
|
299
|
+
id: 'placed-2',
|
|
300
|
+
name: '',
|
|
301
|
+
parseStatus: 'success'
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
{ ...base, id: 'so2', left: 580, top: 40, layer: 'Plain Photo' }
|
|
305
|
+
];
|
|
306
|
+
};
|
|
307
|
+
/**
|
|
308
|
+
* 图片滤镜场景(B1(余) GPU 化):31 个单滤镜 + 5 组合,序列化形态与
|
|
309
|
+
* UI 产出严格一致(fabric BaseFilter.toObject = type + defaults 键;预设式
|
|
310
|
+
* FilterImage 单选替换、滑块式 FilterElement 同类去重后叠加)。
|
|
311
|
+
* 素材 rotate.png 200×200 / nasty_fabric 198×200(尺寸已知、离线可用)。
|
|
312
|
+
* 覆盖:fabric 内置(Brightness/Contrast/Saturation/Vibrance/Hue/Grayscale/
|
|
313
|
+
* 六个 ColorMatrix 固定滤镜/Invert/Convolute 锐化·浮雕/BlendColor/Blur/
|
|
314
|
+
* Pixelate)+ 应用自定义 16 款全量 + 组合(滤镜栈序、滤镜×裁剪、滤镜×
|
|
315
|
+
* 旋转翻转、滤镜×原生 shadow、滤镜×PSD 投影)。
|
|
316
|
+
* 规避:内置 Noise(uSeed=Math.random() 每渲染重掷,不可逐像素对拍——
|
|
317
|
+
* FilmGrain 的 seed 序列化确定性已覆盖哈希噪声路径)。
|
|
318
|
+
*/
|
|
319
|
+
export const makeFilterImageScene = () => {
|
|
320
|
+
const base = {
|
|
321
|
+
type: 'image',
|
|
322
|
+
scaleX: 1,
|
|
323
|
+
scaleY: 1,
|
|
324
|
+
angle: 0,
|
|
325
|
+
originX: 'left',
|
|
326
|
+
originY: 'top',
|
|
327
|
+
opacity: 1,
|
|
328
|
+
strokeWidth: 0,
|
|
329
|
+
visible: true,
|
|
330
|
+
src: assetUrl('../../assets/images/rotate.png')
|
|
331
|
+
};
|
|
332
|
+
const fabricSrc = assetUrl('../../assets/images/nasty_fabric.png');
|
|
333
|
+
// 4 列网格:格 240×240(图 200×200 + 40 呼吸),行主序落位
|
|
334
|
+
const grid = (i) => ({ left: 40 + (i % 4) * 240, top: 40 + Math.floor(i / 4) * 240 });
|
|
335
|
+
const one = (i, filters, extra = {}) => ({
|
|
336
|
+
...base,
|
|
337
|
+
id: `f${i}`,
|
|
338
|
+
...grid(i),
|
|
339
|
+
filters,
|
|
340
|
+
...extra
|
|
341
|
+
});
|
|
342
|
+
return [
|
|
343
|
+
// ---- fabric 内置 ----
|
|
344
|
+
one(0, [{ type: 'Brightness', brightness: 0.3 }]),
|
|
345
|
+
one(1, [{ type: 'Contrast', contrast: 0.35 }]),
|
|
346
|
+
one(2, [{ type: 'Saturation', saturation: 0.5 }]),
|
|
347
|
+
one(3, [{ type: 'Vibrance', vibrance: 0.4 }]),
|
|
348
|
+
one(4, [{ type: 'HueRotation', rotation: 0.5 }]),
|
|
349
|
+
one(5, [{ type: 'Grayscale', mode: 'average' }]),
|
|
350
|
+
one(6, [{ type: 'Sepia', colorsOnly: false }]),
|
|
351
|
+
one(7, [{ type: 'Brownie', colorsOnly: false }]),
|
|
352
|
+
one(8, [{ type: 'Kodachrome', colorsOnly: false }]),
|
|
353
|
+
one(9, [{ type: 'Technicolor', colorsOnly: false }]),
|
|
354
|
+
one(10, [{ type: 'Polaroid', colorsOnly: false }]),
|
|
355
|
+
one(11, [{ type: 'BlackWhite', colorsOnly: false }]),
|
|
356
|
+
one(12, [{ type: 'Invert', invert: true, alphaOnly: false }]),
|
|
357
|
+
// 锐化(UI 预设 Convolute 矩阵)/ 浮雕
|
|
358
|
+
one(13, [{ type: 'Convolute', opaque: false, matrix: [0, -1, 0, -1, 5, -1, 0, -1, 0] }]),
|
|
359
|
+
one(14, [{ type: 'Convolute', opaque: false, matrix: [1, 1, 1, 1, 0.7, -1, -1, -1, -1] }]),
|
|
360
|
+
// 着色(UI 预设 BlendColor overlay)
|
|
361
|
+
one(15, [{ type: 'BlendColor', color: '#ff6600', mode: 'overlay', alpha: 0.4 }]),
|
|
362
|
+
// PS 口径高斯:blur = 像素半径(σ=r/2 三趟 box,2026-09-21 对齐批次)
|
|
363
|
+
one(16, [{ type: 'Blur', blur: 8 }]),
|
|
364
|
+
one(17, [{ type: 'Pixelate', blocksize: 6 }]),
|
|
365
|
+
// ---- 应用自定义 16 款 ----
|
|
366
|
+
one(18, [{ type: 'Vignette', intensity: 0.6 }]),
|
|
367
|
+
one(19, [{ type: 'Temperature', temperature: 0.5 }]),
|
|
368
|
+
one(20, [{ type: 'Posterize', levels: 6 }]),
|
|
369
|
+
one(21, [{ type: 'FilmGrain', intensity: 0.35, seed: 7.13 }]),
|
|
370
|
+
one(22, [{ type: 'Duotone', color1: '#2E003E', color2: '#FF6EC7' }]),
|
|
371
|
+
one(23, [{ type: 'Sketch' }]),
|
|
372
|
+
one(24, [{ type: 'ChromaticAberration', offset: 6 }]),
|
|
373
|
+
one(25, [{ type: 'SoftFocus', blend: 0.6 }]),
|
|
374
|
+
one(26, [{ type: 'Threshold', threshold: 128 }]),
|
|
375
|
+
one(27, [{ type: 'UnsharpMask', amount: 1.2 }]),
|
|
376
|
+
one(28, [{ type: 'MotionBlur', distance: 0.15, angle: 0.3 }]),
|
|
377
|
+
one(29, [{ type: 'LensFlare', intensity: 0.8 }]),
|
|
378
|
+
one(30, [{ type: 'GradientMap', color0: '#0a0020', color1: '#ff4466', color2: '#ffdd44' }]),
|
|
379
|
+
one(31, [{ type: 'GradientMap', color0: '#001040', color1: '#ffe0b0' }]),
|
|
380
|
+
one(32, [{ type: 'Levels', blackPoint: 30, whitePoint: 220, gamma: 1.4 }]),
|
|
381
|
+
one(33, [{ type: 'SurfaceBlur', radius: 3, threshold: 0.2 }]),
|
|
382
|
+
one(34, [{ type: 'Exposure', exposure: 0.6, offset: 0, gamma: 1 }]),
|
|
383
|
+
// ---- 组合 ----
|
|
384
|
+
// 滤镜栈(滑块叠加序:Brightness → Contrast → Vignette,序敏感)
|
|
385
|
+
one(35, [
|
|
386
|
+
{ type: 'Brightness', brightness: 0.15 },
|
|
387
|
+
{ type: 'Contrast', contrast: 0.25 },
|
|
388
|
+
{ type: 'Vignette', intensity: 0.5 }
|
|
389
|
+
]),
|
|
390
|
+
// 滤镜 × 裁剪(visible 口径):滤镜跑全图、cropX/Y 后开窗
|
|
391
|
+
one(36, [{ type: 'Sepia', colorsOnly: false }], { cropX: 30, cropY: 30, width: 120, height: 120, cropSizeMode: 'visible' }),
|
|
392
|
+
// 滤镜 × 旋转 + 翻转
|
|
393
|
+
one(37, [{ type: 'Duotone', color1: '#102040', color2: '#FFD070' }], { src: fabricSrc, angle: 25, flipX: true, scaleX: 1.4, scaleY: 1.4 }),
|
|
394
|
+
// 滤镜 × 原生 shadow(alpha 保持 → 剪影不受滤镜影响)
|
|
395
|
+
one(38, [{ type: 'Grayscale', mode: 'luminosity' }], {
|
|
396
|
+
shadow: { color: 'rgba(40,40,60,0.45)', blur: 12, offsetX: 10, offsetY: 10, affectStroke: false, nonScaling: false }
|
|
397
|
+
}),
|
|
398
|
+
// 滤镜 × PSD 投影(effects 分支走应用 FabricImage——两条定制链同图组合)
|
|
399
|
+
one(39, [{ type: 'Technicolor', colorsOnly: false }], {
|
|
400
|
+
angle: 15,
|
|
401
|
+
scaleX: 1.3,
|
|
402
|
+
scaleY: 1.3,
|
|
403
|
+
effects: { dropShadow: [{ enabled: true, showInDialog: true, fill: 'rgba(60,50,40,0.45)', blur: 10, offsetX: 12, offsetY: 12 }] }
|
|
404
|
+
})
|
|
405
|
+
];
|
|
406
|
+
};
|
|
407
|
+
/**
|
|
408
|
+
* 文本场景(Phase 2a):CJK/拉丁/混排 + 换行/对齐/字距/行距组合。
|
|
409
|
+
* 字体用 chromium 内置族(避免 e2e 环境字体加载差异),字号偏大(hinting 差异
|
|
410
|
+
* 随字号增大而稀释)。覆盖:硬换行、自动换行、center/right、charSpacing、
|
|
411
|
+
* 多行 lineHeight、无换行 text 类型;P2-2 增补:逐字 fontSize/fontFamily
|
|
412
|
+
* 混排(t7 换行度量 + t8 无换行);justify 增补:t9 纯 justify 多行拉伸
|
|
413
|
+
* (含末行)、t10 justify-center 段末行居中收尾 + CJK 无空格行不拉伸。
|
|
414
|
+
*/
|
|
415
|
+
export const makeTextScene = () => {
|
|
416
|
+
const base = {
|
|
417
|
+
type: 'textbox',
|
|
418
|
+
scaleX: 1,
|
|
419
|
+
scaleY: 1,
|
|
420
|
+
angle: 0,
|
|
421
|
+
originX: 'left',
|
|
422
|
+
originY: 'top',
|
|
423
|
+
opacity: 1,
|
|
424
|
+
strokeWidth: 0,
|
|
425
|
+
visible: true,
|
|
426
|
+
fill: '#1a1a1a'
|
|
427
|
+
};
|
|
428
|
+
return [
|
|
429
|
+
{
|
|
430
|
+
...base,
|
|
431
|
+
id: 't0',
|
|
432
|
+
left: 80,
|
|
433
|
+
top: 60,
|
|
434
|
+
width: 620,
|
|
435
|
+
text: '你好,WebGL2 设计引擎!字形图集渲染。',
|
|
436
|
+
fontFamily: 'sans-serif',
|
|
437
|
+
fontSize: 56,
|
|
438
|
+
fontWeight: 'bold',
|
|
439
|
+
lineHeight: 1.16,
|
|
440
|
+
charSpacing: 0,
|
|
441
|
+
textAlign: 'left'
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
...base,
|
|
445
|
+
id: 't6',
|
|
446
|
+
left: 80,
|
|
447
|
+
top: 640,
|
|
448
|
+
width: 560,
|
|
449
|
+
text: 'Rich text with per char colors and highlight marks 你好。',
|
|
450
|
+
fontFamily: 'sans-serif',
|
|
451
|
+
fontSize: 38,
|
|
452
|
+
lineHeight: 1.3,
|
|
453
|
+
charSpacing: 0,
|
|
454
|
+
textAlign: 'left',
|
|
455
|
+
fill: '#101010',
|
|
456
|
+
// 逐字符样式(fabric styles 结构):两段着色 + 一段高亮
|
|
457
|
+
styles: {
|
|
458
|
+
0: {
|
|
459
|
+
0: { fill: '#c03030' },
|
|
460
|
+
1: { fill: '#c03030' },
|
|
461
|
+
2: { fill: '#c03030' },
|
|
462
|
+
3: { fill: '#c03030' },
|
|
463
|
+
10: { fill: '#2060c0', textBackgroundColor: '#ffe08a' },
|
|
464
|
+
11: { fill: '#2060c0', textBackgroundColor: '#ffe08a' },
|
|
465
|
+
12: { fill: '#2060c0', textBackgroundColor: '#ffe08a' },
|
|
466
|
+
13: { fill: '#2060c0', textBackgroundColor: '#ffe08a' },
|
|
467
|
+
14: { fill: '#2060c0', textBackgroundColor: '#ffe08a' }
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
...base,
|
|
473
|
+
id: 't1',
|
|
474
|
+
left: 80,
|
|
475
|
+
top: 200,
|
|
476
|
+
width: 400,
|
|
477
|
+
text: 'The quick brown fox jumps over the lazy dog and wraps here.',
|
|
478
|
+
fontFamily: 'serif',
|
|
479
|
+
fontSize: 40,
|
|
480
|
+
lineHeight: 1.25,
|
|
481
|
+
charSpacing: 0,
|
|
482
|
+
textAlign: 'left',
|
|
483
|
+
fill: '#2050a0'
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
...base,
|
|
487
|
+
id: 't2',
|
|
488
|
+
left: 80,
|
|
489
|
+
top: 420,
|
|
490
|
+
width: 520,
|
|
491
|
+
text: '居中对齐的中文标题\n第二行小字 world',
|
|
492
|
+
fontFamily: 'sans-serif',
|
|
493
|
+
fontSize: 48,
|
|
494
|
+
lineHeight: 1.4,
|
|
495
|
+
charSpacing: 80,
|
|
496
|
+
textAlign: 'center',
|
|
497
|
+
fill: '#a03030'
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
...base,
|
|
501
|
+
id: 't3',
|
|
502
|
+
left: 700,
|
|
503
|
+
top: 60,
|
|
504
|
+
width: 460,
|
|
505
|
+
text: '右对齐 Right aligned with spacing.',
|
|
506
|
+
fontFamily: 'monospace',
|
|
507
|
+
fontSize: 32,
|
|
508
|
+
lineHeight: 1.16,
|
|
509
|
+
charSpacing: 50,
|
|
510
|
+
textAlign: 'right',
|
|
511
|
+
fill: '#106010'
|
|
512
|
+
},
|
|
513
|
+
{
|
|
514
|
+
...base,
|
|
515
|
+
id: 't4',
|
|
516
|
+
left: 700,
|
|
517
|
+
top: 240,
|
|
518
|
+
width: 480,
|
|
519
|
+
text: '自动换行的中文长句会按照盒宽在词语与字符之间断行,验证 CJK 换行状态机。',
|
|
520
|
+
fontFamily: 'sans-serif',
|
|
521
|
+
fontSize: 36,
|
|
522
|
+
lineHeight: 1.5,
|
|
523
|
+
charSpacing: 0,
|
|
524
|
+
textAlign: 'left',
|
|
525
|
+
fill: '#404040'
|
|
526
|
+
},
|
|
527
|
+
{
|
|
528
|
+
...base,
|
|
529
|
+
id: 't5',
|
|
530
|
+
left: 700,
|
|
531
|
+
top: 520,
|
|
532
|
+
width: 480,
|
|
533
|
+
text: '不换行的 text 类型:Single line no wrap.',
|
|
534
|
+
type: 'text',
|
|
535
|
+
fontFamily: 'serif',
|
|
536
|
+
fontSize: 34,
|
|
537
|
+
lineHeight: 1.16,
|
|
538
|
+
charSpacing: 0,
|
|
539
|
+
textAlign: 'left',
|
|
540
|
+
fill: '#704080'
|
|
541
|
+
},
|
|
542
|
+
{
|
|
543
|
+
...base,
|
|
544
|
+
id: 't7',
|
|
545
|
+
left: 700,
|
|
546
|
+
top: 585,
|
|
547
|
+
width: 460,
|
|
548
|
+
// P2-2:逐字 fontSize/fontFamily 参与度量——混排字号行高、异族字体宽度、
|
|
549
|
+
// 大字号词撑盒(dynamicMinWidth)、换行吃掉的空格按原始偏移样式度量
|
|
550
|
+
text: 'Mixed sizes Big word fonts 混排字号.',
|
|
551
|
+
fontFamily: 'sans-serif',
|
|
552
|
+
fontSize: 24,
|
|
553
|
+
lineHeight: 1.35,
|
|
554
|
+
charSpacing: 0,
|
|
555
|
+
textAlign: 'left',
|
|
556
|
+
fill: '#303030',
|
|
557
|
+
styles: {
|
|
558
|
+
0: {
|
|
559
|
+
// 索引对应 "Mixed sizes Big word fonts 混排字号.":
|
|
560
|
+
// 6-7="si"(sizes 提到 40)、12-14="Big"(serif 36)、16-19="word"(monospace 30)
|
|
561
|
+
6: { fontSize: 40, fill: '#c03030' },
|
|
562
|
+
7: { fontSize: 40, fill: '#c03030' },
|
|
563
|
+
8: { fontSize: 40, fill: '#c03030' },
|
|
564
|
+
9: { fontSize: 40, fill: '#c03030' },
|
|
565
|
+
10: { fontSize: 40, fill: '#c03030' },
|
|
566
|
+
12: { fontSize: 36, fontFamily: 'serif' },
|
|
567
|
+
13: { fontSize: 36, fontFamily: 'serif' },
|
|
568
|
+
14: { fontSize: 36, fontFamily: 'serif' },
|
|
569
|
+
16: { fontSize: 30, fontFamily: 'monospace' },
|
|
570
|
+
17: { fontSize: 30, fontFamily: 'monospace' },
|
|
571
|
+
18: { fontSize: 30, fontFamily: 'monospace' },
|
|
572
|
+
19: { fontSize: 30, fontFamily: 'monospace' }
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
},
|
|
576
|
+
{
|
|
577
|
+
...base,
|
|
578
|
+
id: 't8',
|
|
579
|
+
left: 700,
|
|
580
|
+
top: 672,
|
|
581
|
+
// 不换行类型 + 逐字字号(光标/选区行高随逐字 max)
|
|
582
|
+
text: 'Cursor in mixed 123',
|
|
583
|
+
type: 'text',
|
|
584
|
+
fontFamily: 'sans-serif',
|
|
585
|
+
fontSize: 26,
|
|
586
|
+
lineHeight: 1.16,
|
|
587
|
+
charSpacing: 0,
|
|
588
|
+
textAlign: 'left',
|
|
589
|
+
fill: '#106040',
|
|
590
|
+
styles: {
|
|
591
|
+
0: {
|
|
592
|
+
17: { fontSize: 44 },
|
|
593
|
+
18: { fontSize: 44 }
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
},
|
|
597
|
+
{
|
|
598
|
+
...base,
|
|
599
|
+
id: 't9',
|
|
600
|
+
left: 80,
|
|
601
|
+
top: 760,
|
|
602
|
+
width: 400,
|
|
603
|
+
// 两端对齐(fabric enlargeSpaces 同源):多行词隙拉伸;末行含空格同样
|
|
604
|
+
// 拉满(fabric 纯 justify 的历史行为,不做末行豁免)。文本/几何沿用 t1
|
|
605
|
+
// 的组合(该组合下 justify 全变体与 fabric 参考侧逐像素一致)
|
|
606
|
+
text: 'The quick brown fox jumps over the lazy dog and wraps here.',
|
|
607
|
+
fontFamily: 'serif',
|
|
608
|
+
fontSize: 40,
|
|
609
|
+
lineHeight: 1.25,
|
|
610
|
+
charSpacing: 0,
|
|
611
|
+
textAlign: 'justify',
|
|
612
|
+
fill: '#303030'
|
|
613
|
+
},
|
|
614
|
+
{
|
|
615
|
+
...base,
|
|
616
|
+
id: 't10',
|
|
617
|
+
left: 700,
|
|
618
|
+
top: 760,
|
|
619
|
+
width: 460,
|
|
620
|
+
// justify-center 变体:非段末行拉伸、段末行居中收尾;CJK 无空格行不拉伸
|
|
621
|
+
text: '两端对齐的中英混排 stretch spaces between words\nCJK 行没有空格不可拉伸',
|
|
622
|
+
fontFamily: 'sans-serif',
|
|
623
|
+
fontSize: 28,
|
|
624
|
+
lineHeight: 1.35,
|
|
625
|
+
charSpacing: 0,
|
|
626
|
+
textAlign: 'justify-center',
|
|
627
|
+
fill: '#204080'
|
|
628
|
+
}
|
|
629
|
+
];
|
|
630
|
+
};
|
|
631
|
+
/**
|
|
632
|
+
* 描边文本场景(Phase 2 P2-3)。
|
|
633
|
+
*
|
|
634
|
+
* 覆盖描边的四条语义:
|
|
635
|
+
* - k0/k1:同一文本、paintFirst 两种(fill 先 / stroke 先)——两遍渲染的顺序语义;
|
|
636
|
+
* - k2:fill 为空 = 纯描边(fabric `_renderTextFill` 整体跳过);
|
|
637
|
+
* - k3:逐字 stroke/strokeWidth 覆写(fabric fullDecl 合并语义);
|
|
638
|
+
* - k4:不带 strokeWidth(两侧都按 fabric 类默认 1);
|
|
639
|
+
* - k5:有 strokeWidth 但 stroke 为空——两侧都不画描边,但**文本整体偏移
|
|
640
|
+
* strokeWidth/2**(fabric 把 strokeWidth 计入变换尺寸),这条锁的是位置语义;
|
|
641
|
+
* - k6:带 scale/角度(变换链 + 描边随对象缩放);
|
|
642
|
+
* - k7:多行 + 半透明描边(考察逐字形合成)。
|
|
643
|
+
*
|
|
644
|
+
* 字号偏大(hinting 差随字号稀释)、字体用 chromium 内置族(避免字体加载差异)。
|
|
645
|
+
* 虚线描边(strokeDashArray)不在本场景:fabric 按行/run 一次 strokeText(相位连续),
|
|
646
|
+
* 引擎图集逐字形 cell(相位逐字重来),属 P3-2 的 run 级栅格化议题。
|
|
647
|
+
*/
|
|
648
|
+
export const makeStrokeTextScene = () => {
|
|
649
|
+
const base = {
|
|
650
|
+
type: 'textbox',
|
|
651
|
+
scaleX: 1,
|
|
652
|
+
scaleY: 1,
|
|
653
|
+
angle: 0,
|
|
654
|
+
originX: 'left',
|
|
655
|
+
originY: 'top',
|
|
656
|
+
opacity: 1,
|
|
657
|
+
strokeWidth: 0,
|
|
658
|
+
visible: true,
|
|
659
|
+
fill: '#1a1a1a'
|
|
660
|
+
};
|
|
661
|
+
return [
|
|
662
|
+
{
|
|
663
|
+
...base,
|
|
664
|
+
id: 'k0',
|
|
665
|
+
left: 40,
|
|
666
|
+
top: 30,
|
|
667
|
+
width: 560,
|
|
668
|
+
text: '描边标题 Outline',
|
|
669
|
+
fontFamily: 'sans-serif',
|
|
670
|
+
fontSize: 56,
|
|
671
|
+
fontWeight: 'bold',
|
|
672
|
+
lineHeight: 1.16,
|
|
673
|
+
stroke: '#c03030',
|
|
674
|
+
strokeWidth: 8,
|
|
675
|
+
paintFirst: 'fill'
|
|
676
|
+
},
|
|
677
|
+
{
|
|
678
|
+
...base,
|
|
679
|
+
id: 'k1',
|
|
680
|
+
left: 640,
|
|
681
|
+
top: 30,
|
|
682
|
+
width: 560,
|
|
683
|
+
text: 'Stroke First 外描边',
|
|
684
|
+
fontFamily: 'sans-serif',
|
|
685
|
+
fontSize: 56,
|
|
686
|
+
fontWeight: 'bold',
|
|
687
|
+
lineHeight: 1.16,
|
|
688
|
+
stroke: '#c03030',
|
|
689
|
+
strokeWidth: 8,
|
|
690
|
+
paintFirst: 'stroke'
|
|
691
|
+
},
|
|
692
|
+
{
|
|
693
|
+
...base,
|
|
694
|
+
id: 'k2',
|
|
695
|
+
left: 40,
|
|
696
|
+
top: 160,
|
|
697
|
+
width: 560,
|
|
698
|
+
text: '纯描边 Outline only',
|
|
699
|
+
fontFamily: 'serif',
|
|
700
|
+
fontSize: 48,
|
|
701
|
+
lineHeight: 1.16,
|
|
702
|
+
fill: '',
|
|
703
|
+
stroke: '#2060c0',
|
|
704
|
+
strokeWidth: 3
|
|
705
|
+
},
|
|
706
|
+
{
|
|
707
|
+
...base,
|
|
708
|
+
id: 'k3',
|
|
709
|
+
left: 640,
|
|
710
|
+
top: 160,
|
|
711
|
+
width: 560,
|
|
712
|
+
text: 'Per char stroke 逐字描边',
|
|
713
|
+
fontFamily: 'sans-serif',
|
|
714
|
+
fontSize: 40,
|
|
715
|
+
lineHeight: 1.3,
|
|
716
|
+
fill: '#202020',
|
|
717
|
+
stroke: '#104010',
|
|
718
|
+
strokeWidth: 3,
|
|
719
|
+
// 索引对应 "Per char stroke 逐字描边":0-2='Per'、4-7='char' 加粗描边
|
|
720
|
+
styles: {
|
|
721
|
+
0: {
|
|
722
|
+
0: { strokeWidth: 12, stroke: '#c03030' },
|
|
723
|
+
1: { strokeWidth: 12, stroke: '#c03030' },
|
|
724
|
+
2: { strokeWidth: 12, stroke: '#c03030' },
|
|
725
|
+
4: { stroke: '#7030a0', strokeWidth: 8 },
|
|
726
|
+
5: { stroke: '#7030a0', strokeWidth: 8 },
|
|
727
|
+
6: { stroke: '#7030a0', strokeWidth: 8 },
|
|
728
|
+
7: { stroke: '#7030a0', strokeWidth: 8 }
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
},
|
|
732
|
+
{
|
|
733
|
+
...base,
|
|
734
|
+
id: 'k4',
|
|
735
|
+
left: 40,
|
|
736
|
+
top: 290,
|
|
737
|
+
width: 700,
|
|
738
|
+
text: 'default width 缺省线宽',
|
|
739
|
+
fontFamily: 'monospace',
|
|
740
|
+
fontSize: 44,
|
|
741
|
+
lineHeight: 1.16,
|
|
742
|
+
fill: '#303030',
|
|
743
|
+
stroke: '#704080'
|
|
744
|
+
},
|
|
745
|
+
{
|
|
746
|
+
...base,
|
|
747
|
+
id: 'k5',
|
|
748
|
+
left: 640,
|
|
749
|
+
top: 300,
|
|
750
|
+
width: 560,
|
|
751
|
+
text: 'no stroke, width 6 只有宽度',
|
|
752
|
+
fontFamily: 'sans-serif',
|
|
753
|
+
fontSize: 40,
|
|
754
|
+
lineHeight: 1.16,
|
|
755
|
+
fill: '#202020',
|
|
756
|
+
strokeWidth: 6
|
|
757
|
+
},
|
|
758
|
+
{
|
|
759
|
+
...base,
|
|
760
|
+
id: 'k6',
|
|
761
|
+
left: 40,
|
|
762
|
+
top: 420,
|
|
763
|
+
width: 700,
|
|
764
|
+
text: '带缩放与角度 描边',
|
|
765
|
+
fontFamily: 'sans-serif',
|
|
766
|
+
fontSize: 44,
|
|
767
|
+
fontWeight: 'bold',
|
|
768
|
+
lineHeight: 1.16,
|
|
769
|
+
fill: '#1a1a1a',
|
|
770
|
+
stroke: '#e0a020',
|
|
771
|
+
strokeWidth: 5,
|
|
772
|
+
scaleX: 1.2,
|
|
773
|
+
scaleY: 0.9,
|
|
774
|
+
angle: 8
|
|
775
|
+
},
|
|
776
|
+
{
|
|
777
|
+
...base,
|
|
778
|
+
id: 'k7',
|
|
779
|
+
left: 640,
|
|
780
|
+
top: 440,
|
|
781
|
+
width: 560,
|
|
782
|
+
text: '两行描边文本\nsecond line',
|
|
783
|
+
fontFamily: 'sans-serif',
|
|
784
|
+
fontSize: 36,
|
|
785
|
+
lineHeight: 1.3,
|
|
786
|
+
fill: '#202020',
|
|
787
|
+
stroke: 'rgba(16, 96, 64, 0.6)',
|
|
788
|
+
strokeWidth: 2.5
|
|
789
|
+
}
|
|
790
|
+
];
|
|
791
|
+
};
|
|
792
|
+
/**
|
|
793
|
+
* 装饰线文本场景(Phase 2 P2-4):underline / overline / linethrough。
|
|
794
|
+
*
|
|
795
|
+
* 覆盖的语义分层:
|
|
796
|
+
* - d0/d1/d2:对象级三线型各一(y 偏移系数 0.1 / −0.28167 / −0.81333);
|
|
797
|
+
* - d3:逐字 underline 开关 + 逐字 fill(装饰色跟 fill、fill 变化断段);
|
|
798
|
+
* - d4:对象级 on + 逐字 textDecorationThickness 覆写(线宽 = 对象 fontSize × ‰);
|
|
799
|
+
* - d5:charSpacing + underline(行末 flush 宽度扣除一次对象级 spacing);
|
|
800
|
+
* - d6:逐字 fontSize 混排 + underline(run 按 size 断段、y 用段首字号、
|
|
801
|
+
* 线宽仍按对象 fontSize);
|
|
802
|
+
* - d7:三线全开 + scale/角度 + 多行(变换链 + 逐行独立 run)。
|
|
803
|
+
*
|
|
804
|
+
* 刻意不带 textBackgroundColor:布局 parity 走 fillRect 探针对拍,背景高亮的
|
|
805
|
+
* fillRect 会混入记录(探针按类型隔离已排除字形 fillText,背景属第三来源)。
|
|
806
|
+
* deltaY 不进场景(引擎暂不支持逐字 deltaY)。
|
|
807
|
+
*/
|
|
808
|
+
export const makeDecorationTextScene = () => {
|
|
809
|
+
const base = {
|
|
810
|
+
type: 'textbox',
|
|
811
|
+
scaleX: 1,
|
|
812
|
+
scaleY: 1,
|
|
813
|
+
angle: 0,
|
|
814
|
+
originX: 'left',
|
|
815
|
+
originY: 'top',
|
|
816
|
+
opacity: 1,
|
|
817
|
+
strokeWidth: 0,
|
|
818
|
+
visible: true,
|
|
819
|
+
fill: '#1a1a1a'
|
|
820
|
+
};
|
|
821
|
+
return [
|
|
822
|
+
{
|
|
823
|
+
...base,
|
|
824
|
+
id: 'd0',
|
|
825
|
+
left: 40,
|
|
826
|
+
top: 30,
|
|
827
|
+
width: 560,
|
|
828
|
+
text: '下划线标题 Underline',
|
|
829
|
+
fontFamily: 'sans-serif',
|
|
830
|
+
fontSize: 52,
|
|
831
|
+
fontWeight: 'bold',
|
|
832
|
+
lineHeight: 1.16,
|
|
833
|
+
underline: true
|
|
834
|
+
},
|
|
835
|
+
{
|
|
836
|
+
...base,
|
|
837
|
+
id: 'd1',
|
|
838
|
+
left: 640,
|
|
839
|
+
top: 30,
|
|
840
|
+
width: 560,
|
|
841
|
+
text: '删除线 Strikethrough',
|
|
842
|
+
fontFamily: 'serif',
|
|
843
|
+
fontSize: 46,
|
|
844
|
+
lineHeight: 1.16,
|
|
845
|
+
linethrough: true,
|
|
846
|
+
fill: '#803030'
|
|
847
|
+
},
|
|
848
|
+
{
|
|
849
|
+
...base,
|
|
850
|
+
id: 'd2',
|
|
851
|
+
left: 40,
|
|
852
|
+
top: 160,
|
|
853
|
+
width: 560,
|
|
854
|
+
text: '上划线 Overline',
|
|
855
|
+
fontFamily: 'monospace',
|
|
856
|
+
fontSize: 40,
|
|
857
|
+
lineHeight: 1.16,
|
|
858
|
+
overline: true,
|
|
859
|
+
fill: '#206080'
|
|
860
|
+
},
|
|
861
|
+
{
|
|
862
|
+
...base,
|
|
863
|
+
id: 'd3',
|
|
864
|
+
left: 640,
|
|
865
|
+
top: 160,
|
|
866
|
+
width: 620,
|
|
867
|
+
text: 'Per char style 装饰线',
|
|
868
|
+
fontFamily: 'sans-serif',
|
|
869
|
+
fontSize: 40,
|
|
870
|
+
lineHeight: 1.3,
|
|
871
|
+
fill: '#303030',
|
|
872
|
+
// 索引对应 "Per char style 装饰线":0-2='Per'、4-7='char'、9-13='style'、15-17='装饰线'
|
|
873
|
+
styles: {
|
|
874
|
+
0: {
|
|
875
|
+
0: { underline: true, fill: '#c03030' },
|
|
876
|
+
1: { underline: true, fill: '#c03030' },
|
|
877
|
+
2: { underline: true, fill: '#c03030' },
|
|
878
|
+
4: { underline: true, fill: '#2060c0' },
|
|
879
|
+
5: { underline: true, fill: '#2060c0' },
|
|
880
|
+
6: { underline: true, fill: '#2060c0' },
|
|
881
|
+
7: { underline: true, fill: '#2060c0' },
|
|
882
|
+
9: { underline: true },
|
|
883
|
+
10: { underline: true },
|
|
884
|
+
11: { underline: true },
|
|
885
|
+
12: { underline: true },
|
|
886
|
+
13: { underline: true },
|
|
887
|
+
15: { underline: true, fill: '#106040' },
|
|
888
|
+
16: { underline: true, fill: '#106040' },
|
|
889
|
+
17: { underline: true, fill: '#106040' }
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
},
|
|
893
|
+
{
|
|
894
|
+
...base,
|
|
895
|
+
id: 'd4',
|
|
896
|
+
left: 40,
|
|
897
|
+
top: 300,
|
|
898
|
+
width: 620,
|
|
899
|
+
text: '粗线 Thick 线宽覆写',
|
|
900
|
+
fontFamily: 'sans-serif',
|
|
901
|
+
fontSize: 44,
|
|
902
|
+
lineHeight: 1.2,
|
|
903
|
+
underline: true,
|
|
904
|
+
fill: '#404040',
|
|
905
|
+
// 索引对应 "粗线 Thick 线宽覆写":0-1='粗线'(250‰ 粗线)、3-7='Thick'(200‰)
|
|
906
|
+
styles: {
|
|
907
|
+
0: {
|
|
908
|
+
0: { textDecorationThickness: 250 },
|
|
909
|
+
1: { textDecorationThickness: 250 },
|
|
910
|
+
3: { textDecorationThickness: 200 },
|
|
911
|
+
4: { textDecorationThickness: 200 },
|
|
912
|
+
5: { textDecorationThickness: 200 },
|
|
913
|
+
6: { textDecorationThickness: 200 },
|
|
914
|
+
7: { textDecorationThickness: 200 }
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
},
|
|
918
|
+
{
|
|
919
|
+
...base,
|
|
920
|
+
id: 'd5',
|
|
921
|
+
left: 640,
|
|
922
|
+
top: 320,
|
|
923
|
+
width: 560,
|
|
924
|
+
text: '字距 Spacing 下划线',
|
|
925
|
+
fontFamily: 'serif',
|
|
926
|
+
fontSize: 40,
|
|
927
|
+
lineHeight: 1.16,
|
|
928
|
+
charSpacing: 80,
|
|
929
|
+
underline: true,
|
|
930
|
+
fill: '#505030'
|
|
931
|
+
},
|
|
932
|
+
{
|
|
933
|
+
...base,
|
|
934
|
+
id: 'd6',
|
|
935
|
+
left: 40,
|
|
936
|
+
top: 430,
|
|
937
|
+
width: 620,
|
|
938
|
+
text: 'Mixed sizes 装饰线',
|
|
939
|
+
fontFamily: 'sans-serif',
|
|
940
|
+
fontSize: 24,
|
|
941
|
+
lineHeight: 1.35,
|
|
942
|
+
underline: true,
|
|
943
|
+
fill: '#303030',
|
|
944
|
+
// 索引对应 "Mixed sizes 装饰线":0-4='Mixed'(fontSize 44)
|
|
945
|
+
styles: {
|
|
946
|
+
0: {
|
|
947
|
+
0: { fontSize: 44 },
|
|
948
|
+
1: { fontSize: 44 },
|
|
949
|
+
2: { fontSize: 44 },
|
|
950
|
+
3: { fontSize: 44 },
|
|
951
|
+
4: { fontSize: 44 }
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
},
|
|
955
|
+
{
|
|
956
|
+
...base,
|
|
957
|
+
id: 'd7',
|
|
958
|
+
left: 640,
|
|
959
|
+
top: 450,
|
|
960
|
+
width: 560,
|
|
961
|
+
text: '三线全开\nsecond line',
|
|
962
|
+
fontFamily: 'sans-serif',
|
|
963
|
+
fontSize: 34,
|
|
964
|
+
lineHeight: 1.3,
|
|
965
|
+
underline: true,
|
|
966
|
+
overline: true,
|
|
967
|
+
linethrough: true,
|
|
968
|
+
fill: '#402050',
|
|
969
|
+
scaleX: 1.15,
|
|
970
|
+
scaleY: 0.95,
|
|
971
|
+
angle: 6
|
|
972
|
+
}
|
|
973
|
+
];
|
|
974
|
+
};
|
|
975
|
+
/**
|
|
976
|
+
* 渐变填充场景(Phase 3 P3-3):linear/radial × rect/形状 + 坐标系变体。
|
|
977
|
+
*
|
|
978
|
+
* 覆盖的语义分层(渐变坐标原点在对象左上角、pixels 系单位为对象未变换像素):
|
|
979
|
+
* - g0/g1:linear 水平/垂直(端点轴投影的 t);
|
|
980
|
+
* - g2:linear 对角 + 对象带角度与 scale(变换链下渐变随对象本地空间);
|
|
981
|
+
* - g3:radial 同心(r1=0 → t=|q−c|/r2 的闭式根验证面);
|
|
982
|
+
* - g4:radial 非同心(x1≠x2,圆族二次方程的判别式路径);
|
|
983
|
+
* - g5:percentage 系(coords 为 0..1 分数,合成矩阵多乘 scale(w,h));
|
|
984
|
+
* - g6:linear 多 stop + 中段透明 stop(预乘空间插值 vs 直通的区分度);
|
|
985
|
+
* - g7:凹 L 形 radial(三角化网格的逐片元渐变);
|
|
986
|
+
* - g8:gradientTransform 旋转 30°(合成矩阵第三段);
|
|
987
|
+
* - g9:offsetX/offsetY 平移渐变 + 对象半透明(globalAlpha 乘法)。
|
|
988
|
+
*
|
|
989
|
+
* 文本渐变不进场景(引擎字形管线暂以首 stop 近似,P3-3 已知缺口)。
|
|
990
|
+
*/
|
|
991
|
+
export const makeGradientScene = () => {
|
|
992
|
+
const base = {
|
|
993
|
+
// 占位(每个条目各自覆写 type)
|
|
994
|
+
type: 'rect',
|
|
995
|
+
scaleX: 1,
|
|
996
|
+
scaleY: 1,
|
|
997
|
+
angle: 0,
|
|
998
|
+
originX: 'left',
|
|
999
|
+
originY: 'top',
|
|
1000
|
+
opacity: 1,
|
|
1001
|
+
strokeWidth: 0,
|
|
1002
|
+
visible: true
|
|
1003
|
+
};
|
|
1004
|
+
const lin = (x1, y1, x2, y2, stops, extra = {}) => ({
|
|
1005
|
+
type: 'linear',
|
|
1006
|
+
coords: { x1, y1, x2, y2 },
|
|
1007
|
+
colorStops: stops.map(([offset, color]) => ({ offset, color })),
|
|
1008
|
+
offsetX: 0,
|
|
1009
|
+
offsetY: 0,
|
|
1010
|
+
gradientUnits: 'pixels',
|
|
1011
|
+
...extra
|
|
1012
|
+
});
|
|
1013
|
+
const rad = (x1, y1, r1, x2, y2, r2, stops) => ({
|
|
1014
|
+
type: 'radial',
|
|
1015
|
+
coords: { x1, y1, r1, x2, y2, r2 },
|
|
1016
|
+
colorStops: stops.map(([offset, color]) => ({ offset, color })),
|
|
1017
|
+
offsetX: 0,
|
|
1018
|
+
offsetY: 0,
|
|
1019
|
+
gradientUnits: 'pixels'
|
|
1020
|
+
});
|
|
1021
|
+
return [
|
|
1022
|
+
{
|
|
1023
|
+
...base,
|
|
1024
|
+
id: 'g0',
|
|
1025
|
+
left: 60,
|
|
1026
|
+
top: 40,
|
|
1027
|
+
width: 240,
|
|
1028
|
+
height: 140,
|
|
1029
|
+
fill: lin(0, 0, 240, 0, [
|
|
1030
|
+
[0, '#c03030'],
|
|
1031
|
+
[1, '#e0c030']
|
|
1032
|
+
])
|
|
1033
|
+
},
|
|
1034
|
+
{
|
|
1035
|
+
...base,
|
|
1036
|
+
id: 'g1',
|
|
1037
|
+
left: 340,
|
|
1038
|
+
top: 40,
|
|
1039
|
+
width: 240,
|
|
1040
|
+
height: 140,
|
|
1041
|
+
fill: lin(0, 0, 0, 140, [
|
|
1042
|
+
[0, '#2050c0'],
|
|
1043
|
+
[0.5, '#e8e8f0'],
|
|
1044
|
+
[1, '#30a050']
|
|
1045
|
+
])
|
|
1046
|
+
},
|
|
1047
|
+
{
|
|
1048
|
+
...base,
|
|
1049
|
+
id: 'g2',
|
|
1050
|
+
left: 620,
|
|
1051
|
+
top: 40,
|
|
1052
|
+
width: 240,
|
|
1053
|
+
height: 140,
|
|
1054
|
+
angle: 20,
|
|
1055
|
+
scaleX: 1.2,
|
|
1056
|
+
scaleY: 0.9,
|
|
1057
|
+
fill: lin(0, 0, 240, 140, [
|
|
1058
|
+
[0, '#7030a0'],
|
|
1059
|
+
[1, '#30b0b0']
|
|
1060
|
+
])
|
|
1061
|
+
},
|
|
1062
|
+
{
|
|
1063
|
+
...base,
|
|
1064
|
+
id: 'g3',
|
|
1065
|
+
type: 'ellipse',
|
|
1066
|
+
left: 920,
|
|
1067
|
+
top: 50,
|
|
1068
|
+
rx: 120,
|
|
1069
|
+
ry: 80,
|
|
1070
|
+
fill: rad(120, 80, 0, 120, 80, 110, [
|
|
1071
|
+
[0, '#e06030'],
|
|
1072
|
+
[1, '#f0e0d0']
|
|
1073
|
+
])
|
|
1074
|
+
},
|
|
1075
|
+
{
|
|
1076
|
+
...base,
|
|
1077
|
+
id: 'g4',
|
|
1078
|
+
type: 'circle',
|
|
1079
|
+
left: 60,
|
|
1080
|
+
top: 220,
|
|
1081
|
+
radius: 90,
|
|
1082
|
+
fill: rad(60, 90, 10, 95, 60, 90, [
|
|
1083
|
+
[0, '#2060c0'],
|
|
1084
|
+
[1, '#d0e0f0']
|
|
1085
|
+
])
|
|
1086
|
+
},
|
|
1087
|
+
{
|
|
1088
|
+
...base,
|
|
1089
|
+
id: 'g5',
|
|
1090
|
+
left: 280,
|
|
1091
|
+
top: 220,
|
|
1092
|
+
width: 240,
|
|
1093
|
+
height: 160,
|
|
1094
|
+
fill: {
|
|
1095
|
+
type: 'linear',
|
|
1096
|
+
coords: { x1: 0, y1: 0, x2: 1, y2: 1 },
|
|
1097
|
+
colorStops: [
|
|
1098
|
+
{ offset: 0, color: '#108060' },
|
|
1099
|
+
{ offset: 1, color: '#e0a020' }
|
|
1100
|
+
],
|
|
1101
|
+
offsetX: 0,
|
|
1102
|
+
offsetY: 0,
|
|
1103
|
+
gradientUnits: 'percentage'
|
|
1104
|
+
}
|
|
1105
|
+
},
|
|
1106
|
+
{
|
|
1107
|
+
...base,
|
|
1108
|
+
id: 'g6',
|
|
1109
|
+
left: 560,
|
|
1110
|
+
top: 220,
|
|
1111
|
+
width: 280,
|
|
1112
|
+
height: 160,
|
|
1113
|
+
fill: lin(0, 0, 280, 0, [
|
|
1114
|
+
[0, '#c02060'],
|
|
1115
|
+
[0.45, 'rgba(255,200,80,0.25)'],
|
|
1116
|
+
[1, '#2060a0']
|
|
1117
|
+
])
|
|
1118
|
+
},
|
|
1119
|
+
{
|
|
1120
|
+
...base,
|
|
1121
|
+
id: 'g7',
|
|
1122
|
+
type: 'polygon',
|
|
1123
|
+
left: 880,
|
|
1124
|
+
top: 210,
|
|
1125
|
+
points: [
|
|
1126
|
+
{ x: 0, y: 0 },
|
|
1127
|
+
{ x: 180, y: 0 },
|
|
1128
|
+
{ x: 180, y: 60 },
|
|
1129
|
+
{ x: 60, y: 60 },
|
|
1130
|
+
{ x: 60, y: 170 },
|
|
1131
|
+
{ x: 0, y: 170 }
|
|
1132
|
+
],
|
|
1133
|
+
fill: rad(90, 85, 0, 90, 85, 130, [
|
|
1134
|
+
[0, '#a03070'],
|
|
1135
|
+
[1, '#3070a0']
|
|
1136
|
+
])
|
|
1137
|
+
},
|
|
1138
|
+
{
|
|
1139
|
+
...base,
|
|
1140
|
+
id: 'g8',
|
|
1141
|
+
left: 60,
|
|
1142
|
+
top: 430,
|
|
1143
|
+
width: 260,
|
|
1144
|
+
height: 170,
|
|
1145
|
+
fill: lin(0, 0, 260, 0, [
|
|
1146
|
+
[0, '#b08020'],
|
|
1147
|
+
[1, '#40b060']
|
|
1148
|
+
], {
|
|
1149
|
+
gradientTransform: [Math.cos((30 * Math.PI) / 180), Math.sin((30 * Math.PI) / 180), -Math.sin((30 * Math.PI) / 180), Math.cos((30 * Math.PI) / 180), 0, 0]
|
|
1150
|
+
})
|
|
1151
|
+
},
|
|
1152
|
+
{
|
|
1153
|
+
...base,
|
|
1154
|
+
id: 'g9',
|
|
1155
|
+
left: 360,
|
|
1156
|
+
top: 430,
|
|
1157
|
+
width: 260,
|
|
1158
|
+
height: 170,
|
|
1159
|
+
opacity: 0.8,
|
|
1160
|
+
fill: lin(0, 0, 260, 0, [
|
|
1161
|
+
[0, '#4040c0'],
|
|
1162
|
+
[1, '#c04040']
|
|
1163
|
+
], { offsetX: 60, offsetY: 40 })
|
|
1164
|
+
}
|
|
1165
|
+
];
|
|
1166
|
+
};
|
|
1167
|
+
/**
|
|
1168
|
+
* 图案填充场景(Phase 3 P3-3b):pattern × repeat 语义 × rect/形状。
|
|
1169
|
+
*
|
|
1170
|
+
* tile 用本地打包素材(与图片场景同源,1:1 尺度下 canvas pattern 与 GL REPEAT
|
|
1171
|
+
* 采样都近乎逐像素复制);patternTransform 旋转用例改用平滑 SVG 渐变 data URL
|
|
1172
|
+
* tile(硬边素材的旋转重采样核差异会铺满 tile,与图案语义本身无关)。
|
|
1173
|
+
* 差异集中在:旋转重采样、椭圆/凹形轮廓 AA、tile 边界的亚像素定位。
|
|
1174
|
+
* 覆盖:repeat/repeat-x/repeat-y/no-repeat(单次轴 tile 外透明的遮罩语义)、
|
|
1175
|
+
* patternTransform 旋转、offsetX/offsetY、mesh 管线(椭圆/凹多边形)。
|
|
1176
|
+
* 文本图案不进场景(引擎字形管线暂以黑近似,P3-3 已知缺口)。
|
|
1177
|
+
*/
|
|
1178
|
+
export const makePatternScene = () => {
|
|
1179
|
+
const base = {
|
|
1180
|
+
type: 'rect',
|
|
1181
|
+
scaleX: 1,
|
|
1182
|
+
scaleY: 1,
|
|
1183
|
+
angle: 0,
|
|
1184
|
+
originX: 'left',
|
|
1185
|
+
originY: 'top',
|
|
1186
|
+
opacity: 1,
|
|
1187
|
+
strokeWidth: 0,
|
|
1188
|
+
visible: true
|
|
1189
|
+
};
|
|
1190
|
+
const tileA = assetUrl('../../assets/images/nasty_fabric.png'); // 198×200 织物
|
|
1191
|
+
const tileB = assetUrl('../../assets/images/greyfloral.png'); // 150×124 灰花卉
|
|
1192
|
+
// repeat 变体按应用图案选择器的真实形态给 patternTransform——
|
|
1193
|
+
// 裸 no-repeat 自然尺寸贴图在 canvas 语义下只填左上一角(与 fabric 逐像素一致,
|
|
1194
|
+
// 但观感像「选框与内容错位」);裸语义的轴向遮罩由 pattern.spec 单测覆盖。
|
|
1195
|
+
// 缩放公式同 ColorPicker.generatePattern:适应=min / 贴合=max,等比居中(ratio=1)
|
|
1196
|
+
const fitTileB = (elW, elH, mode) => {
|
|
1197
|
+
const s = mode === 'contain' ? Math.min(elW / 150, elH / 124) : Math.max(elW / 150, elH / 124);
|
|
1198
|
+
return [s, 0, 0, s, (elW - 150 * s) / 2, (elH - 124 * s) / 2];
|
|
1199
|
+
};
|
|
1200
|
+
// 平滑渐变 tile(80×80,旋转重采样安全):SVG data URL,两侧同源栅格化
|
|
1201
|
+
const smoothTile = `data:image/svg+xml;utf8,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80"><defs><linearGradient id="g" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#3f7fbf"/><stop offset="1" stop-color="#e0c060"/></linearGradient></defs><rect width="80" height="80" fill="url(#g)"/></svg>')}`;
|
|
1202
|
+
const pat = (source, extra = {}) => ({
|
|
1203
|
+
type: 'pattern',
|
|
1204
|
+
source,
|
|
1205
|
+
repeat: 'repeat',
|
|
1206
|
+
offsetX: 0,
|
|
1207
|
+
offsetY: 0,
|
|
1208
|
+
patternTransform: null,
|
|
1209
|
+
...extra
|
|
1210
|
+
});
|
|
1211
|
+
return [
|
|
1212
|
+
{ ...base, id: 'p0', left: 60, top: 40, width: 280, height: 160, fill: pat(tileA) },
|
|
1213
|
+
{ ...base, id: 'p1', left: 380, top: 40, width: 300, height: 200, fill: pat(tileB) },
|
|
1214
|
+
// repeat-x:tile 纵向缩放到盒高(单次轴恰好满高)+ 横向平铺——遮罩语义在满高边界上
|
|
1215
|
+
{ ...base, id: 'p2', left: 720, top: 40, width: 280, height: 160, fill: pat(tileA, { repeat: 'repeat-x', patternTransform: [160 / 200, 0, 0, 160 / 200, 0, 0] }) },
|
|
1216
|
+
// repeat-y:tile 横向缩放到盒宽(单次轴恰好满宽)+ 纵向平铺
|
|
1217
|
+
{ ...base, id: 'p3', left: 60, top: 240, width: 280, height: 160, fill: pat(tileA, { repeat: 'repeat-y', patternTransform: [280 / 198, 0, 0, 280 / 198, 0, 0] }) },
|
|
1218
|
+
// no-repeat:贴合(cover)式变换铺满盒(应用「贴合」选项同形态),双单次轴遮罩
|
|
1219
|
+
{ ...base, id: 'p4', left: 380, top: 280, width: 300, height: 180, fill: pat(tileB, { repeat: 'no-repeat', patternTransform: fitTileB(300, 180, 'cover') }) },
|
|
1220
|
+
{
|
|
1221
|
+
...base,
|
|
1222
|
+
id: 'p5',
|
|
1223
|
+
left: 720,
|
|
1224
|
+
top: 240,
|
|
1225
|
+
width: 280,
|
|
1226
|
+
height: 180,
|
|
1227
|
+
fill: pat(smoothTile, { patternTransform: [Math.cos((20 * Math.PI) / 180), Math.sin((20 * Math.PI) / 180), -Math.sin((20 * Math.PI) / 180), Math.cos((20 * Math.PI) / 180), 0, 0] })
|
|
1228
|
+
},
|
|
1229
|
+
{ ...base, id: 'p6', type: 'ellipse', left: 60, top: 440, rx: 130, ry: 85, fill: pat(tileB) },
|
|
1230
|
+
{
|
|
1231
|
+
...base,
|
|
1232
|
+
id: 'p7',
|
|
1233
|
+
type: 'polygon',
|
|
1234
|
+
left: 340,
|
|
1235
|
+
top: 470,
|
|
1236
|
+
points: [
|
|
1237
|
+
{ x: 0, y: 0 },
|
|
1238
|
+
{ x: 200, y: 0 },
|
|
1239
|
+
{ x: 200, y: 60 },
|
|
1240
|
+
{ x: 70, y: 60 },
|
|
1241
|
+
{ x: 70, y: 170 },
|
|
1242
|
+
{ x: 0, y: 170 }
|
|
1243
|
+
],
|
|
1244
|
+
fill: pat(tileA, { offsetX: 30, offsetY: 20 })
|
|
1245
|
+
}
|
|
1246
|
+
];
|
|
1247
|
+
};
|
|
1248
|
+
/**
|
|
1249
|
+
* 阴影场景(Phase 3 P3-4):shadow × 对象族 × 变换链。
|
|
1250
|
+
*
|
|
1251
|
+
* 覆盖:blur+offset 组合 / 纯 offset 硬阴影 / 彩色半透明阴影色 / 旋转+缩放对象
|
|
1252
|
+
* (offset 沿画布轴不随对象旋转——canvas 设备空间语义)/ 椭圆与凹多边形 /
|
|
1253
|
+
* 位图 alpha 剪影 / 文本逐字剪影 / nonScaling / 阴影×渐变填充叠加。
|
|
1254
|
+
* 已知近似(场景规避):半透明填充对象的阴影强度按源 alpha 衰减(烘焙剪影
|
|
1255
|
+
* 恒不透明);affectStroke 描边阴影不在此列(形状描边属 P3-2)。
|
|
1256
|
+
*/
|
|
1257
|
+
export const makeShadowScene = () => {
|
|
1258
|
+
const base = {
|
|
1259
|
+
type: 'rect',
|
|
1260
|
+
scaleX: 1,
|
|
1261
|
+
scaleY: 1,
|
|
1262
|
+
angle: 0,
|
|
1263
|
+
originX: 'left',
|
|
1264
|
+
originY: 'top',
|
|
1265
|
+
opacity: 1,
|
|
1266
|
+
strokeWidth: 0,
|
|
1267
|
+
visible: true,
|
|
1268
|
+
fill: '#e8e0d0'
|
|
1269
|
+
};
|
|
1270
|
+
const shadow = (color, blur, offsetX, offsetY, extra = {}) => ({
|
|
1271
|
+
color,
|
|
1272
|
+
blur,
|
|
1273
|
+
offsetX,
|
|
1274
|
+
offsetY,
|
|
1275
|
+
affectStroke: false,
|
|
1276
|
+
nonScaling: false,
|
|
1277
|
+
...extra
|
|
1278
|
+
});
|
|
1279
|
+
return [
|
|
1280
|
+
{ ...base, id: 'sh0', left: 60, top: 40, width: 240, height: 140, fill: '#d0c8b8', shadow: shadow('rgba(40,40,60,0.45)', 12, 10, 10) },
|
|
1281
|
+
{ ...base, id: 'sh1', left: 380, top: 40, width: 240, height: 140, fill: '#c8d8c0', shadow: shadow('rgba(30,60,30,0.5)', 0, 14, 8) },
|
|
1282
|
+
{ ...base, id: 'sh2', left: 700, top: 40, width: 240, height: 140, fill: '#f0f0f0', shadow: shadow('rgba(160,60,200,0.5)', 16, -8, 12) },
|
|
1283
|
+
{
|
|
1284
|
+
...base,
|
|
1285
|
+
id: 'sh3',
|
|
1286
|
+
left: 1020,
|
|
1287
|
+
top: 60,
|
|
1288
|
+
width: 220,
|
|
1289
|
+
height: 150,
|
|
1290
|
+
angle: 30,
|
|
1291
|
+
scaleX: 1.2,
|
|
1292
|
+
scaleY: 0.9,
|
|
1293
|
+
fill: '#d8ccc0',
|
|
1294
|
+
shadow: shadow('rgba(60,50,40,0.5)', 10, 12, 12)
|
|
1295
|
+
},
|
|
1296
|
+
{ ...base, id: 'sh4', type: 'ellipse', left: 60, top: 240, rx: 120, ry: 78, fill: '#c0cad8', shadow: shadow('rgba(30,40,80,0.45)', 14, 8, 10) },
|
|
1297
|
+
{
|
|
1298
|
+
...base,
|
|
1299
|
+
id: 'sh5',
|
|
1300
|
+
type: 'polygon',
|
|
1301
|
+
left: 320,
|
|
1302
|
+
top: 250,
|
|
1303
|
+
points: [
|
|
1304
|
+
{ x: 0, y: 0 },
|
|
1305
|
+
{ x: 180, y: 0 },
|
|
1306
|
+
{ x: 180, y: 60 },
|
|
1307
|
+
{ x: 60, y: 60 },
|
|
1308
|
+
{ x: 60, y: 170 },
|
|
1309
|
+
{ x: 0, y: 170 }
|
|
1310
|
+
],
|
|
1311
|
+
fill: '#d0d0c0',
|
|
1312
|
+
shadow: shadow('rgba(60,60,30,0.45)', 12, 10, 10)
|
|
1313
|
+
},
|
|
1314
|
+
{
|
|
1315
|
+
...base,
|
|
1316
|
+
id: 'sh6',
|
|
1317
|
+
type: 'image',
|
|
1318
|
+
left: 620,
|
|
1319
|
+
top: 250,
|
|
1320
|
+
src: assetUrl('../../assets/images/nasty_fabric.png'),
|
|
1321
|
+
shadow: shadow('rgba(40,30,60,0.5)', 12, 10, 10)
|
|
1322
|
+
},
|
|
1323
|
+
{
|
|
1324
|
+
...base,
|
|
1325
|
+
id: 'sh7',
|
|
1326
|
+
type: 'textbox',
|
|
1327
|
+
left: 60,
|
|
1328
|
+
top: 470,
|
|
1329
|
+
width: 420,
|
|
1330
|
+
text: '阴影文本 Shadow text 逐字剪影',
|
|
1331
|
+
fontFamily: 'sans-serif',
|
|
1332
|
+
fontSize: 44,
|
|
1333
|
+
fontWeight: 'bold',
|
|
1334
|
+
fill: '#303040',
|
|
1335
|
+
lineHeight: 1.16,
|
|
1336
|
+
shadow: shadow('rgba(80,90,160,0.5)', 8, 6, 8)
|
|
1337
|
+
},
|
|
1338
|
+
{
|
|
1339
|
+
...base,
|
|
1340
|
+
id: 'sh8',
|
|
1341
|
+
left: 540,
|
|
1342
|
+
top: 470,
|
|
1343
|
+
width: 240,
|
|
1344
|
+
height: 150,
|
|
1345
|
+
scaleX: 1.8,
|
|
1346
|
+
scaleY: 1.4,
|
|
1347
|
+
fill: '#e0d8e8',
|
|
1348
|
+
shadow: shadow('rgba(60,40,60,0.5)', 10, 10, 10, { nonScaling: true })
|
|
1349
|
+
},
|
|
1350
|
+
{
|
|
1351
|
+
...base,
|
|
1352
|
+
id: 'sh9',
|
|
1353
|
+
left: 880,
|
|
1354
|
+
top: 470,
|
|
1355
|
+
width: 280,
|
|
1356
|
+
height: 170,
|
|
1357
|
+
fill: {
|
|
1358
|
+
type: 'linear',
|
|
1359
|
+
coords: { x1: 0, y1: 0, x2: 280, y2: 0 },
|
|
1360
|
+
colorStops: [
|
|
1361
|
+
{ offset: 0, color: '#c06060' },
|
|
1362
|
+
{ offset: 1, color: '#6060c0' }
|
|
1363
|
+
],
|
|
1364
|
+
offsetX: 0,
|
|
1365
|
+
offsetY: 0,
|
|
1366
|
+
gradientUnits: 'pixels'
|
|
1367
|
+
},
|
|
1368
|
+
shadow: shadow('rgba(40,40,40,0.5)', 14, 10, 12)
|
|
1369
|
+
}
|
|
1370
|
+
];
|
|
1371
|
+
};
|
|
1372
|
+
/**
|
|
1373
|
+
* 图片族 PSD 效果场景(Phase 3 P3-5a):dropShadow / solidFill(fillType 0)。
|
|
1374
|
+
*
|
|
1375
|
+
* 参考侧为**应用侧 FabricImage**(effects 是应用定制语义,clean fabric 不认)。
|
|
1376
|
+
* 覆盖:单层/多层投影(累积语义)、纯 offset 硬影、彩色影、旋转+缩放变换链、
|
|
1377
|
+
* solidFill 纯色叠加(图像 alpha 遮罩)、影+填充组合、顶层 disabled(main 不
|
|
1378
|
+
* 检查该开关、逐效果 enabled 照常生效——对齐 ground truth 的口径锁)。
|
|
1379
|
+
* stroke[](距离场多层描边)与 glow 族不进场景——main 图片路径未启用/待后续批次;
|
|
1380
|
+
* cmyk 色串与 opacity 字段不进(main 口径:纯色不乘 opacity,引擎不支持 cmyk)。
|
|
1381
|
+
*/
|
|
1382
|
+
export const makePsdEffectsScene = () => {
|
|
1383
|
+
const base = {
|
|
1384
|
+
type: 'image',
|
|
1385
|
+
scaleX: 1,
|
|
1386
|
+
scaleY: 1,
|
|
1387
|
+
angle: 0,
|
|
1388
|
+
originX: 'left',
|
|
1389
|
+
originY: 'top',
|
|
1390
|
+
opacity: 1,
|
|
1391
|
+
strokeWidth: 0,
|
|
1392
|
+
visible: true,
|
|
1393
|
+
src: assetUrl('../../assets/images/nasty_fabric.png')
|
|
1394
|
+
};
|
|
1395
|
+
const dropShadow = (fill, blur, offsetX, offsetY, extra = {}) => ({
|
|
1396
|
+
enabled: true,
|
|
1397
|
+
showInDialog: true,
|
|
1398
|
+
fill,
|
|
1399
|
+
blur,
|
|
1400
|
+
offsetX,
|
|
1401
|
+
offsetY,
|
|
1402
|
+
...extra
|
|
1403
|
+
});
|
|
1404
|
+
const solidFill = (fill, extra = {}) => ({ enabled: true, showInDialog: true, fillType: 0, fill, ...extra });
|
|
1405
|
+
// fillType 1(gradientOverlay 并入形态):fill 为 fabric Gradient 序列化选项,
|
|
1406
|
+
// 与 element.ts gradient2fill 产物同构(percentage 坐标、stops 的 rgba 串已烘 opacity)
|
|
1407
|
+
const gradientFill = (type, coords, stops, extra = {}) => ({
|
|
1408
|
+
enabled: true,
|
|
1409
|
+
showInDialog: true,
|
|
1410
|
+
fillType: 1,
|
|
1411
|
+
fill: { type, colorStops: stops.map(([offset, color]) => ({ offset, color })), coords, gradientUnits: 'percentage' },
|
|
1412
|
+
...extra
|
|
1413
|
+
});
|
|
1414
|
+
const floralSrc = assetUrl('../../assets/images/greyfloral.png');
|
|
1415
|
+
return [
|
|
1416
|
+
{ ...base, id: 'pe0', left: 60, top: 40, effects: { dropShadow: [dropShadow('rgba(40,40,60,0.45)', 12, 10, 10)] } },
|
|
1417
|
+
{
|
|
1418
|
+
...base,
|
|
1419
|
+
id: 'pe1',
|
|
1420
|
+
left: 320,
|
|
1421
|
+
top: 40,
|
|
1422
|
+
effects: {
|
|
1423
|
+
dropShadow: [dropShadow('rgba(160,60,60,0.4)', 14, 14, 8), dropShadow('rgba(40,60,160,0.35)', 8, -10, 14)]
|
|
1424
|
+
}
|
|
1425
|
+
},
|
|
1426
|
+
{ ...base, id: 'pe2', left: 580, top: 40, effects: { dropShadow: [dropShadow('rgba(30,60,30,0.5)', 0, 16, 8)] } },
|
|
1427
|
+
{
|
|
1428
|
+
...base,
|
|
1429
|
+
id: 'pe3',
|
|
1430
|
+
left: 840,
|
|
1431
|
+
top: 40,
|
|
1432
|
+
angle: 25,
|
|
1433
|
+
scaleX: 1.3,
|
|
1434
|
+
scaleY: 0.85,
|
|
1435
|
+
effects: { dropShadow: [dropShadow('rgba(60,50,40,0.45)', 10, 12, 12)] }
|
|
1436
|
+
},
|
|
1437
|
+
{
|
|
1438
|
+
...base,
|
|
1439
|
+
id: 'pe4',
|
|
1440
|
+
left: 60,
|
|
1441
|
+
top: 280,
|
|
1442
|
+
src: floralSrc,
|
|
1443
|
+
effects: { solidFill: [solidFill('rgba(200,80,80,0.55)')] }
|
|
1444
|
+
},
|
|
1445
|
+
{
|
|
1446
|
+
...base,
|
|
1447
|
+
id: 'pe5',
|
|
1448
|
+
left: 320,
|
|
1449
|
+
top: 280,
|
|
1450
|
+
src: floralSrc,
|
|
1451
|
+
effects: {
|
|
1452
|
+
dropShadow: [dropShadow('rgba(40,40,60,0.45)', 10, 8, 10)],
|
|
1453
|
+
solidFill: [solidFill('rgba(80,160,200,0.4)')]
|
|
1454
|
+
}
|
|
1455
|
+
},
|
|
1456
|
+
{
|
|
1457
|
+
...base,
|
|
1458
|
+
id: 'pe6',
|
|
1459
|
+
left: 580,
|
|
1460
|
+
top: 280,
|
|
1461
|
+
opacity: 0.85,
|
|
1462
|
+
effects: {
|
|
1463
|
+
dropShadow: [dropShadow('rgba(120,60,160,0.45)', 12, 10, 10)],
|
|
1464
|
+
solidFill: [solidFill('rgba(240,200,80,0.5)'), solidFill('rgba(80,200,140,0.3)')]
|
|
1465
|
+
}
|
|
1466
|
+
},
|
|
1467
|
+
{
|
|
1468
|
+
...base,
|
|
1469
|
+
id: 'pe7',
|
|
1470
|
+
left: 840,
|
|
1471
|
+
top: 280,
|
|
1472
|
+
effects: { disabled: true, dropShadow: [dropShadow('rgba(255,0,0,0.9)', 20, 20, 20)] }
|
|
1473
|
+
},
|
|
1474
|
+
// P3-5b fillType 1:线性渐变(纵向、两端带 alpha 渐隐——PSD opacityStops
|
|
1475
|
+
// 已烘进 rgba 的形态)
|
|
1476
|
+
{
|
|
1477
|
+
...base,
|
|
1478
|
+
id: 'pe8',
|
|
1479
|
+
left: 60,
|
|
1480
|
+
top: 520,
|
|
1481
|
+
src: floralSrc,
|
|
1482
|
+
effects: {
|
|
1483
|
+
solidFill: [
|
|
1484
|
+
gradientFill('linear', { x1: 0.5, y1: 0, x2: 0.5, y2: 1 }, [
|
|
1485
|
+
[0, 'rgba(60,20,90,0.85)'],
|
|
1486
|
+
[0.5, 'rgba(200,60,120,0.55)'],
|
|
1487
|
+
[1, 'rgba(240,220,80,0.1)']
|
|
1488
|
+
])
|
|
1489
|
+
]
|
|
1490
|
+
}
|
|
1491
|
+
},
|
|
1492
|
+
// 径向渐变(中心发光形态;r2=0.6 覆盖大半画布)
|
|
1493
|
+
{
|
|
1494
|
+
...base,
|
|
1495
|
+
id: 'pe9',
|
|
1496
|
+
left: 320,
|
|
1497
|
+
top: 520,
|
|
1498
|
+
src: floralSrc,
|
|
1499
|
+
effects: {
|
|
1500
|
+
solidFill: [
|
|
1501
|
+
gradientFill('radial', { x1: 0.5, y1: 0.5, r1: 0, x2: 0.5, y2: 0.5, r2: 0.6 }, [
|
|
1502
|
+
[0, 'rgba(255,240,180,0.95)'],
|
|
1503
|
+
[0.55, 'rgba(230,120,50,0.5)'],
|
|
1504
|
+
[1, 'rgba(60,20,90,0.8)']
|
|
1505
|
+
])
|
|
1506
|
+
]
|
|
1507
|
+
}
|
|
1508
|
+
},
|
|
1509
|
+
// 多层序:纯色在下、渐变在上(parser 产出序:solidFill(0) 先、gradientOverlay
|
|
1510
|
+
// 反转并入;drawFills 数组序绘制)+ 斜角 linear 验证非轴对齐 + 对象旋转
|
|
1511
|
+
{
|
|
1512
|
+
...base,
|
|
1513
|
+
id: 'pe10',
|
|
1514
|
+
left: 580,
|
|
1515
|
+
top: 520,
|
|
1516
|
+
angle: 18,
|
|
1517
|
+
src: floralSrc,
|
|
1518
|
+
effects: {
|
|
1519
|
+
dropShadow: [dropShadow('rgba(40,40,60,0.4)', 10, 8, 10)],
|
|
1520
|
+
solidFill: [
|
|
1521
|
+
solidFill('rgba(20,40,80,0.35)'),
|
|
1522
|
+
gradientFill('linear', { x1: 0.1, y1: 0.1, x2: 0.9, y2: 0.7 }, [
|
|
1523
|
+
[0, 'rgba(120,220,140,0.7)'],
|
|
1524
|
+
[1, 'rgba(180,40,60,0.25)']
|
|
1525
|
+
])
|
|
1526
|
+
]
|
|
1527
|
+
}
|
|
1528
|
+
},
|
|
1529
|
+
// P3-5b(2/2) stroke[]:距离场多层描边(右侧余量列 x=1060,720p 视口内)
|
|
1530
|
+
// pe11 双层同心(主描边窄在上、外圈宽在下——drawStrokes 倒序:索引大先画底层)
|
|
1531
|
+
{
|
|
1532
|
+
...base,
|
|
1533
|
+
id: 'pe11',
|
|
1534
|
+
left: 1060,
|
|
1535
|
+
top: 40,
|
|
1536
|
+
src: floralSrc,
|
|
1537
|
+
effects: {
|
|
1538
|
+
stroke: [
|
|
1539
|
+
{ enabled: true, showInDialog: true, fill: 'rgba(60,60,200,1)', strokeWidth: 6, strokeAlignment: 'outside' },
|
|
1540
|
+
{ enabled: true, showInDialog: true, fill: 'rgba(255,255,255,0.95)', strokeWidth: 16, strokeAlignment: 'outside' }
|
|
1541
|
+
]
|
|
1542
|
+
}
|
|
1543
|
+
},
|
|
1544
|
+
// pe12 center 对齐:描边跨 alpha 轮廓(内半叠图上、外半在 padding)
|
|
1545
|
+
{
|
|
1546
|
+
...base,
|
|
1547
|
+
id: 'pe12',
|
|
1548
|
+
left: 1060,
|
|
1549
|
+
top: 260,
|
|
1550
|
+
src: floralSrc,
|
|
1551
|
+
effects: {
|
|
1552
|
+
stroke: [{ enabled: true, showInDialog: true, fill: 'rgba(230,120,40,0.9)', strokeWidth: 14, strokeAlignment: 'center' }]
|
|
1553
|
+
}
|
|
1554
|
+
},
|
|
1555
|
+
// pe13 inside 对齐 + 缩放链:不透明图(nasty 织物)padT=0、整块前景——
|
|
1556
|
+
// inverted 无种子即退化,main 的边界种子补丁是唯一非平凡路径
|
|
1557
|
+
{
|
|
1558
|
+
...base,
|
|
1559
|
+
id: 'pe13',
|
|
1560
|
+
left: 1060,
|
|
1561
|
+
top: 470,
|
|
1562
|
+
scaleX: 0.85,
|
|
1563
|
+
scaleY: 0.85,
|
|
1564
|
+
effects: {
|
|
1565
|
+
stroke: [{ enabled: true, showInDialog: true, fill: 'rgba(40,160,90,0.95)', strokeWidth: 12, strokeAlignment: 'inside' }]
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
];
|
|
1569
|
+
};
|
|
1570
|
+
/**
|
|
1571
|
+
* 形状场景(Phase 3 P3-1):ellipse/circle/polygon(凸/凹)/polyline。
|
|
1572
|
+
*
|
|
1573
|
+
* 全部纯色不透明、strokeWidth 0:描边属 P3-2、半透明堆叠的舍入差与本批目标
|
|
1574
|
+
* (三角化几何正确性)无关。s4 是凹 L 形——包围盒判定会把右下缺口当实心,
|
|
1575
|
+
* 耳切必须只填 L 形本体,这是本场景的核心用例。s5 带 scale、s2 带角度,
|
|
1576
|
+
* 覆盖 dims→aCoords 的变换链。s6/s7 是 polyline:fabric 的 Polyline 默认
|
|
1577
|
+
* fill 为空(不渲染),有 fill 时按 canvas fill() 自动闭合——两种语义都要对上。
|
|
1578
|
+
*/
|
|
1579
|
+
export const makeShapeScene = () => {
|
|
1580
|
+
const base = {
|
|
1581
|
+
// 占位(每个条目各自覆写):SerializedNode.type 必填,与 makeTextScene 的 'textbox' 同套路
|
|
1582
|
+
type: 'polygon',
|
|
1583
|
+
scaleX: 1,
|
|
1584
|
+
scaleY: 1,
|
|
1585
|
+
angle: 0,
|
|
1586
|
+
originX: 'left',
|
|
1587
|
+
originY: 'top',
|
|
1588
|
+
opacity: 1,
|
|
1589
|
+
strokeWidth: 0,
|
|
1590
|
+
visible: true
|
|
1591
|
+
};
|
|
1592
|
+
return [
|
|
1593
|
+
{ ...base, id: 's0', type: 'ellipse', left: 80, top: 60, rx: 90, ry: 60, fill: '#c04040' },
|
|
1594
|
+
{ ...base, id: 's1', type: 'circle', left: 320, top: 60, radius: 70, fill: '#2f6fbf' },
|
|
1595
|
+
{ ...base, id: 's2', type: 'ellipse', left: 540, top: 60, rx: 80, ry: 50, angle: 30, fill: '#3f8f5f' },
|
|
1596
|
+
{
|
|
1597
|
+
...base,
|
|
1598
|
+
id: 's3',
|
|
1599
|
+
type: 'polygon',
|
|
1600
|
+
left: 80,
|
|
1601
|
+
top: 260,
|
|
1602
|
+
points: [
|
|
1603
|
+
{ x: 0, y: 0 },
|
|
1604
|
+
{ x: 120, y: 0 },
|
|
1605
|
+
{ x: 60, y: 110 }
|
|
1606
|
+
],
|
|
1607
|
+
fill: '#b07030'
|
|
1608
|
+
},
|
|
1609
|
+
{
|
|
1610
|
+
...base,
|
|
1611
|
+
id: 's4',
|
|
1612
|
+
type: 'polygon',
|
|
1613
|
+
left: 260,
|
|
1614
|
+
top: 260,
|
|
1615
|
+
points: [
|
|
1616
|
+
{ x: 0, y: 0 },
|
|
1617
|
+
{ x: 120, y: 0 },
|
|
1618
|
+
{ x: 120, y: 40 },
|
|
1619
|
+
{ x: 40, y: 40 },
|
|
1620
|
+
{ x: 40, y: 120 },
|
|
1621
|
+
{ x: 0, y: 120 }
|
|
1622
|
+
],
|
|
1623
|
+
fill: '#7a4fa0'
|
|
1624
|
+
},
|
|
1625
|
+
{
|
|
1626
|
+
...base,
|
|
1627
|
+
id: 's5',
|
|
1628
|
+
type: 'polygon',
|
|
1629
|
+
left: 470,
|
|
1630
|
+
top: 300,
|
|
1631
|
+
scaleX: 1.4,
|
|
1632
|
+
scaleY: 0.8,
|
|
1633
|
+
points: [
|
|
1634
|
+
{ x: 60, y: 0 },
|
|
1635
|
+
{ x: 120, y: 45 },
|
|
1636
|
+
{ x: 95, y: 115 },
|
|
1637
|
+
{ x: 25, y: 115 },
|
|
1638
|
+
{ x: 0, y: 45 }
|
|
1639
|
+
],
|
|
1640
|
+
fill: '#108080'
|
|
1641
|
+
},
|
|
1642
|
+
{
|
|
1643
|
+
...base,
|
|
1644
|
+
id: 's6',
|
|
1645
|
+
type: 'polyline',
|
|
1646
|
+
left: 720,
|
|
1647
|
+
top: 260,
|
|
1648
|
+
points: [
|
|
1649
|
+
{ x: 0, y: 0 },
|
|
1650
|
+
{ x: 120, y: 50 },
|
|
1651
|
+
{ x: 30, y: 70 },
|
|
1652
|
+
{ x: 140, y: 140 }
|
|
1653
|
+
],
|
|
1654
|
+
fill: '#a03070'
|
|
1655
|
+
},
|
|
1656
|
+
{
|
|
1657
|
+
...base,
|
|
1658
|
+
id: 's7',
|
|
1659
|
+
type: 'polyline',
|
|
1660
|
+
left: 720,
|
|
1661
|
+
top: 470,
|
|
1662
|
+
// fabric Polyline 默认 fill 为空:两侧都应不渲染(引擎 parseColor('') → 全透明)
|
|
1663
|
+
points: [
|
|
1664
|
+
{ x: 0, y: 0 },
|
|
1665
|
+
{ x: 110, y: 60 },
|
|
1666
|
+
{ x: 20, y: 120 }
|
|
1667
|
+
],
|
|
1668
|
+
fill: ''
|
|
1669
|
+
}
|
|
1670
|
+
];
|
|
1671
|
+
};
|
|
1672
|
+
/**
|
|
1673
|
+
* 路径场景(Phase 3 P3-6a):fabric Path/FabricPath 的填充渲染 parity。
|
|
1674
|
+
*
|
|
1675
|
+
* 覆盖:简单折线闭合 / 贝塞尔曲线极值(dims 与填充同时吃扁平化误差)/ 椭圆弧
|
|
1676
|
+
* (A→C 转换)/ evenodd 与 nonzero 两种 fillRule 的洞 / 多子路径岛 / 渐变填充 /
|
|
1677
|
+
* 旋转缩放变换链。全部 strokeWidth 0——路径描边属 P3-2。
|
|
1678
|
+
*/
|
|
1679
|
+
export const makePathScene = () => {
|
|
1680
|
+
const base = {
|
|
1681
|
+
type: 'Path',
|
|
1682
|
+
scaleX: 1,
|
|
1683
|
+
scaleY: 1,
|
|
1684
|
+
angle: 0,
|
|
1685
|
+
originX: 'left',
|
|
1686
|
+
originY: 'top',
|
|
1687
|
+
opacity: 1,
|
|
1688
|
+
strokeWidth: 0,
|
|
1689
|
+
visible: true
|
|
1690
|
+
};
|
|
1691
|
+
return [
|
|
1692
|
+
// 折线闭合三角(基线:无曲线误差)
|
|
1693
|
+
{ ...base, id: 'pa0', left: 60, top: 40, fill: 'rgba(200,80,80,0.9)', path: [['M', 10, 10], ['L', 180, 30], ['L', 60, 140], ['Z']] },
|
|
1694
|
+
// 曲线主体(C 的极值超出端点——dims 与三角化同时考验)
|
|
1695
|
+
{ ...base, id: 'pa1', left: 320, top: 40, fill: 'rgba(80,140,220,0.9)', path: 'M 10 100 C 40 -60 160 -60 190 100 C 220 40 120 160 100 120 Z' },
|
|
1696
|
+
// 椭圆弧(A 命令 → C 段)+ 弧极值
|
|
1697
|
+
{ ...base, id: 'pa2', left: 580, top: 40, fill: 'rgba(90,190,130,0.9)', path: 'M 10 90 A 90 60 20 1 0 190 90 A 90 60 20 1 0 10 90 Z' },
|
|
1698
|
+
// evenodd 洞(同向绕环 + fillRule evenodd——偶奇按嵌套深度相减)
|
|
1699
|
+
{
|
|
1700
|
+
...base,
|
|
1701
|
+
id: 'pa3',
|
|
1702
|
+
left: 840,
|
|
1703
|
+
top: 40,
|
|
1704
|
+
fill: 'rgba(160,100,200,0.9)',
|
|
1705
|
+
fillRule: 'evenodd',
|
|
1706
|
+
path: 'M 0 0 L 180 0 L 180 120 L 0 120 Z M 40 30 L 140 30 L 140 90 L 40 90 Z'
|
|
1707
|
+
},
|
|
1708
|
+
// nonzero 洞(反向绕环,缺省 fillRule——fabric 默认按环绕数相减)
|
|
1709
|
+
{
|
|
1710
|
+
...base,
|
|
1711
|
+
id: 'pa4',
|
|
1712
|
+
left: 60,
|
|
1713
|
+
top: 260,
|
|
1714
|
+
fill: 'rgba(230,160,60,0.9)',
|
|
1715
|
+
path: 'M 0 0 L 180 0 L 180 120 L 0 120 Z M 40 30 L 40 90 L 140 90 L 140 30 Z'
|
|
1716
|
+
},
|
|
1717
|
+
// 多子路径 + 岛中洞(evenodd 三层)+ Q/T 简写
|
|
1718
|
+
{
|
|
1719
|
+
...base,
|
|
1720
|
+
id: 'pa5',
|
|
1721
|
+
left: 320,
|
|
1722
|
+
top: 260,
|
|
1723
|
+
fill: 'rgba(70,170,180,0.9)',
|
|
1724
|
+
fillRule: 'evenodd',
|
|
1725
|
+
path: 'M 0 0 L 200 0 L 200 150 L 0 150 Z M 30 25 L 170 25 L 170 125 L 30 125 Z M 80 55 Q 100 35 120 55 Q 140 75 120 95 Q 100 115 80 95 Q 60 75 80 55 Z'
|
|
1726
|
+
},
|
|
1727
|
+
// 渐变填充路径(P3-3 渐变管线复用)
|
|
1728
|
+
{
|
|
1729
|
+
...base,
|
|
1730
|
+
id: 'pa6',
|
|
1731
|
+
left: 580,
|
|
1732
|
+
top: 260,
|
|
1733
|
+
fill: {
|
|
1734
|
+
type: 'linear',
|
|
1735
|
+
coords: { x1: 0, y1: 0, x2: 1, y2: 1 },
|
|
1736
|
+
colorStops: [
|
|
1737
|
+
{ offset: 0, color: 'rgba(120,40,180,0.95)' },
|
|
1738
|
+
{ offset: 1, color: 'rgba(240,180,60,0.85)' }
|
|
1739
|
+
],
|
|
1740
|
+
gradientUnits: 'percentage'
|
|
1741
|
+
},
|
|
1742
|
+
path: 'M 20 130 C 60 20 160 20 190 110 C 150 60 90 70 20 130 Z'
|
|
1743
|
+
},
|
|
1744
|
+
// 旋转 + 缩放 + S 简写曲线(变换链下的三角化铺放)
|
|
1745
|
+
{
|
|
1746
|
+
...base,
|
|
1747
|
+
id: 'pa7',
|
|
1748
|
+
left: 840,
|
|
1749
|
+
top: 280,
|
|
1750
|
+
angle: 20,
|
|
1751
|
+
scaleX: 1.15,
|
|
1752
|
+
scaleY: 0.85,
|
|
1753
|
+
fill: 'rgba(40,60,60,0.9)',
|
|
1754
|
+
path: 'M 10 10 C 60 10 90 40 100 90 S 60 150 20 130 S -20 40 10 10 Z'
|
|
1755
|
+
}
|
|
1756
|
+
];
|
|
1757
|
+
};
|
|
1758
|
+
/**
|
|
1759
|
+
* 路径族锚点编辑场景(P4-7):Path 折线闭合(拖点/插点/类型切换基准)+ Path
|
|
1760
|
+
* 曲线(C 手柄/连接线)+ polygon(顶点拖拽)+ line(端点拖拽)。位形对齐
|
|
1761
|
+
* pathSession.spec 的手推基准:p0 四锚点场景位 (100,100)/(200,100)/(200,180)/
|
|
1762
|
+
* (100,180)、上边中点 (150,100)。
|
|
1763
|
+
*/
|
|
1764
|
+
export const makePathEditScene = () => {
|
|
1765
|
+
const base = {
|
|
1766
|
+
type: 'Path',
|
|
1767
|
+
scaleX: 1,
|
|
1768
|
+
scaleY: 1,
|
|
1769
|
+
angle: 0,
|
|
1770
|
+
originX: 'left',
|
|
1771
|
+
originY: 'top',
|
|
1772
|
+
opacity: 1,
|
|
1773
|
+
strokeWidth: 0,
|
|
1774
|
+
visible: true
|
|
1775
|
+
};
|
|
1776
|
+
return [
|
|
1777
|
+
// 折线闭合(基准:锚点/插点/类型切换)
|
|
1778
|
+
{ ...base, type: 'Path', id: 'p0', left: 100, top: 100, fill: 'rgba(74,124,199,0.9)', path: [['M', 10, 10], ['L', 110, 10], ['L', 110, 90], ['L', 10, 90], ['Z']] },
|
|
1779
|
+
// 曲线主体(C 双手柄 + 连接线)
|
|
1780
|
+
{ ...base, type: 'Path', id: 'p1', left: 320, top: 100, fill: 'rgba(199,74,143,0.9)', path: 'M 10 60 C 40 -40 160 -40 190 60 C 160 140 40 140 10 60 Z' },
|
|
1781
|
+
// polygon 顶点拖拽
|
|
1782
|
+
{
|
|
1783
|
+
...base,
|
|
1784
|
+
type: 'polygon',
|
|
1785
|
+
id: 'pg0',
|
|
1786
|
+
left: 100,
|
|
1787
|
+
top: 300,
|
|
1788
|
+
fill: 'rgba(90,170,110,0.9)',
|
|
1789
|
+
points: [
|
|
1790
|
+
{ x: 0, y: 0 },
|
|
1791
|
+
{ x: 100, y: 0 },
|
|
1792
|
+
{ x: 0, y: 80 }
|
|
1793
|
+
]
|
|
1794
|
+
},
|
|
1795
|
+
// line 端点拖拽(唯一带描边者)
|
|
1796
|
+
{ ...base, type: 'Line', id: 'ln0', left: 320, top: 300, stroke: '#333333', strokeWidth: 4, x1: -60, y1: -40, x2: 60, y2: 40 }
|
|
1797
|
+
];
|
|
1798
|
+
};
|
|
1799
|
+
/**
|
|
1800
|
+
* 描边场景(Phase 3 P3-2):形状/路径族的 fabric 描边 parity。
|
|
1801
|
+
*
|
|
1802
|
+
* 覆盖:四形状族 ×(实线/虚线+相位偏移/round·bevel 连接/round·square 线帽/
|
|
1803
|
+
* 斜接尖峰 miterLimit)、strokeUniform × 非均匀缩放(描边宽恒定、几何反向补偿)、
|
|
1804
|
+
* 描边盖填充与 paintFirst stroke 互换、半透明描边、变换链下虚线相位。
|
|
1805
|
+
*/
|
|
1806
|
+
export const makeStrokeShapeScene = () => {
|
|
1807
|
+
const base = {
|
|
1808
|
+
type: 'polygon',
|
|
1809
|
+
scaleX: 1,
|
|
1810
|
+
scaleY: 1,
|
|
1811
|
+
angle: 0,
|
|
1812
|
+
originX: 'left',
|
|
1813
|
+
originY: 'top',
|
|
1814
|
+
opacity: 1,
|
|
1815
|
+
strokeWidth: 0,
|
|
1816
|
+
visible: true
|
|
1817
|
+
};
|
|
1818
|
+
const star = (cx, cy, r, r2, n) => {
|
|
1819
|
+
const pts = [];
|
|
1820
|
+
for (let i = 0; i < n * 2; i++) {
|
|
1821
|
+
const rr = i % 2 === 0 ? r : r2;
|
|
1822
|
+
const a = (Math.PI / n) * i - Math.PI / 2;
|
|
1823
|
+
pts.push({ x: cx + rr * Math.cos(a), y: cy + rr * Math.sin(a) });
|
|
1824
|
+
}
|
|
1825
|
+
return pts;
|
|
1826
|
+
};
|
|
1827
|
+
return [
|
|
1828
|
+
// polygon 尖峰斜接(星形 miter 尖端)+ 填充上盖描边(paintFirst 缺省 fill)
|
|
1829
|
+
{ ...base, id: 'st0', left: 60, top: 40, fill: 'rgba(250,235,200,0.9)', stroke: 'rgba(60,60,120,0.95)', strokeWidth: 5, points: star(90, 75, 70, 30, 5) },
|
|
1830
|
+
// 虚线 + 相位偏移 + round 线帽(相位在整路径内连续——canvas 同源)
|
|
1831
|
+
{
|
|
1832
|
+
...base,
|
|
1833
|
+
id: 'st1',
|
|
1834
|
+
left: 300,
|
|
1835
|
+
top: 40,
|
|
1836
|
+
fill: '',
|
|
1837
|
+
stroke: 'rgba(180,50,50,0.95)',
|
|
1838
|
+
strokeWidth: 4,
|
|
1839
|
+
strokeDashArray: [12, 8],
|
|
1840
|
+
strokeDashOffset: 6,
|
|
1841
|
+
strokeLineCap: 'round',
|
|
1842
|
+
points: star(90, 75, 70, 32, 6)
|
|
1843
|
+
},
|
|
1844
|
+
// bevel 连接 + square 线帽(虚线方头)
|
|
1845
|
+
{
|
|
1846
|
+
...base,
|
|
1847
|
+
id: 'st2',
|
|
1848
|
+
left: 540,
|
|
1849
|
+
top: 40,
|
|
1850
|
+
fill: '',
|
|
1851
|
+
stroke: 'rgba(40,130,80,0.95)',
|
|
1852
|
+
strokeWidth: 6,
|
|
1853
|
+
strokeDashArray: [16, 10],
|
|
1854
|
+
strokeLineJoin: 'bevel',
|
|
1855
|
+
strokeLineCap: 'square',
|
|
1856
|
+
points: star(90, 75, 68, 28, 7)
|
|
1857
|
+
},
|
|
1858
|
+
// ellipse 描边(虚线 + round 连接)
|
|
1859
|
+
{
|
|
1860
|
+
...base,
|
|
1861
|
+
id: 'st3',
|
|
1862
|
+
type: 'ellipse',
|
|
1863
|
+
left: 800,
|
|
1864
|
+
top: 40,
|
|
1865
|
+
rx: 95,
|
|
1866
|
+
ry: 62,
|
|
1867
|
+
fill: 'rgba(210,230,250,0.8)',
|
|
1868
|
+
stroke: 'rgba(150,40,140,0.95)',
|
|
1869
|
+
strokeWidth: 5,
|
|
1870
|
+
strokeDashArray: [10, 6],
|
|
1871
|
+
strokeLineJoin: 'round'
|
|
1872
|
+
},
|
|
1873
|
+
// strokeUniform × 非均匀缩放:描边宽恒定 6(几何 y 反向补偿——fabric 已知怪癖照抄)
|
|
1874
|
+
{ ...base, id: 'st4', left: 60, top: 240, scaleX: 1.6, scaleY: 0.7, fill: '', stroke: 'rgba(30,30,30,0.95)', strokeWidth: 6, strokeUniform: true, points: star(90, 70, 72, 30, 5) },
|
|
1875
|
+
// 非 uniform:描边宽随各向异性缩放(canvas lineWidth 受 CTM 变换)
|
|
1876
|
+
{ ...base, id: 'st5', left: 340, top: 240, scaleX: 1.6, scaleY: 0.7, angle: 15, fill: 'rgba(255,255,255,0.5)', stroke: 'rgba(200,120,20,0.95)', strokeWidth: 4, points: star(90, 70, 72, 30, 5) },
|
|
1877
|
+
// paintFirst stroke:描边垫在填充之下(外半可见、内半被填充盖住)
|
|
1878
|
+
{ ...base, id: 'st6', left: 620, top: 240, fill: 'rgba(240,240,240,1)', stroke: 'rgba(200,30,30,1)', strokeWidth: 10, paintFirst: 'stroke', points: star(90, 70, 72, 34, 5) },
|
|
1879
|
+
// Path 描边(曲线 + S 简写 + round 连接)与圆
|
|
1880
|
+
{
|
|
1881
|
+
...base,
|
|
1882
|
+
id: 'st7',
|
|
1883
|
+
type: 'Path',
|
|
1884
|
+
left: 60,
|
|
1885
|
+
top: 440,
|
|
1886
|
+
fill: '',
|
|
1887
|
+
stroke: 'rgba(30,90,170,0.95)',
|
|
1888
|
+
strokeWidth: 4,
|
|
1889
|
+
strokeLineJoin: 'round',
|
|
1890
|
+
path: 'M 10 90 C 40 -40 140 -40 170 90 S 90 150 10 90 Z'
|
|
1891
|
+
},
|
|
1892
|
+
// rect 描边(fabricrect 族的实色矩形路径)+ 旋转
|
|
1893
|
+
{ ...base, id: 'st8', type: 'rect', left: 320, top: 450, width: 220, height: 130, angle: 12, fill: 'rgba(235,225,245,0.9)', stroke: 'rgba(90,40,120,0.95)', strokeWidth: 6 },
|
|
1894
|
+
// circle 描边(虚线圆)
|
|
1895
|
+
{ ...base, id: 'st9', type: 'circle', left: 620, top: 440, radius: 70, fill: '', stroke: 'rgba(20,20,20,0.9)', strokeWidth: 3, strokeDashArray: [8, 8] }
|
|
1896
|
+
];
|
|
1897
|
+
};
|
|
1898
|
+
/**
|
|
1899
|
+
* 路径定制效果场景(Phase 3 P3-5c):FabricPath 的应用定制——dropShadow[] 多层
|
|
1900
|
+
* 投影(PathCommon.renderShadow:raw 偏移 + 填充剪影,无擦除)与
|
|
1901
|
+
* strokeAlignment OUTER/INNER(destination-out / clip 技巧)。
|
|
1902
|
+
* 参考面走应用 FabricPath(应用定制语义对拍应用类;其构造器强制
|
|
1903
|
+
* strokeUniform=true,引擎侧同口径)。
|
|
1904
|
+
*/
|
|
1905
|
+
export const makePathEffectsScene = () => {
|
|
1906
|
+
const base = {
|
|
1907
|
+
type: 'Path',
|
|
1908
|
+
scaleX: 1,
|
|
1909
|
+
scaleY: 1,
|
|
1910
|
+
angle: 0,
|
|
1911
|
+
originX: 'left',
|
|
1912
|
+
originY: 'top',
|
|
1913
|
+
opacity: 1,
|
|
1914
|
+
strokeWidth: 0,
|
|
1915
|
+
visible: true
|
|
1916
|
+
};
|
|
1917
|
+
const dropShadow = (fill, blur, offsetX, offsetY) => ({ enabled: true, showInDialog: true, fill, blur, offsetX, offsetY });
|
|
1918
|
+
return [
|
|
1919
|
+
// 单层投影(raw 偏移——与图片族的 scale 补偿公式不同的口径)
|
|
1920
|
+
{
|
|
1921
|
+
...base,
|
|
1922
|
+
id: 'px0',
|
|
1923
|
+
left: 60,
|
|
1924
|
+
top: 60,
|
|
1925
|
+
fill: 'rgba(250,240,220,0.95)',
|
|
1926
|
+
path: 'M 10 10 C 80 -30 160 20 180 90 C 120 150 30 130 10 10 Z',
|
|
1927
|
+
effects: { dropShadow: [dropShadow('rgba(40,40,80,0.5)', 14, 12, 14)] }
|
|
1928
|
+
},
|
|
1929
|
+
// 多层投影累积(数组序:后层压前层)
|
|
1930
|
+
{
|
|
1931
|
+
...base,
|
|
1932
|
+
id: 'px1',
|
|
1933
|
+
left: 340,
|
|
1934
|
+
top: 60,
|
|
1935
|
+
fill: 'rgba(220,240,250,0.95)',
|
|
1936
|
+
path: 'M 20 120 C 60 20 160 20 190 100 C 150 150 60 150 20 120 Z',
|
|
1937
|
+
effects: { dropShadow: [dropShadow('rgba(160,60,60,0.45)', 16, 16, 10), dropShadow('rgba(60,60,160,0.4)', 8, -12, 16)] }
|
|
1938
|
+
},
|
|
1939
|
+
// 半透明填充:投影强度随填充 alpha(剪影同源语义)
|
|
1940
|
+
{
|
|
1941
|
+
...base,
|
|
1942
|
+
id: 'px2',
|
|
1943
|
+
left: 620,
|
|
1944
|
+
top: 60,
|
|
1945
|
+
fill: 'rgba(200,220,160,0.55)',
|
|
1946
|
+
path: 'M 10 110 C 50 10 150 10 180 110 C 130 150 60 150 10 110 Z',
|
|
1947
|
+
effects: { dropShadow: [dropShadow('rgba(30,60,30,0.6)', 12, 10, 12)] }
|
|
1948
|
+
},
|
|
1949
|
+
// 空填充 + 投影:main 的 _renderFill 不画 → 无投影(锁口径)
|
|
1950
|
+
{
|
|
1951
|
+
...base,
|
|
1952
|
+
id: 'px3',
|
|
1953
|
+
left: 900,
|
|
1954
|
+
top: 60,
|
|
1955
|
+
fill: '',
|
|
1956
|
+
path: 'M 10 10 L 150 10 L 150 120 L 10 120 Z',
|
|
1957
|
+
effects: { dropShadow: [dropShadow('rgba(255,0,0,0.9)', 20, 20, 20)] }
|
|
1958
|
+
},
|
|
1959
|
+
// OUTER 描边(双倍宽 + destination-out 擦内侧)
|
|
1960
|
+
{
|
|
1961
|
+
...base,
|
|
1962
|
+
id: 'px4',
|
|
1963
|
+
left: 60,
|
|
1964
|
+
top: 340,
|
|
1965
|
+
fill: 'rgba(240,235,245,1)',
|
|
1966
|
+
stroke: 'rgba(150,60,140,1)',
|
|
1967
|
+
strokeWidth: 8,
|
|
1968
|
+
strokeAlignment: 'outside',
|
|
1969
|
+
path: 'M 10 100 C 40 10 140 10 170 100 C 120 150 50 150 10 100 Z'
|
|
1970
|
+
},
|
|
1971
|
+
// INNER 描边(clip 内侧 + 双倍宽)
|
|
1972
|
+
{
|
|
1973
|
+
...base,
|
|
1974
|
+
id: 'px5',
|
|
1975
|
+
left: 340,
|
|
1976
|
+
top: 340,
|
|
1977
|
+
fill: 'rgba(235,245,235,1)',
|
|
1978
|
+
stroke: 'rgba(40,90,50,1)',
|
|
1979
|
+
strokeWidth: 8,
|
|
1980
|
+
strokeAlignment: 'inside',
|
|
1981
|
+
path: 'M 10 100 C 40 10 140 10 170 100 C 120 150 50 150 10 100 Z'
|
|
1982
|
+
},
|
|
1983
|
+
// OUTER + 虚线(对齐技巧与虚线相位叠加)+ 旋转
|
|
1984
|
+
{
|
|
1985
|
+
...base,
|
|
1986
|
+
id: 'px6',
|
|
1987
|
+
left: 620,
|
|
1988
|
+
top: 350,
|
|
1989
|
+
angle: 15,
|
|
1990
|
+
fill: 'rgba(245,240,225,1)',
|
|
1991
|
+
stroke: 'rgba(60,60,150,1)',
|
|
1992
|
+
strokeWidth: 6,
|
|
1993
|
+
strokeAlignment: 'outside',
|
|
1994
|
+
strokeDashArray: [14, 8],
|
|
1995
|
+
path: 'M 10 90 C 50 -20 150 -10 180 90 C 130 140 50 140 10 90 Z'
|
|
1996
|
+
},
|
|
1997
|
+
// 投影 + OUTER 描边组合(below 相位投影 + 描边层)
|
|
1998
|
+
{
|
|
1999
|
+
...base,
|
|
2000
|
+
id: 'px7',
|
|
2001
|
+
left: 900,
|
|
2002
|
+
top: 340,
|
|
2003
|
+
fill: 'rgba(250,245,230,1)',
|
|
2004
|
+
stroke: 'rgba(140,90,30,1)',
|
|
2005
|
+
strokeWidth: 7,
|
|
2006
|
+
strokeAlignment: 'outside',
|
|
2007
|
+
path: 'M 15 100 C 45 15 145 15 175 100 C 125 150 55 150 15 100 Z',
|
|
2008
|
+
effects: { dropShadow: [dropShadow('rgba(60,40,20,0.5)', 12, 10, 12)] }
|
|
2009
|
+
}
|
|
2010
|
+
];
|
|
2011
|
+
};
|
|
2012
|
+
/**
|
|
2013
|
+
* 线族场景(Phase 3 P3-6b):Line/arrow/Dimension/ReferenceLine 的描边渲染 parity。
|
|
2014
|
+
*
|
|
2015
|
+
* x1..y2 为中心相对坐标(fabric Line 序列化语义——calcLinePoints 恒等映射),
|
|
2016
|
+
* left/top = 定位。覆盖:实线/虚线/圆帽线、端箭头/双端箭头/虚线箭头/缩放旋转、
|
|
2017
|
+
* 标注(端刻+文本框+沿线旋转)、参考线(自定义点形态——渲染同 Line)。
|
|
2018
|
+
*/
|
|
2019
|
+
export const makeLineScene = () => {
|
|
2020
|
+
const base = {
|
|
2021
|
+
type: 'Line',
|
|
2022
|
+
scaleX: 1,
|
|
2023
|
+
scaleY: 1,
|
|
2024
|
+
angle: 0,
|
|
2025
|
+
originX: 'left',
|
|
2026
|
+
originY: 'top',
|
|
2027
|
+
opacity: 1,
|
|
2028
|
+
visible: true
|
|
2029
|
+
};
|
|
2030
|
+
const line = (x1, y1, x2, y2, left, top) => ({ ...base, x1, y1, x2, y2, left, top });
|
|
2031
|
+
return [
|
|
2032
|
+
// 实线(butt 帽)
|
|
2033
|
+
{ ...line(-90, -35, 90, 35, 150, 75), id: 'ln0', stroke: 'rgba(40,40,60,0.95)', strokeWidth: 3 },
|
|
2034
|
+
// 虚线 + round 帽 + 相位
|
|
2035
|
+
{ ...line(-90, -30, 90, 30, 150, 185), id: 'ln1', stroke: 'rgba(160,50,50,0.95)', strokeWidth: 4, strokeDashArray: [14, 10], strokeDashOffset: 7, strokeLineCap: 'round' },
|
|
2036
|
+
// 水平线(零高度退化)
|
|
2037
|
+
{ ...line(-100, 0, 100, 0, 150, 295), id: 'ln2', stroke: 'rgba(30,100,60,0.95)', strokeWidth: 5 },
|
|
2038
|
+
// 端箭头(默认 arrowType end)
|
|
2039
|
+
{ ...line(-90, -40, 90, 40, 480, 75), id: 'ln3', type: 'arrow', stroke: 'rgba(50,50,150,0.95)', strokeWidth: 3 },
|
|
2040
|
+
// 双端箭头 + 虚线
|
|
2041
|
+
{ ...line(-90, -35, 90, 35, 480, 185), id: 'ln4', type: 'arrow', stroke: 'rgba(150,90,20,0.95)', strokeWidth: 4, strokeDashArray: [12, 8], arrowType: 'both' },
|
|
2042
|
+
// 箭头 + 旋转缩放(头尺寸 = 预设 × √sw,随对象矩阵变换)
|
|
2043
|
+
{ ...line(-80, -30, 80, 30, 460, 295), id: 'ln5', type: 'arrow', angle: 20, scaleX: 1.3, scaleY: 0.8, stroke: 'rgba(120,30,120,0.95)', strokeWidth: 3, arrowWidth: 18, arrowHeight: 27 },
|
|
2044
|
+
// 水平端箭头(2026-09-25 箭头烘焙清晰度 e2e 探针:轴对齐竖直扫描线过杆
|
|
2045
|
+
// 两侧边缘,过渡带宽度判据——1× 烘焙在 zoom 4 下双线性上采样两侧各抹 3-4px)
|
|
2046
|
+
{ ...line(-100, 0, 100, 0, 460, 405), id: 'ln9', type: 'arrow', stroke: 'rgba(30,30,30,0.95)', strokeWidth: 3 },
|
|
2047
|
+
// 标注(整线 + 端刻 + 中点文本框沿线旋转)
|
|
2048
|
+
{
|
|
2049
|
+
...line(-90, -25, 90, 25, 820, 75),
|
|
2050
|
+
id: 'ln6',
|
|
2051
|
+
type: 'Dimension',
|
|
2052
|
+
stroke: 'rgba(30,30,30,0.95)',
|
|
2053
|
+
strokeWidth: 2,
|
|
2054
|
+
text: '120 cm',
|
|
2055
|
+
textFontSize: 28,
|
|
2056
|
+
textColor: '#333333',
|
|
2057
|
+
textBackgroundColor: 'rgba(255,255,255,0.9)',
|
|
2058
|
+
textPadding: 4,
|
|
2059
|
+
textFollowLine: true
|
|
2060
|
+
},
|
|
2061
|
+
// 标注不随线旋转
|
|
2062
|
+
{ ...line(-80, -30, 80, 30, 820, 210), id: 'ln7', type: 'Dimension', angle: 0, stroke: 'rgba(90,30,30,0.95)', strokeWidth: 3, text: '80mm', textFontSize: 24, textFollowLine: false },
|
|
2063
|
+
// 参考线(自定义点形态——渲染同 Line,交互定制不进 parity)
|
|
2064
|
+
{ ...line(-100, -20, 100, 20, 820, 340), id: 'ln8', type: 'ReferenceLine', stroke: 'rgba(200,40,80,0.9)', strokeWidth: 2, strokeDashArray: [6, 6] }
|
|
2065
|
+
];
|
|
2066
|
+
};
|
|
2067
|
+
/**
|
|
2068
|
+
* 虚线文本描边场景(Phase 3 P3-2b):fabric 按 run 一次 strokeText(虚线相位
|
|
2069
|
+
* 在 run 内连续),图集逐字形做不到——run 级烘焙路径的 parity。
|
|
2070
|
+
*/
|
|
2071
|
+
export const makeDashStrokeTextScene = () => {
|
|
2072
|
+
const base = {
|
|
2073
|
+
type: 'textbox',
|
|
2074
|
+
scaleX: 1,
|
|
2075
|
+
scaleY: 1,
|
|
2076
|
+
angle: 0,
|
|
2077
|
+
originX: 'left',
|
|
2078
|
+
originY: 'top',
|
|
2079
|
+
opacity: 1,
|
|
2080
|
+
strokeWidth: 0,
|
|
2081
|
+
visible: true,
|
|
2082
|
+
fill: 'rgba(250,248,240,0.95)',
|
|
2083
|
+
lineHeight: 1.16
|
|
2084
|
+
};
|
|
2085
|
+
return [
|
|
2086
|
+
// 单行虚线(相位整行连续——核心用例)
|
|
2087
|
+
{
|
|
2088
|
+
...base,
|
|
2089
|
+
id: 'kd0',
|
|
2090
|
+
left: 40,
|
|
2091
|
+
top: 40,
|
|
2092
|
+
width: 560,
|
|
2093
|
+
text: '虚线描边 Dashed',
|
|
2094
|
+
fontFamily: 'sans-serif',
|
|
2095
|
+
fontSize: 56,
|
|
2096
|
+
fontWeight: 'bold',
|
|
2097
|
+
stroke: '#c03030',
|
|
2098
|
+
strokeWidth: 5,
|
|
2099
|
+
strokeDashArray: [10, 7]
|
|
2100
|
+
},
|
|
2101
|
+
// 多行虚线(每行相位独立重启——fabric 每行单独 strokeText)
|
|
2102
|
+
{
|
|
2103
|
+
...base,
|
|
2104
|
+
id: 'kd1',
|
|
2105
|
+
left: 640,
|
|
2106
|
+
top: 40,
|
|
2107
|
+
width: 560,
|
|
2108
|
+
text: '多行各自\n重启相位\nDashed lines',
|
|
2109
|
+
fontFamily: 'sans-serif',
|
|
2110
|
+
fontSize: 44,
|
|
2111
|
+
stroke: '#2060c0',
|
|
2112
|
+
strokeWidth: 4,
|
|
2113
|
+
strokeDashArray: [8, 6],
|
|
2114
|
+
strokeDashOffset: 4
|
|
2115
|
+
},
|
|
2116
|
+
// charSpacing ≠ 0:fabric 逐字一段(虚线逐字重启——锁口径)
|
|
2117
|
+
{
|
|
2118
|
+
...base,
|
|
2119
|
+
id: 'kd2',
|
|
2120
|
+
left: 40,
|
|
2121
|
+
top: 200,
|
|
2122
|
+
width: 560,
|
|
2123
|
+
text: '字距虚线 Spaced',
|
|
2124
|
+
fontFamily: 'sans-serif',
|
|
2125
|
+
fontSize: 48,
|
|
2126
|
+
stroke: '#207050',
|
|
2127
|
+
strokeWidth: 4,
|
|
2128
|
+
strokeDashArray: [9, 6],
|
|
2129
|
+
charSpacing: 300
|
|
2130
|
+
},
|
|
2131
|
+
// 纯描边 + 虚线(fill 空)+ round 帽
|
|
2132
|
+
{
|
|
2133
|
+
...base,
|
|
2134
|
+
id: 'kd3',
|
|
2135
|
+
left: 640,
|
|
2136
|
+
top: 240,
|
|
2137
|
+
width: 560,
|
|
2138
|
+
text: 'Outline dash only',
|
|
2139
|
+
fontFamily: 'serif',
|
|
2140
|
+
fontSize: 48,
|
|
2141
|
+
fill: '',
|
|
2142
|
+
stroke: '#803080',
|
|
2143
|
+
strokeWidth: 3,
|
|
2144
|
+
strokeDashArray: [7, 5],
|
|
2145
|
+
strokeLineCap: 'round'
|
|
2146
|
+
},
|
|
2147
|
+
// 逐字样式分段(字体/描边变化处断 run)
|
|
2148
|
+
{
|
|
2149
|
+
...base,
|
|
2150
|
+
id: 'kd4',
|
|
2151
|
+
left: 40,
|
|
2152
|
+
top: 380,
|
|
2153
|
+
width: 560,
|
|
2154
|
+
text: '混排虚线 Mixed',
|
|
2155
|
+
fontFamily: 'sans-serif',
|
|
2156
|
+
fontSize: 48,
|
|
2157
|
+
stroke: '#303030',
|
|
2158
|
+
strokeWidth: 4,
|
|
2159
|
+
strokeDashArray: [10, 6],
|
|
2160
|
+
styles: {
|
|
2161
|
+
0: {
|
|
2162
|
+
2: { fontSize: 64, stroke: '#c06020', fill: 'rgba(255,255,255,0.95)' },
|
|
2163
|
+
3: { fontSize: 64, stroke: '#c06020', fill: 'rgba(255,255,255,0.95)' }
|
|
2164
|
+
}
|
|
2165
|
+
}
|
|
2166
|
+
},
|
|
2167
|
+
// 旋转 + 缩放变换链下的虚线
|
|
2168
|
+
{
|
|
2169
|
+
...base,
|
|
2170
|
+
id: 'kd5',
|
|
2171
|
+
left: 640,
|
|
2172
|
+
top: 420,
|
|
2173
|
+
width: 520,
|
|
2174
|
+
angle: 12,
|
|
2175
|
+
scaleX: 1.1,
|
|
2176
|
+
scaleY: 0.9,
|
|
2177
|
+
text: '旋转虚线 Rotated',
|
|
2178
|
+
fontFamily: 'sans-serif',
|
|
2179
|
+
fontSize: 44,
|
|
2180
|
+
stroke: '#2060a0',
|
|
2181
|
+
strokeWidth: 4,
|
|
2182
|
+
strokeDashArray: [8, 5]
|
|
2183
|
+
}
|
|
2184
|
+
];
|
|
2185
|
+
};
|
|
2186
|
+
/**
|
|
2187
|
+
* 文本 PSD 特效场景(P3-5d:统一剪影管线)。
|
|
2188
|
+
*
|
|
2189
|
+
* 引擎以「文本剪影 → 位图算子」渲染(与图片族同构);参考面是应用侧 Textbox
|
|
2190
|
+
* (_renderTextDropShadow/_renderTextStroke 的逐字矢量路径)——两侧机制不同,
|
|
2191
|
+
* parity 为 AA 级近似(宽容差口径,同文本像素 parity 地板)。
|
|
2192
|
+
* 覆盖:
|
|
2193
|
+
* - fx0/fx1:单层/多层投影(层序:数组序绘制、后层压前层);
|
|
2194
|
+
* - fx2:solidFill 纯色叠加(半透明效果色 × 文字 alpha);
|
|
2195
|
+
* - fx3/fx4/fx5:描边三对齐 outside/center/inside(位图三区间 ↔ main 的
|
|
2196
|
+
* 线宽×2+补填充 / 居中 / 线宽×2+source-atop 三技巧);
|
|
2197
|
+
* - fx6:投影 + 填充 + 双层描边组合(相位序:below 投影 → 内容 → above 填充/描边);
|
|
2198
|
+
* - fx7:多行 + 逐字 fill/fontSize(剪影源逐字字体四件套)+ 旋转缩放链;
|
|
2199
|
+
* - fx8:效果层偏移(offsetEnable + offsetX/Y,_renderStrokeCommon 的整层平移);
|
|
2200
|
+
* - fx9:半透明对象(opacity)× 投影/填充(烘焙层随对象 opacity 调制)。
|
|
2201
|
+
* 文本族描边对齐走 `position` 字段(psd-lib 形态);fontSize 偏大稀释 hinting 差。
|
|
2202
|
+
*/
|
|
2203
|
+
export const makeTextFxScene = () => {
|
|
2204
|
+
const base = {
|
|
2205
|
+
type: 'textbox',
|
|
2206
|
+
scaleX: 1,
|
|
2207
|
+
scaleY: 1,
|
|
2208
|
+
angle: 0,
|
|
2209
|
+
originX: 'left',
|
|
2210
|
+
originY: 'top',
|
|
2211
|
+
opacity: 1,
|
|
2212
|
+
strokeWidth: 0,
|
|
2213
|
+
visible: true,
|
|
2214
|
+
width: 480,
|
|
2215
|
+
fontFamily: 'sans-serif',
|
|
2216
|
+
fontSize: 40,
|
|
2217
|
+
lineHeight: 1.3,
|
|
2218
|
+
charSpacing: 0,
|
|
2219
|
+
textAlign: 'left',
|
|
2220
|
+
fill: '#c8c8c8'
|
|
2221
|
+
};
|
|
2222
|
+
const shadow = (fill, blur, offsetX, offsetY) => ({ enabled: true, showInDialog: true, fill, blur, offsetX, offsetY });
|
|
2223
|
+
const solid = (fill, extra = {}) => ({ enabled: true, showInDialog: true, fillType: 0, fill, ...extra });
|
|
2224
|
+
// 文本族宽度走 size.value(main _setEffectStrokeStyles 只认它;strokeWidth 是图片族字段)
|
|
2225
|
+
// fillType 'color'(字符串——文本族 schema,main _setEffectStrokeStyles 以它分派色源;
|
|
2226
|
+
// 图片族的数字 fillType 是 solidFill 的字段,别混淆)
|
|
2227
|
+
const stroke = (fill, value, position, extra = {}) => ({
|
|
2228
|
+
enabled: true,
|
|
2229
|
+
showInDialog: true,
|
|
2230
|
+
fill,
|
|
2231
|
+
fillType: 'color',
|
|
2232
|
+
size: { value },
|
|
2233
|
+
position,
|
|
2234
|
+
...extra
|
|
2235
|
+
});
|
|
2236
|
+
const fx = (effects) => ({
|
|
2237
|
+
stroke: [],
|
|
2238
|
+
solidFill: [],
|
|
2239
|
+
dropShadow: [],
|
|
2240
|
+
outerGlow: { enabled: true, showInDialog: true },
|
|
2241
|
+
gradientOverlay: [],
|
|
2242
|
+
...effects
|
|
2243
|
+
});
|
|
2244
|
+
return [
|
|
2245
|
+
{ ...base, id: 'fx0', left: 80, top: 30, text: 'Shadow 投影一层', effects: fx({ dropShadow: [shadow('rgba(40,40,80,0.45)', 10, 8, 8)] }) },
|
|
2246
|
+
{
|
|
2247
|
+
...base,
|
|
2248
|
+
id: 'fx1',
|
|
2249
|
+
left: 660,
|
|
2250
|
+
top: 30,
|
|
2251
|
+
text: '多层投影 Multi shadow',
|
|
2252
|
+
effects: fx({ dropShadow: [shadow('rgba(160,60,60,0.4)', 12, 12, 6), shadow('rgba(40,60,160,0.35)', 6, -8, 12)] })
|
|
2253
|
+
},
|
|
2254
|
+
{ ...base, id: 'fx2', left: 80, top: 150, text: 'Color overlay 色叠加', effects: fx({ solidFill: [solid('rgba(30,140,140,0.55)')] }) },
|
|
2255
|
+
{ ...base, id: 'fx3', left: 660, top: 150, text: '描边外 Outside', effects: fx({ stroke: [stroke('rgba(200,60,60,0.95)', 10, 'outside')] }) },
|
|
2256
|
+
{ ...base, id: 'fx4', left: 80, top: 270, text: '描边居中 Center', effects: fx({ stroke: [stroke('rgba(230,140,40,0.95)', 10, 'center')] }) },
|
|
2257
|
+
{ ...base, id: 'fx5', left: 660, top: 270, text: '描边内 Inside', effects: fx({ stroke: [stroke('rgba(40,160,90,0.95)', 8, 'inside')] }) },
|
|
2258
|
+
{
|
|
2259
|
+
...base,
|
|
2260
|
+
id: 'fx6',
|
|
2261
|
+
left: 80,
|
|
2262
|
+
top: 390,
|
|
2263
|
+
text: '组合特效 Combo',
|
|
2264
|
+
effects: fx({
|
|
2265
|
+
dropShadow: [shadow('rgba(30,30,60,0.4)', 8, 6, 10)],
|
|
2266
|
+
solidFill: [solid('rgba(200,200,80,0.5)')],
|
|
2267
|
+
stroke: [stroke('rgba(60,60,200,0.95)', 5, 'outside'), stroke('rgba(20,20,40,0.9)', 14, 'outside')]
|
|
2268
|
+
})
|
|
2269
|
+
},
|
|
2270
|
+
{
|
|
2271
|
+
...base,
|
|
2272
|
+
id: 'fx7',
|
|
2273
|
+
left: 660,
|
|
2274
|
+
top: 390,
|
|
2275
|
+
angle: 12,
|
|
2276
|
+
scaleX: 1.15,
|
|
2277
|
+
scaleY: 0.9,
|
|
2278
|
+
text: '逐字混排 Rich\neffects 字号',
|
|
2279
|
+
styles: { 0: { 0: { fill: '#e0e0e0', fontSize: 48 }, 1: { fill: '#a0a0a0', fontSize: 48 }, 5: { fontSize: 30 } } },
|
|
2280
|
+
effects: fx({ dropShadow: [shadow('rgba(60,30,60,0.45)', 9, 7, 9)], stroke: [stroke('rgba(120,40,160,0.9)', 6, 'outside')] })
|
|
2281
|
+
},
|
|
2282
|
+
{
|
|
2283
|
+
...base,
|
|
2284
|
+
id: 'fx8',
|
|
2285
|
+
left: 80,
|
|
2286
|
+
top: 510,
|
|
2287
|
+
text: '效果偏移 Offset',
|
|
2288
|
+
effects: fx({ stroke: [stroke('rgba(200,60,60,0.9)', 6, 'outside', { offsetEnable: true, offsetX: 12, offsetY: 6 })] })
|
|
2289
|
+
},
|
|
2290
|
+
{
|
|
2291
|
+
...base,
|
|
2292
|
+
id: 'fx9',
|
|
2293
|
+
left: 660,
|
|
2294
|
+
top: 510,
|
|
2295
|
+
opacity: 0.6,
|
|
2296
|
+
text: '半透明 Opacity',
|
|
2297
|
+
effects: fx({ dropShadow: [shadow('rgba(30,30,80,0.5)', 10, 8, 8)], solidFill: [solid('rgba(220,120,60,0.6)')] })
|
|
2298
|
+
}
|
|
2299
|
+
];
|
|
2300
|
+
};
|
|
2301
|
+
/**
|
|
2302
|
+
* 文本全家桶场景:文本 / 描边文本 / 装饰文本 / 文本特效 / 变形文本 / 弧形圆形
|
|
2303
|
+
* 文本 / 竖排文本七个子场景 + 组合场景(P4-1)合并进同一画板——组合借此获得
|
|
2304
|
+
* 页面按钮可见性(单场景路由 ?scene=group 保留,e2e 仍走单场景)。
|
|
2305
|
+
*
|
|
2306
|
+
* 合并只平移 left/top(其余属性零改动),子场景对象直接复用——parity 契约仍是
|
|
2307
|
+
* 「同一份 JSON 双渲染」,且各子场景的 id 前缀(t/k/d/fx/wp/ac/ci/vt/gr)互不冲突。
|
|
2308
|
+
* 带 effects 的 fx 节点与 wp 变形 / ac/ci 弧形圆形 / vt 竖排节点(像素形变、
|
|
2309
|
+
* 逐字摆位与竖排布局姿态是应用定制)在参考渲染器里逐节点走应用侧类,与干净
|
|
2310
|
+
* fabric 的其余节点混排天然兼容(renderFabricReference 按节点分派,非按场景)。
|
|
2311
|
+
*
|
|
2312
|
+
* 2×4 分区,槽位 1300×950(各子场景的实测外接:文本 1180×860 / 描边 1200×535 /
|
|
2313
|
+
* 装饰 1260×540 / 特效 1140×570 + 投影出血 ~30 / 变形 ~930×650(warp 烘焙 quad
|
|
2314
|
+
* 的 arch/flag 出血已含,wp0 顶部出血 ~6px 落进槽间隙)/ 弧形圆形 ~885×660 /
|
|
2315
|
+
* 竖排 ~976×780(vt 系 origin center + angle:90 的变换后四角并集,x 107..1083
|
|
2316
|
+
* y 80..860)/ 组合 ~1060×400(gr0–gr6 旋转出血已含,2026-09-22 框随内容校准后收紧;含图片子加载链与
|
|
2317
|
+
* 半透明组),槽内均留 ≥40 间隙):
|
|
2318
|
+
* - 左上 makeTextScene、右上 makeStrokeTextScene;
|
|
2319
|
+
* - 左中 makeDecorationTextScene、右中 makeTextFxScene;
|
|
2320
|
+
* - 左下 makeWarpTextScene、右下 makeArcCircleTextScene;
|
|
2321
|
+
* - 左底 makeVerticalTextScene、右底 makeGroupScene。
|
|
2322
|
+
* 画板整体 ≈ 2510×3710(组合槽内容止于 y≈3500——gr9/gr10 混合组第三行 y 480..650,
|
|
2323
|
+
* 未撑高画板);视口小于画布时两侧同窗裁剪,parity 比对不受影响。
|
|
2324
|
+
*/
|
|
2325
|
+
export const makeTextAllScene = () => {
|
|
2326
|
+
const place = (objects, dx, dy) => objects.map((o) => ({ ...o, left: (o.left ?? 0) + dx, top: (o.top ?? 0) + dy }));
|
|
2327
|
+
return [
|
|
2328
|
+
...place(makeTextScene(), 0, 0),
|
|
2329
|
+
...place(makeStrokeTextScene(), 1300, 0),
|
|
2330
|
+
...place(makeDecorationTextScene(), 0, 950),
|
|
2331
|
+
...place(makeTextFxScene(), 1300, 950),
|
|
2332
|
+
...place(makeWarpTextScene(), 0, 1900),
|
|
2333
|
+
...place(makeArcCircleTextScene(), 1300, 1900),
|
|
2334
|
+
...place(makeVerticalTextScene(), 0, 2850),
|
|
2335
|
+
...place(makeGroupScene(), 1300, 2850)
|
|
2336
|
+
];
|
|
2337
|
+
};
|
|
2338
|
+
/**
|
|
2339
|
+
* 图片全家桶场景:图片 / PSD 效果 / 拼图 / 图片裁剪四个场景合并进同一画板
|
|
2340
|
+
* (合并只平移 left/top,id 前缀 img/psd/pz/cr 互不冲突;裁剪场景此前只有
|
|
2341
|
+
* debug API 无页面入口,随本合并获得可见性;e2e 仍走各单场景 debug 方法——
|
|
2342
|
+
* 逐场景视口适配 + 分场景容差)。
|
|
2343
|
+
*
|
|
2344
|
+
* 分区(各子场景实测外接:图片 ~3283×2426(2000×1400 撒点域 + 翻转旋转缩放
|
|
2345
|
+
* 出血,x −510..2773 → 平移 +600 后 90..3373)/ PSD 效果 ~1168×644(14 对象,
|
|
2346
|
+
* 投影/纯色/渐变叠加)/ 拼图 ~1124×684 / 裁剪 ~882×491,内容间均 ≥90 间隙):
|
|
2347
|
+
* - 顶行 makeImageScene(60)@(600,0);
|
|
2348
|
+
* - 次行左 makePsdEffectsScene@(600,2500)、右 makePuzzleScene@(2100,2500);
|
|
2349
|
+
* - 三行 makeCropImageScene@(600,3300);
|
|
2350
|
+
* - 底行 makeFilterImageScene@(600,4200)(40 对象,4 列 × 10 行,外接 ≈ 920×2400)。
|
|
2351
|
+
* 画板整体 ≈ 3373×6620;视口小于画板时两侧同窗裁剪,parity 比对不受影响。
|
|
2352
|
+
*/
|
|
2353
|
+
export const makeImageAllScene = () => {
|
|
2354
|
+
const place = (objects, dx, dy) => objects.map((o) => ({ ...o, left: (o.left ?? 0) + dx, top: (o.top ?? 0) + dy }));
|
|
2355
|
+
return [
|
|
2356
|
+
...place(makeImageScene(60, 7), 600, 0),
|
|
2357
|
+
...place(makePsdEffectsScene(), 600, 2500),
|
|
2358
|
+
...place(makePuzzleScene(), 2100, 2500),
|
|
2359
|
+
...place(makeCropImageScene(), 600, 3300),
|
|
2360
|
+
...place(makeFilterImageScene(), 600, 4200)
|
|
2361
|
+
];
|
|
2362
|
+
};
|
|
2363
|
+
/**
|
|
2364
|
+
* 组场景(Phase 4 P4-1):fabric Group 的变换继承与嵌套 parity。
|
|
2365
|
+
*
|
|
2366
|
+
* 子对象 left/top 为**组中心相对空间**(v6 序列化语义)。组 width/height =
|
|
2367
|
+
* 子内容 bbox(含 stroke 半宽)。2026-09-22 校准:gr1–gr5 手写声明宽高与
|
|
2368
|
+
* 落地墨迹脱节(gr3 框底空 61px / gr5 空 70px / gr4 图片自然尺寸 150×124
|
|
2369
|
+
* 误按 200×140 声明——fabric v6 反序列化信任声明值不重算,引擎同口径,选中
|
|
2370
|
+
* 框因此不贴内容);现按实测墨迹收缩声明框并把子元素平移到新框中心,渲染
|
|
2371
|
+
* 位置漂移 ≤4px(旋转组 pivot 随框心移动)。覆盖:双 rect 平移组 / 组旋转+
|
|
2372
|
+
* 缩放(子随组复合变换)/ 组中组两层变换 / 混合内容(rect+ellipse+path)/
|
|
2373
|
+
* 图片子 / 文本子 / 半透明组(子逐个乘组 opacity)/ 跨类型混合组
|
|
2374
|
+
* (gr7–gr10:文字+矩形 / 图片+矩形 / 图片+文字(−8° 旋转链)/ 三合一)。
|
|
2375
|
+
*/
|
|
2376
|
+
export const makeGroupScene = () => {
|
|
2377
|
+
const child = (over) => ({ scaleX: 1, scaleY: 1, angle: 0, originX: 'left', originY: 'top', opacity: 1, strokeWidth: 0, visible: true, ...over });
|
|
2378
|
+
return [
|
|
2379
|
+
// 双 rect 组(identity 变换——基线)
|
|
2380
|
+
{
|
|
2381
|
+
...child({ type: 'Group', left: 60, top: 50, width: 200, height: 150 }),
|
|
2382
|
+
id: 'gr0',
|
|
2383
|
+
objects: [
|
|
2384
|
+
child({ type: 'rect', id: 'gr0-c0', left: -100, top: -75, width: 120, height: 90, fill: 'rgba(230,120,100,0.95)' }),
|
|
2385
|
+
child({ type: 'rect', id: 'gr0-c1', left: -10, top: -30, width: 110, height: 105, fill: 'rgba(100,150,220,0.95)' })
|
|
2386
|
+
]
|
|
2387
|
+
},
|
|
2388
|
+
// 组旋转 + 缩放(子复合变换)
|
|
2389
|
+
{
|
|
2390
|
+
...child({ type: 'Group', left: 340, top: 40, width: 200, height: 145, angle: 18, scaleX: 1.15, scaleY: 0.85 }),
|
|
2391
|
+
id: 'gr1',
|
|
2392
|
+
objects: [
|
|
2393
|
+
child({ type: 'rect', id: 'gr1-c0', left: -100, top: -72.5, width: 130, height: 70, fill: 'rgba(160,110,210,0.95)' }),
|
|
2394
|
+
child({ type: 'ellipse', id: 'gr1-c1', left: 10, top: -37.5, rx: 45, ry: 55, fill: 'rgba(120,200,150,0.95)' })
|
|
2395
|
+
]
|
|
2396
|
+
},
|
|
2397
|
+
// 组中组(两层变换)。2026-09-22 登记:gr2 框不贴内容(嵌套组 25° 旋转簇
|
|
2398
|
+
// 右下角戳出 ~18px)为 seed 声明值与墨迹脱节——但多次重校准实验触发引擎与
|
|
2399
|
+
// fabric 的组内子元素摆放分歧(内容中心差 ~20px,组场景 parity 1.88% vs 基线
|
|
2400
|
+
// ~0.3-0.8%,疑似引擎组子摆放对声明框宽高敏感的缺陷),已回滚原始值维持
|
|
2401
|
+
// parity 绿;框贴合议题移交引擎侧排查后重新定框。
|
|
2402
|
+
{
|
|
2403
|
+
...child({ type: 'Group', left: 640, top: 60, width: 210, height: 170, angle: -12 }),
|
|
2404
|
+
id: 'gr2',
|
|
2405
|
+
objects: [
|
|
2406
|
+
child({ type: 'rect', id: 'gr2-c0', left: -105, top: -85, width: 90, height: 170, fill: 'rgba(240,200,90,0.95)' }),
|
|
2407
|
+
{
|
|
2408
|
+
...child({ type: 'Group', left: -5, top: -60, width: 110, height: 120, angle: 25, scaleX: 0.9, scaleY: 1.1 }),
|
|
2409
|
+
id: 'gr2-inner',
|
|
2410
|
+
objects: [
|
|
2411
|
+
child({ type: 'rect', id: 'gr2-i0', left: -55, top: -60, width: 110, height: 55, fill: 'rgba(80,140,190,0.95)' }),
|
|
2412
|
+
child({ type: 'rect', id: 'gr2-i1', left: -40, top: 0, width: 80, height: 60, fill: 'rgba(200,90,120,0.95)' })
|
|
2413
|
+
]
|
|
2414
|
+
}
|
|
2415
|
+
]
|
|
2416
|
+
},
|
|
2417
|
+
// 混合内容:path + 描边 shape
|
|
2418
|
+
{
|
|
2419
|
+
...child({ type: 'Group', left: 60, top: 300, width: 229, height: 99, angle: 8 }),
|
|
2420
|
+
id: 'gr3',
|
|
2421
|
+
objects: [
|
|
2422
|
+
child({ type: 'Path', id: 'gr3-c0', left: -114.5, top: -49.5, fill: 'rgba(90,170,180,0.95)', path: 'M 10 90 C 40 10 130 10 160 90 C 110 130 50 130 10 90 Z' }),
|
|
2423
|
+
child({
|
|
2424
|
+
type: 'polygon',
|
|
2425
|
+
id: 'gr3-c1',
|
|
2426
|
+
left: 40.5,
|
|
2427
|
+
top: -29.5,
|
|
2428
|
+
fill: 'rgba(250,240,210,0.95)',
|
|
2429
|
+
stroke: 'rgba(150,60,60,0.95)',
|
|
2430
|
+
strokeWidth: 4,
|
|
2431
|
+
points: [
|
|
2432
|
+
{ x: 0, y: 0 },
|
|
2433
|
+
{ x: 70, y: 10 },
|
|
2434
|
+
{ x: 55, y: 75 },
|
|
2435
|
+
{ x: 5, y: 60 }
|
|
2436
|
+
]
|
|
2437
|
+
})
|
|
2438
|
+
]
|
|
2439
|
+
},
|
|
2440
|
+
// 图片子(加载链;greyfloral 自然尺寸 150×124——框随内容)
|
|
2441
|
+
{
|
|
2442
|
+
...child({ type: 'Group', left: 360, top: 300, width: 150, height: 124, scaleX: 1.1 }),
|
|
2443
|
+
id: 'gr4',
|
|
2444
|
+
objects: [child({ type: 'image', id: 'gr4-c0', left: -75, top: -62, src: assetUrl('../../assets/images/greyfloral.png') })]
|
|
2445
|
+
},
|
|
2446
|
+
// 文本子(排版 + 字体链;单行 44px×1.16≈51 高——框随内容)
|
|
2447
|
+
{
|
|
2448
|
+
...child({ type: 'Group', left: 640, top: 310, width: 230, height: 51, angle: -6 }),
|
|
2449
|
+
id: 'gr5',
|
|
2450
|
+
objects: [child({ type: 'textbox', id: 'gr5-t0', left: -115, top: -25.5, width: 230, text: '组内文本', fontFamily: 'sans-serif', fontSize: 44, fill: 'rgba(40,40,70,0.95)', lineHeight: 1.16 })]
|
|
2451
|
+
},
|
|
2452
|
+
// 半透明组
|
|
2453
|
+
{
|
|
2454
|
+
...child({ type: 'Group', left: 920, top: 60, width: 190, height: 150, opacity: 0.55, angle: 10 }),
|
|
2455
|
+
id: 'gr6',
|
|
2456
|
+
objects: [
|
|
2457
|
+
child({ type: 'rect', id: 'gr6-c0', left: -95, top: -75, width: 190, height: 150, fill: 'rgba(60,180,120,1)' }),
|
|
2458
|
+
child({ type: 'circle', id: 'gr6-c1', left: -45, top: -45, radius: 45, fill: 'rgba(240,240,240,1)' })
|
|
2459
|
+
]
|
|
2460
|
+
},
|
|
2461
|
+
// ── 混合类型组(2026-09-23 用户点名补案例:下钻/虚线 topGroup 在跨类型
|
|
2462
|
+
// 子元素上的验证面。声明框按墨迹外接校准——gr9 含图片+文本两段内容,
|
|
2463
|
+
// 外接 = x −75..75 × y −79.5..72.2(20px 字号 ×1.16 行高)──
|
|
2464
|
+
// 文字+矩形(徽标:底板 rect 上叠文本,identity 变换基线)
|
|
2465
|
+
{
|
|
2466
|
+
...child({ type: 'Group', left: 920, top: 300, width: 200, height: 70 }),
|
|
2467
|
+
id: 'gr7',
|
|
2468
|
+
objects: [
|
|
2469
|
+
child({ type: 'rect', id: 'gr7-r0', left: -100, top: -35, width: 200, height: 70, fill: 'rgba(250,235,205,0.95)' }),
|
|
2470
|
+
child({ type: 'textbox', id: 'gr7-t0', left: -92, top: -16, width: 184, text: '矩形+文字', fontFamily: 'sans-serif', fontSize: 28, fill: 'rgba(60,50,30,0.95)', lineHeight: 1.16 })
|
|
2471
|
+
]
|
|
2472
|
+
},
|
|
2473
|
+
// 图片+矩形(拍立得衬底:image 用 greyfloral 自然尺寸 150×124,居中垫在底板上)
|
|
2474
|
+
{
|
|
2475
|
+
...child({ type: 'Group', left: 60, top: 480, width: 190, height: 130 }),
|
|
2476
|
+
id: 'gr8',
|
|
2477
|
+
objects: [
|
|
2478
|
+
child({ type: 'rect', id: 'gr8-r0', left: -95, top: -65, width: 190, height: 130, fill: 'rgba(245,228,196,0.95)' }),
|
|
2479
|
+
child({ type: 'image', id: 'gr8-i0', left: -75, top: -62, src: assetUrl('../../assets/images/greyfloral.png') })
|
|
2480
|
+
]
|
|
2481
|
+
},
|
|
2482
|
+
// 图片+文字(上图下文;组旋转 −8°——跨类型子随组链变换)
|
|
2483
|
+
{
|
|
2484
|
+
...child({ type: 'Group', left: 300, top: 480, width: 150, height: 152, angle: -8 }),
|
|
2485
|
+
id: 'gr9',
|
|
2486
|
+
objects: [
|
|
2487
|
+
child({ type: 'image', id: 'gr9-i0', left: -75, top: -79.5, src: assetUrl('../../assets/images/greyfloral.png') }),
|
|
2488
|
+
child({ type: 'textbox', id: 'gr9-t0', left: -75, top: 49, width: 150, text: '图片配文', fontFamily: 'sans-serif', fontSize: 20, fill: 'rgba(40,40,70,0.95)', lineHeight: 1.16 })
|
|
2489
|
+
]
|
|
2490
|
+
},
|
|
2491
|
+
// 图片+文字+矩形(三合一卡片:底板 / 图 / 底部说明文字)
|
|
2492
|
+
{
|
|
2493
|
+
...child({ type: 'Group', left: 580, top: 480, width: 240, height: 170 }),
|
|
2494
|
+
id: 'gr10',
|
|
2495
|
+
objects: [
|
|
2496
|
+
child({ type: 'rect', id: 'gr10-r0', left: -120, top: -85, width: 240, height: 170, fill: 'rgba(248,248,252,0.95)' }),
|
|
2497
|
+
child({ type: 'image', id: 'gr10-i0', left: -95, top: -70, src: assetUrl('../../assets/images/greyfloral.png') }),
|
|
2498
|
+
child({ type: 'textbox', id: 'gr10-t0', left: -100, top: 58, width: 200, text: '图+文+矩形', fontFamily: 'sans-serif', fontSize: 20, fill: 'rgba(40,40,70,0.95)', lineHeight: 1.16 })
|
|
2499
|
+
]
|
|
2500
|
+
}
|
|
2501
|
+
];
|
|
2502
|
+
};
|
|
2503
|
+
/**
|
|
2504
|
+
* 组蒙版与隔离场景(Phase 4 P4-2):FBO 离屏合成 parity。
|
|
2505
|
+
*
|
|
2506
|
+
* 蒙版 = 灰度位图(白显黑隐);defaultColor 255 = coversHost(蒙版矩形外保持
|
|
2507
|
+
* 可见),0 = 矩形外裁掉。覆盖:径向灰度蒙版 / coversHost / 蒙版+组透明 /
|
|
2508
|
+
* 纯隔离(半透明组重叠子——P4-1 gr6 语义收口)/ 蒙版×旋转缩放链。
|
|
2509
|
+
*/
|
|
2510
|
+
export const makeGroupMaskScene = () => {
|
|
2511
|
+
const base = (over) => ({ type: 'Group', scaleX: 1, scaleY: 1, angle: 0, originX: 'left', originY: 'top', opacity: 1, strokeWidth: 0, visible: true, ...over });
|
|
2512
|
+
const child = (over) => ({ scaleX: 1, scaleY: 1, angle: 0, originX: 'left', originY: 'top', opacity: 1, strokeWidth: 0, visible: true, ...over });
|
|
2513
|
+
// 灰度蒙版(SVG data URL,radial 白→黑)
|
|
2514
|
+
const radialMask = (r, g, b) => `data:image/svg+xml;utf8,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="${r}" height="${g}"><defs><radialGradient id="m" cx="0.5" cy="0.5" r="0.5"><stop offset="0" stop-color="#ffffff"/><stop offset="0.7" stop-color="#808080"/><stop offset="1" stop-color="#000000"/></radialGradient></defs><rect width="${r}" height="${g}" fill="url(#m)"/></svg>`).replace('REMOVED', String(b))}`;
|
|
2515
|
+
return [
|
|
2516
|
+
// 径向蒙版(defaultColor 0:矩形外裁掉)
|
|
2517
|
+
{
|
|
2518
|
+
...base({ left: 60, top: 50, width: 200, height: 150, mask: { src: radialMask(200, 150, 0), offsetX: 0, offsetY: 0, width: 200, height: 150, scaleX: 1, scaleY: 1, defaultColor: 0 } }),
|
|
2519
|
+
id: 'gm0',
|
|
2520
|
+
objects: [
|
|
2521
|
+
child({ type: 'rect', left: -100, top: -75, width: 130, height: 150, fill: 'rgba(230,120,100,1)' }),
|
|
2522
|
+
child({ type: 'rect', left: -30, top: -75, width: 130, height: 150, fill: 'rgba(100,150,220,1)' })
|
|
2523
|
+
]
|
|
2524
|
+
},
|
|
2525
|
+
// coversHost(defaultColor 255:蒙版矩形外可见)
|
|
2526
|
+
{
|
|
2527
|
+
...base({ left: 340, top: 50, width: 200, height: 150, mask: { src: radialMask(120, 90, 255), offsetX: -40, offsetY: -30, width: 120, height: 90, scaleX: 1, scaleY: 1, defaultColor: 255 } }),
|
|
2528
|
+
id: 'gm1',
|
|
2529
|
+
objects: [child({ type: 'rect', left: -100, top: -75, width: 200, height: 150, fill: 'rgba(120,200,150,1)' })]
|
|
2530
|
+
},
|
|
2531
|
+
// 蒙版 + 组透明(隔离 + destination-in + opacity 复合)
|
|
2532
|
+
{
|
|
2533
|
+
...base({
|
|
2534
|
+
left: 640,
|
|
2535
|
+
top: 50,
|
|
2536
|
+
width: 200,
|
|
2537
|
+
height: 150,
|
|
2538
|
+
opacity: 0.6,
|
|
2539
|
+
mask: { src: radialMask(200, 150, 0), offsetX: 0, offsetY: 0, width: 200, height: 150, scaleX: 1, scaleY: 1, defaultColor: 0 }
|
|
2540
|
+
}),
|
|
2541
|
+
id: 'gm2',
|
|
2542
|
+
objects: [
|
|
2543
|
+
child({ type: 'rect', left: -100, top: -75, width: 200, height: 150, fill: 'rgba(200,160,60,1)' }),
|
|
2544
|
+
child({ type: 'circle', left: -40, top: -55, radius: 55, fill: 'rgba(240,240,240,1)' })
|
|
2545
|
+
]
|
|
2546
|
+
},
|
|
2547
|
+
// 纯隔离(半透明组重叠子——fabric 缓存单元合成语义)
|
|
2548
|
+
{
|
|
2549
|
+
...base({ left: 60, top: 300, width: 200, height: 150, opacity: 0.55, angle: 8 }),
|
|
2550
|
+
id: 'gm3',
|
|
2551
|
+
objects: [
|
|
2552
|
+
child({ type: 'rect', left: -100, top: -75, width: 200, height: 150, fill: 'rgba(60,180,120,1)' }),
|
|
2553
|
+
child({ type: 'circle', left: -45, top: -45, radius: 45, fill: 'rgba(240,240,240,1)' })
|
|
2554
|
+
]
|
|
2555
|
+
},
|
|
2556
|
+
// 蒙版 × 旋转缩放(摆放矩形随组矩阵)
|
|
2557
|
+
{
|
|
2558
|
+
...base({
|
|
2559
|
+
left: 340,
|
|
2560
|
+
top: 320,
|
|
2561
|
+
width: 200,
|
|
2562
|
+
height: 150,
|
|
2563
|
+
angle: 18,
|
|
2564
|
+
scaleX: 1.15,
|
|
2565
|
+
scaleY: 0.85,
|
|
2566
|
+
mask: { src: radialMask(200, 150, 0), offsetX: 0, offsetY: 0, width: 200, height: 150, scaleX: 1, scaleY: 1, defaultColor: 0 }
|
|
2567
|
+
}),
|
|
2568
|
+
id: 'gm4',
|
|
2569
|
+
objects: [
|
|
2570
|
+
child({ type: 'rect', left: -100, top: -75, width: 200, height: 150, fill: 'rgba(150,110,210,1)' }),
|
|
2571
|
+
child({ type: 'rect', left: -60, top: -40, width: 90, height: 90, fill: 'rgba(250,220,120,1)' })
|
|
2572
|
+
]
|
|
2573
|
+
}
|
|
2574
|
+
];
|
|
2575
|
+
};
|
|
2576
|
+
/**
|
|
2577
|
+
* clipPath 场景(Phase 4 P4-3):矢量裁剪 parity。
|
|
2578
|
+
*
|
|
2579
|
+
* clipPath = 形状族描述(rect/ellipse/Path/polygon),fabric 语义:宿主经
|
|
2580
|
+
* 私有缓存 + destination-in 合成剪影;absolutePositioned = 场景坐标
|
|
2581
|
+
* (缺省为宿主本地系);inverted = destination-out(裁剪取反)。
|
|
2582
|
+
* 覆盖:rect 裁图片 / 椭圆裁形状 / Path 曲线裁 rect / inverted /
|
|
2583
|
+
* absolutePositioned / 带变换链宿主。
|
|
2584
|
+
*/
|
|
2585
|
+
export const makeClipPathScene = () => {
|
|
2586
|
+
const base = (over) => ({ scaleX: 1, scaleY: 1, angle: 0, originX: 'left', originY: 'top', opacity: 1, strokeWidth: 0, visible: true, ...over });
|
|
2587
|
+
return [
|
|
2588
|
+
// rect 裁图片(角落窗口)
|
|
2589
|
+
{
|
|
2590
|
+
...base({ type: 'image', left: 60, top: 50, src: assetUrl('../../assets/images/nasty_fabric.png') }),
|
|
2591
|
+
id: 'cp0',
|
|
2592
|
+
clipPath: { type: 'rect', left: 40, top: 30, width: 100, height: 120 }
|
|
2593
|
+
},
|
|
2594
|
+
// 椭圆裁形状
|
|
2595
|
+
{
|
|
2596
|
+
...base({ type: 'rect', left: 320, top: 50, width: 200, height: 150, fill: 'rgba(120,160,220,0.95)' }),
|
|
2597
|
+
id: 'cp1',
|
|
2598
|
+
clipPath: { type: 'ellipse', left: 30, top: 15, rx: 70, ry: 60 }
|
|
2599
|
+
},
|
|
2600
|
+
// Path 曲线裁 rect
|
|
2601
|
+
{
|
|
2602
|
+
...base({ type: 'rect', left: 600, top: 50, width: 220, height: 150, fill: 'rgba(230,150,90,0.95)' }),
|
|
2603
|
+
id: 'cp2',
|
|
2604
|
+
clipPath: { type: 'Path', left: 20, top: 10, path: 'M 0 0 C 60 -30 140 30 180 0 C 160 80 80 130 0 110 Z' }
|
|
2605
|
+
},
|
|
2606
|
+
// inverted(保留形状外)
|
|
2607
|
+
{
|
|
2608
|
+
...base({ type: 'rect', left: 60, top: 320, width: 200, height: 150, fill: 'rgba(160,110,210,0.95)' }),
|
|
2609
|
+
id: 'cp3',
|
|
2610
|
+
clipPath: { type: 'ellipse', left: 50, top: 35, rx: 50, ry: 40, inverted: true }
|
|
2611
|
+
},
|
|
2612
|
+
// absolutePositioned(场景坐标椭圆,宿主旋转)
|
|
2613
|
+
{
|
|
2614
|
+
...base({ type: 'rect', left: 320, top: 320, width: 200, height: 150, angle: 15, fill: 'rgba(100,200,150,0.95)' }),
|
|
2615
|
+
id: 'cp4',
|
|
2616
|
+
clipPath: { type: 'ellipse', left: 350, top: 340, rx: 60, ry: 50, absolutePositioned: true }
|
|
2617
|
+
},
|
|
2618
|
+
// 裁剪 + 宿主半透明(隔离复合 × clip)
|
|
2619
|
+
// 注:textbox+clipPath 在 fabric 参考面走直绘路径崩溃(main 同缺陷——该组合
|
|
2620
|
+
// 的引擎支持保留,parity 种子规避)
|
|
2621
|
+
{
|
|
2622
|
+
...base({
|
|
2623
|
+
type: 'polygon',
|
|
2624
|
+
left: 600,
|
|
2625
|
+
top: 330,
|
|
2626
|
+
opacity: 0.7,
|
|
2627
|
+
fill: 'rgba(40,40,80,0.9)',
|
|
2628
|
+
points: [
|
|
2629
|
+
{ x: 0, y: 0 },
|
|
2630
|
+
{ x: 220, y: 20 },
|
|
2631
|
+
{ x: 180, y: 140 },
|
|
2632
|
+
{ x: 20, y: 130 }
|
|
2633
|
+
]
|
|
2634
|
+
}),
|
|
2635
|
+
id: 'cp5',
|
|
2636
|
+
clipPath: { type: 'rect', left: 10, top: 10, width: 120, height: 70 }
|
|
2637
|
+
}
|
|
2638
|
+
];
|
|
2639
|
+
};
|
|
2640
|
+
/**
|
|
2641
|
+
* 变形文本场景(Phase 4 P4-5a):ArchText/WaistText/FlagText 的像素形变 parity。
|
|
2642
|
+
* warpStrength ∈ [-1,1];参考面 = 应用类(像素形变是应用定制)。
|
|
2643
|
+
*/
|
|
2644
|
+
export const makeWarpTextScene = () => {
|
|
2645
|
+
const base = (over) => ({ scaleX: 1, scaleY: 1, angle: 0, originX: 'left', originY: 'top', opacity: 1, strokeWidth: 0, visible: true, fontFamily: 'sans-serif', lineHeight: 1.16, ...over });
|
|
2646
|
+
return [
|
|
2647
|
+
{ ...base({ type: 'ArchText', left: 60, top: 40, width: 380, text: '拱形凸起', fontSize: 48, fill: 'rgba(40,60,140,0.95)', warpStrength: 0.6 }), id: 'wp0' },
|
|
2648
|
+
{ ...base({ type: 'ArchText', left: 500, top: 40, width: 380, text: '凹陷下沉', fontSize: 48, fill: 'rgba(160,60,60,0.95)', warpStrength: -0.5 }), id: 'wp1' },
|
|
2649
|
+
{ ...base({ type: 'WaistText', left: 60, top: 260, width: 380, text: '腰线捏合', fontSize: 48, fill: 'rgba(40,130,90,0.95)', warpStrength: 0.7 }), id: 'wp2' },
|
|
2650
|
+
{ ...base({ type: 'WaistText', left: 500, top: 260, width: 380, text: '腰线展开', fontSize: 48, fill: 'rgba(150,100,180,0.95)', warpStrength: -0.6 }), id: 'wp3' },
|
|
2651
|
+
{ ...base({ type: 'FlagText', left: 60, top: 480, width: 380, text: '波浪旗帜', fontSize: 44, fill: 'rgba(200,140,40,0.95)', warpStrength: 0.8 }), id: 'wp4' },
|
|
2652
|
+
{ ...base({ type: 'ArchText', left: 500, top: 470, width: 400, angle: 8, text: '旋转拱形多行\n第二行文本', fontSize: 40, fill: 'rgba(60,60,60,0.95)', warpStrength: 0.45 }), id: 'wp5' }
|
|
2653
|
+
];
|
|
2654
|
+
};
|
|
2655
|
+
/**
|
|
2656
|
+
* 弧形/圆形文本场景(Phase 4 P4-5b):ArcText/CircleText 逐字摆位 parity。
|
|
2657
|
+
* 参考面 = 应用类(逐字旋转布局是应用定制;ArcText 构造期类字段 clobber 由
|
|
2658
|
+
* 参考面 set() 补拍 initDimensions)。
|
|
2659
|
+
* 覆盖:正/负曲率单行(radius 取 minRadius 分支)、多行 globalOffset 堆叠、
|
|
2660
|
+
* textAlign center 的行偏移、正圆 360 首尾相接 / 椭圆偏心+起始角+部分弧段 /
|
|
2661
|
+
* 水平字向(circleDirection)。
|
|
2662
|
+
* 种子约定(arcLayout 头注的规避带):generic 字体;无 charSpacing(应用侧
|
|
2663
|
+
* bounds 与 charSpacingOffset 双计,未对拍)/ deltaY / justify / effects / 阴影 /
|
|
2664
|
+
* strokeVisible 描边门 / 旋转(ArcText _set('angle') 换 center 锚,另行覆盖)。
|
|
2665
|
+
*/
|
|
2666
|
+
export const makeArcCircleTextScene = () => {
|
|
2667
|
+
const base = (over) => ({ scaleX: 1, scaleY: 1, angle: 0, originX: 'left', originY: 'top', opacity: 1, strokeWidth: 0, visible: true, fontFamily: 'sans-serif', lineHeight: 1.16, ...over });
|
|
2668
|
+
return [
|
|
2669
|
+
{ ...base({ type: 'ArcText', left: 60, top: 50, text: '拱形弯曲文字', fontSize: 44, fill: 'rgba(30,90,150,0.95)', curvature: 80 }), id: 'ac0' },
|
|
2670
|
+
{ ...base({ type: 'ArcText', left: 480, top: 40, text: '下垂弧形文字', fontSize: 44, fill: 'rgba(160,60,90,0.95)', curvature: -60 }), id: 'ac1' },
|
|
2671
|
+
{ ...base({ type: 'ArcText', left: 60, top: 250, text: '两行弧形\n第二行也弯', fontSize: 34, fill: 'rgba(50,120,70,0.95)', curvature: 45 }), id: 'ac2' },
|
|
2672
|
+
{ ...base({ type: 'ArcText', left: 480, top: 240, text: '居中对齐弧形\n次行短', fontSize: 30, fill: 'rgba(120,80,160,0.95)', curvature: 65, textAlign: 'center' }), id: 'ac3' },
|
|
2673
|
+
{ ...base({ type: 'CircleText', left: 70, top: 440, text: '圆形环绕文字', fontSize: 30, fill: 'rgba(180,110,30,0.95)', circleSize: 85, circleSweep: 360 }), id: 'ci0' },
|
|
2674
|
+
{
|
|
2675
|
+
...base({
|
|
2676
|
+
type: 'CircleText',
|
|
2677
|
+
left: 400,
|
|
2678
|
+
top: 440,
|
|
2679
|
+
text: '部分弧段文本',
|
|
2680
|
+
fontSize: 26,
|
|
2681
|
+
fill: 'rgba(30,120,140,0.95)',
|
|
2682
|
+
circleSize: 80,
|
|
2683
|
+
circleStartAngle: 30,
|
|
2684
|
+
circleSweep: 200,
|
|
2685
|
+
circleEccentricity: 0.4
|
|
2686
|
+
}),
|
|
2687
|
+
id: 'ci1'
|
|
2688
|
+
},
|
|
2689
|
+
{
|
|
2690
|
+
...base({ type: 'CircleText', left: 680, top: 440, text: '水平字向环绕', fontSize: 26, fill: 'rgba(90,90,160,0.95)', circleSize: 70, circleSweep: 300, circleDirection: 'horizontal' }),
|
|
2691
|
+
id: 'ci2'
|
|
2692
|
+
}
|
|
2693
|
+
];
|
|
2694
|
+
};
|
|
2695
|
+
/**
|
|
2696
|
+
* 竖排文本场景(Phase 4 P4-5c):vertical:true 的布局与四类字形姿态 parity。
|
|
2697
|
+
*
|
|
2698
|
+
* 参考面 = 应用类(vertical 布局/姿态是应用 Textbox 定制,干净 fabric 不认)。
|
|
2699
|
+
* 对象形态取应用真实口径:vertical + angle:90 + origin center(引擎零角度
|
|
2700
|
+
* 特判——90° 由通用对象矩阵消费,与所有节点一致)。
|
|
2701
|
+
* 覆盖:纯 CJK 多列硬换行 / 中英数字混排(isLatin 双 advance)+ 逐字字号与
|
|
2702
|
+
* 填充覆写 / 括号+标点(四类姿态全档)/ textAlign center 与 right+charSpacing /
|
|
2703
|
+
* lineHeight 列距 / 下划线+背景高亮 / 描边+非 90° 旋转(锁通用矩阵链)。
|
|
2704
|
+
* 种子约定(已知缺口的规避带,见 roadmap P4-5c):generic 字体;无阴影/虚线
|
|
2705
|
+
* 描边/渐变/textOffsetY(抖动未移植);width 取最长原始行横向墨宽 + 20px 余量
|
|
2706
|
+
* ——竖排换行判定轴仍是横向字宽(fabric 原样近似,两侧共享,余量避开容差带);
|
|
2707
|
+
* 不设 height(fabric initDimensions 与引擎 layout.height 同口径重算)。
|
|
2708
|
+
*/
|
|
2709
|
+
export const makeVerticalTextScene = () => {
|
|
2710
|
+
const base = (over) => ({
|
|
2711
|
+
type: 'textbox',
|
|
2712
|
+
scaleX: 1,
|
|
2713
|
+
scaleY: 1,
|
|
2714
|
+
angle: 90,
|
|
2715
|
+
originX: 'center',
|
|
2716
|
+
originY: 'center',
|
|
2717
|
+
opacity: 1,
|
|
2718
|
+
strokeWidth: 0,
|
|
2719
|
+
visible: true,
|
|
2720
|
+
fontFamily: 'sans-serif',
|
|
2721
|
+
lineHeight: 1.16,
|
|
2722
|
+
textAlign: 'left',
|
|
2723
|
+
vertical: true,
|
|
2724
|
+
...over
|
|
2725
|
+
});
|
|
2726
|
+
return [
|
|
2727
|
+
// 纯 CJK 两列(硬换行:行0 = 旋转后最右列,vertical-rl)
|
|
2728
|
+
{ ...base({ left: 170, top: 280, width: 340, text: '竖排文本渲染\n引擎对拍内核', fontSize: 48, fill: 'rgba(26,26,26,0.95)' }), id: 'vt0' },
|
|
2729
|
+
// 中英数字混排:CJK 直立 / 拉丁躺倒双 advance + 逐字字号(advance 走盒高)与填充覆写
|
|
2730
|
+
{
|
|
2731
|
+
...base({
|
|
2732
|
+
left: 400,
|
|
2733
|
+
top: 300,
|
|
2734
|
+
width: 440,
|
|
2735
|
+
text: '中文ABC 123混排',
|
|
2736
|
+
fontSize: 44,
|
|
2737
|
+
fill: 'rgba(30,80,150,0.95)',
|
|
2738
|
+
styles: { 0: { 0: { fontSize: 64 }, 6: { fill: '#c03030' }, 7: { fill: '#c03030' }, 8: { fill: '#c03030' } } }
|
|
2739
|
+
}),
|
|
2740
|
+
id: 'vt1'
|
|
2741
|
+
},
|
|
2742
|
+
// 括号+标点:bracket 平画转向 / symbol 锚点偏移直立 / 普通 CJK 直立全档
|
|
2743
|
+
{ ...base({ left: 640, top: 290, width: 420, text: '「引号」标注。\n、与〜省略…', fontSize: 44, fill: 'rgba(120,60,140,0.95)' }), id: 'vt2' },
|
|
2744
|
+
// textAlign:center 沿列内流向居中
|
|
2745
|
+
{ ...base({ left: 850, top: 280, width: 300, text: '居中对齐竖排\n次列短', fontSize: 40, textAlign: 'center', fill: 'rgba(160,60,90,0.95)' }), id: 'vt3' },
|
|
2746
|
+
// right + charSpacing:列内悬底对齐 + CJK 手动字距(vSpacing 轴)
|
|
2747
|
+
{ ...base({ left: 1060, top: 290, width: 300, text: '右对齐带字距', fontSize: 40, textAlign: 'right', charSpacing: 120, fill: 'rgba(20,110,60,0.95)' }), id: 'vt4' },
|
|
2748
|
+
// lineHeight 列距(竖排下 = 列间距)
|
|
2749
|
+
{ ...base({ left: 170, top: 700, width: 300, text: '松列距竖排\n第二列', fontSize: 40, lineHeight: 1.8, fill: 'rgba(40,40,40,0.95)' }), id: 'vt5' },
|
|
2750
|
+
// 下划线(竖排 run advance 换轴)+ 背景高亮(fabric base 盒 left 链,两侧同构)
|
|
2751
|
+
{
|
|
2752
|
+
...base({
|
|
2753
|
+
left: 410,
|
|
2754
|
+
top: 690,
|
|
2755
|
+
width: 340,
|
|
2756
|
+
text: '装饰线与背景\n高亮混排A',
|
|
2757
|
+
fontSize: 40,
|
|
2758
|
+
fill: 'rgba(20,20,20,0.95)',
|
|
2759
|
+
underline: true,
|
|
2760
|
+
textBackgroundColor: '#ffe08a',
|
|
2761
|
+
styles: { 0: { 5: { fill: '#2060c0' }, 6: { fill: '#2060c0' } } }
|
|
2762
|
+
}),
|
|
2763
|
+
id: 'vt6'
|
|
2764
|
+
},
|
|
2765
|
+
// 描边 + 非 90° 旋转:锁「内部坐标系 + 通用矩阵」等价链(CJK 净转 −45°)。
|
|
2766
|
+
// strokeWidth 取 1:应用 Textbox 构造器无条件强制对象级描边为 1(其 333 行),
|
|
2767
|
+
// 参考面(应用类直构造)与真实数据反序列化后同语义
|
|
2768
|
+
{ ...base({ left: 690, top: 680, width: 320, text: '描边旋转斜置', fontSize: 40, fill: '#2050a0', stroke: '#c03030', strokeWidth: 1, angle: 45 }), id: 'vt7' }
|
|
2769
|
+
];
|
|
2770
|
+
};
|
|
2771
|
+
/**
|
|
2772
|
+
* K-line 垂直偏移场景(批次 61):textOffsetY 隔字抖动(「上下上下」变形,
|
|
2773
|
+
* fabric Textbox._renderStr 2714-2757——偶字平、奇字 (textOffsetY/300)·fontSize/2)。
|
|
2774
|
+
*
|
|
2775
|
+
* 覆盖:正值最强档 / 负值上移 + 逐字 fontSize 抬峰 / 硬换行跨行奇偶连续
|
|
2776
|
+
* (fabric 全局累计不含 \n)/ 拉丁 + charSpacing / 描边 + 旋转(stroke cell
|
|
2777
|
+
* 同 jitter)/ 虚线描边(renderTextDashStroke 逐字分段 + 抖动 y + 余量扩边)/
|
|
2778
|
+
* 竖排(锚点 y 平移——对象 angle:90 后视觉左右交错)。
|
|
2779
|
+
* 种子约定:generic 字体;描边宽恒 1(应用 Textbox 构造器强制,vt7 同注记);
|
|
2780
|
+
* 无阴影(P3-4 烘焙近似属 shadowBake 已知域,不掺入本对拍);无 justify。
|
|
2781
|
+
*/
|
|
2782
|
+
export const makeKlineTextScene = () => {
|
|
2783
|
+
const base = (over) => ({
|
|
2784
|
+
type: 'textbox',
|
|
2785
|
+
scaleX: 1,
|
|
2786
|
+
scaleY: 1,
|
|
2787
|
+
angle: 0,
|
|
2788
|
+
originX: 'left',
|
|
2789
|
+
originY: 'top',
|
|
2790
|
+
opacity: 1,
|
|
2791
|
+
strokeWidth: 0,
|
|
2792
|
+
visible: true,
|
|
2793
|
+
fontFamily: 'sans-serif',
|
|
2794
|
+
lineHeight: 1.16,
|
|
2795
|
+
textAlign: 'left',
|
|
2796
|
+
fill: 'rgba(26,26,26,0.95)',
|
|
2797
|
+
textOffsetY: 300,
|
|
2798
|
+
...over
|
|
2799
|
+
});
|
|
2800
|
+
return [
|
|
2801
|
+
// 正值最强档:奇字下移 fontSize·0.5
|
|
2802
|
+
{ ...base({ left: 80, top: 60, width: 620, text: '隔字上下交错排列文本', fontSize: 48, fill: 'rgba(26,26,26,0.95)' }), id: 'kl0' },
|
|
2803
|
+
// 负值上移 + 逐字 fontSize 覆写抬峰(偏移量逐字各异)+ 逐字填充
|
|
2804
|
+
{
|
|
2805
|
+
...base({
|
|
2806
|
+
left: 820,
|
|
2807
|
+
top: 60,
|
|
2808
|
+
width: 560,
|
|
2809
|
+
text: 'jitter stagger up',
|
|
2810
|
+
fontSize: 42,
|
|
2811
|
+
textOffsetY: -240,
|
|
2812
|
+
fill: '#101010',
|
|
2813
|
+
styles: { 0: { 2: { fontSize: 60, fill: '#c03030' }, 3: { fill: '#c03030' }, 9: { fill: '#2060c0' } } }
|
|
2814
|
+
}),
|
|
2815
|
+
id: 'kl1'
|
|
2816
|
+
},
|
|
2817
|
+
// 硬换行跨行奇偶连续:次行首字全局位 4(偶=平),行内第 5/7 字抖
|
|
2818
|
+
{ ...base({ left: 80, top: 220, width: 620, text: '多行奇偶跨行\n连续累计判定', fontSize: 40, textOffsetY: 300, lineHeight: 1.4, fill: 'rgba(30,80,150,0.95)' }), id: 'kl2' },
|
|
2819
|
+
// 拉丁 + charSpacing(fabric _renderChars 2496:charSpacing≠0 本就逐字出笔)
|
|
2820
|
+
{ ...base({ left: 820, top: 220, width: 560, text: 'Latin ABC 123 spaced', fontSize: 40, textOffsetY: 180, charSpacing: 60, fill: 'rgba(20,110,60,0.95)' }), id: 'kl3' },
|
|
2821
|
+
// 描边 + 旋转(stroke cell 遍同 jitter;strokeWidth 恒 1 见头注)
|
|
2822
|
+
{ ...base({ left: 80, top: 420, width: 620, text: '描边旋转抖动链', fontSize: 44, textOffsetY: 240, fill: '#2050a0', stroke: '#c03030', strokeWidth: 1, angle: 15 }), id: 'kl4' },
|
|
2823
|
+
// 虚线描边(renderTextDashStroke:逐字断段 + 各字 y + 烘焙余量扩 jitterPad)
|
|
2824
|
+
{
|
|
2825
|
+
...base({ left: 820, top: 420, width: 560, text: 'dashed stroke jitter', fontSize: 42, textOffsetY: 300, fill: '#1a1a1a', stroke: '#2060c0', strokeWidth: 1, strokeDashArray: [8, 6] }),
|
|
2826
|
+
id: 'kl5'
|
|
2827
|
+
},
|
|
2828
|
+
// 竖排:锚点 y 平移(fabric charTop 加偏移后算旋转锚点;angle:90 转竖后视觉左右交错)
|
|
2829
|
+
{
|
|
2830
|
+
...base({
|
|
2831
|
+
left: 1440,
|
|
2832
|
+
top: 80,
|
|
2833
|
+
width: 360,
|
|
2834
|
+
text: '竖排抖动\n锚点交错',
|
|
2835
|
+
fontSize: 40,
|
|
2836
|
+
vertical: true,
|
|
2837
|
+
angle: 90,
|
|
2838
|
+
originX: 'center',
|
|
2839
|
+
originY: 'center',
|
|
2840
|
+
textOffsetY: 300,
|
|
2841
|
+
fill: 'rgba(120,60,140,0.95)'
|
|
2842
|
+
}),
|
|
2843
|
+
id: 'kl6'
|
|
2844
|
+
}
|
|
2845
|
+
];
|
|
2846
|
+
};
|
|
2847
|
+
/**
|
|
2848
|
+
* 划重点场景(批次62):raw.texts 的 svg highlight 段 → 段/行区间切分 +
|
|
2849
|
+
* span 拉伸与 isSingle 逐字两模式(应用 Textbox._renderHighlight parity)。
|
|
2850
|
+
*
|
|
2851
|
+
* mark path 取自应用 TextMark 真实配置(configs/texts.ts):圈圈(id1 开口
|
|
2852
|
+
* 椭圆描边)/划线(id2 直线,path height=0 → boxHeight 回退行字高 + translateY
|
|
2853
|
+
* 补半高 quirk)/背景(id4 粉色填充)/逐字三圆(id6 首子路径)/逐字手写
|
|
2854
|
+
* (id7 alignVertical=bottom)。texts 总长恒等于 text 长(fabric 守卫同款)。
|
|
2855
|
+
* 覆盖:整段行末 run(end==boxes.length 虚拟尾盒)/部分段混合/盒宽换行跨行
|
|
2856
|
+
* 切分/硬换行独立 '\n' 段/粗细重调/isSingle scale·alignVertical 档。
|
|
2857
|
+
*/
|
|
2858
|
+
export const makeTextHighlightScene = () => {
|
|
2859
|
+
const circleMark = 'M51.3646 45.8642C49.7808 46.2782 47.906 46.705 45.8588 47.0857M45.8588 47.0857C34.1649 49.2607 16.8486 49.9343 16.0277 38.1484C15.22 26.5533 32.264 22.3636 45.6135 24.5626C53.601 25.8783 57.4507 29.6208 57.9285 34.237C58.2811 37.6435 55.778 43.3702 45.8588 47.0857ZM45.8588 47.0857C42.3367 48.4051 37.8795 49.4708 32.283 50.0891';
|
|
2860
|
+
const lineMark = 'M15 36L57 36';
|
|
2861
|
+
const bgMark = 'M4,2.6C4.4,1.1,5.8,0,7.4,0h0.3v21H3.5c-2.3,0-4-2.2-3.4-4.4L4,2.6z M7.4,0H60.3v21H7.4V0z M64,18.4c-0.4,1.5-1.8,2.6-3.4,2.6h-0.3V0h4.2c2.3,0,4,2.2,3.4,4.4L64,18.4z';
|
|
2862
|
+
const dotMark = 'M35 36.5 a11 11 0 1 0 -22 0 a11 11 0 1 0 22 0 Z M48 36.5 a11 11 0 1 0 -22 0 a11 11 0 1 0 22 0 Z M59 36.5 a11 11 0 1 0 -22 0 a11 11 0 1 0 22 0 Z';
|
|
2863
|
+
const handMark = 'M26.147 47.719c.144-.04.295-.07.445-.052.282.029.529.215.811.273s.656-.14.584-.407c-.085-.302-.596-.267-.764-.54-.373-.616-1.112-.993-1.846-.993-.198 0-.396.029-.583.087a4 4 0 0 0-.613.261c-.83.407-1.714.924-2.014 1.777a2.4 2.4 0 0 0-.126.622 6.6 6.6 0 0 0 0 1.457c.132 1.11.679 2.306 1.773 2.672.349.116.728.14 1.094.116.896-.047 1.804-.337 2.441-.94.385-.367.674-.86.65-1.383-.018-.523-.415-1.04-.95-1.103-.626-.076-.638-1.11-1.239-1.295a.56.56 0 0 0-.62.22.54.54 0 0 0 .055.64c.223.243.192.632.018.91-.174.28-.457.471-.74.657-.222.151-.552.29-.733.087-.096-.104-.09-.261-.072-.4.18-1.243 1.172-2.335 2.423-2.666zm.998 3.258c.09-.21.114-.447.06-.668h.006a.8.8 0 0 0 .469-.151c-.06.4-.198.79-.39 1.144-.043.081-.187.023-.211-.064-.018-.087.03-.174.066-.261M23.375 50s.024.052.03.082c-.066.127 0 .278.012.423 0 .117-.096.244-.192.244a.13.13 0 0 1-.072-.029c-.06-.052-.048-.145-.03-.22q.08-.408.168-.825c0-.023.012-.052.024-.076.066-.098.24 0 .247.11 0 .117-.09.21-.18.291zm15.772-2.281c.144-.04.294-.07.445-.052.282.029.529.215.811.273s.656-.14.584-.407c-.085-.302-.596-.267-.764-.54-.373-.616-1.112-.993-1.846-.993a2 2 0 0 0-.583.087 4 4 0 0 0-.613.261c-.83.407-1.714.924-2.014 1.777a2.4 2.4 0 0 0-.126.622 6.6 6.6 0 0 0 0 1.457c.132 1.11.679 2.306 1.773 2.672.349.116.728.14 1.094.116.896-.047 1.804-.337 2.441-.94.385-.367.674-.86.65-1.383-.018-.523-.415-1.04-.95-1.103-.626-.076-.638-1.11-1.239-1.295a.56.56 0 0 0-.62.22.54.54 0 0 0 .055.64c.223.243.192.632.018.91-.174.28-.457.471-.74.657-.222.151-.553.29-.733.087-.096-.104-.09-.261-.072-.4.18-1.243 1.172-2.335 2.423-2.666z';
|
|
2864
|
+
const svg = (path, over = {}) => ({ type: 'svg', svgInfo: { path, stroke: '', fill: '', strokeWidth: 3, isFill: false, ...over } });
|
|
2865
|
+
const base = (over) => ({
|
|
2866
|
+
type: 'textbox',
|
|
2867
|
+
scaleX: 1,
|
|
2868
|
+
scaleY: 1,
|
|
2869
|
+
angle: 0,
|
|
2870
|
+
originX: 'left',
|
|
2871
|
+
originY: 'top',
|
|
2872
|
+
opacity: 1,
|
|
2873
|
+
strokeWidth: 0,
|
|
2874
|
+
visible: true,
|
|
2875
|
+
fontFamily: 'sans-serif',
|
|
2876
|
+
lineHeight: 1.16,
|
|
2877
|
+
textAlign: 'left',
|
|
2878
|
+
fill: 'rgba(26,26,26,0.95)',
|
|
2879
|
+
...over
|
|
2880
|
+
});
|
|
2881
|
+
return [
|
|
2882
|
+
// 划线整段(span 描边;path height=0 → boxHeight 回退 + 半高补偿 quirk;行末 run 触虚拟尾盒)
|
|
2883
|
+
{
|
|
2884
|
+
...base({ left: 80, top: 60, width: 620, text: '整段划线标记文本', fontSize: 44, texts: [{ text: '整段划线标记文本', highlight: svg(lineMark, { stroke: '#F96023', strokeWidth: 6 }) }] }),
|
|
2885
|
+
id: 'hl0'
|
|
2886
|
+
},
|
|
2887
|
+
// 圈圈部分段(前二字标记 + 其余裸段混合;圈圈 path 开口 Z 闭合)
|
|
2888
|
+
{
|
|
2889
|
+
...base({
|
|
2890
|
+
left: 820,
|
|
2891
|
+
top: 60,
|
|
2892
|
+
width: 560,
|
|
2893
|
+
text: '重点标记剩余部分',
|
|
2894
|
+
fontSize: 44,
|
|
2895
|
+
texts: [{ text: '重点标', highlight: svg(circleMark, { stroke: '#FFC300', strokeWidth: 2.5 }) }, { text: '记剩余部分' }]
|
|
2896
|
+
}),
|
|
2897
|
+
id: 'hl1'
|
|
2898
|
+
},
|
|
2899
|
+
// 背景填充 + 盒宽换行跨行切分(整段标记跨两个视觉行 → 两 run)
|
|
2900
|
+
{
|
|
2901
|
+
...base({
|
|
2902
|
+
left: 80,
|
|
2903
|
+
top: 220,
|
|
2904
|
+
width: 460,
|
|
2905
|
+
text: '背景填充高亮跨行自动换行分段渲染效果',
|
|
2906
|
+
fontSize: 40,
|
|
2907
|
+
lineHeight: 1.4,
|
|
2908
|
+
texts: [{ text: '背景填充高亮跨行自动换行分段渲染效果', highlight: svg(bgMark, { fill: 'pink', isFill: true, strokeWidth: 3 }) }]
|
|
2909
|
+
}),
|
|
2910
|
+
id: 'hl2'
|
|
2911
|
+
},
|
|
2912
|
+
// 逐字三圆 isSingle(首子路径逐字重复;scale 1.3)
|
|
2913
|
+
{
|
|
2914
|
+
...base({
|
|
2915
|
+
left: 820,
|
|
2916
|
+
top: 260,
|
|
2917
|
+
width: 560,
|
|
2918
|
+
text: 'dot mark per char',
|
|
2919
|
+
fontSize: 40,
|
|
2920
|
+
charSpacing: 40,
|
|
2921
|
+
texts: [{ text: 'dot mark per char', highlight: svg(dotMark, { fill: '#ff9cff', isFill: true, isSingle: true, scale: 1.3 }) }]
|
|
2922
|
+
}),
|
|
2923
|
+
id: 'hl3'
|
|
2924
|
+
},
|
|
2925
|
+
// 逐字手写 isSingle + alignVertical bottom + scale 0.3(拉丁跳空格字)
|
|
2926
|
+
{
|
|
2927
|
+
...base({
|
|
2928
|
+
left: 80,
|
|
2929
|
+
top: 420,
|
|
2930
|
+
width: 620,
|
|
2931
|
+
text: 'hand written below',
|
|
2932
|
+
fontSize: 44,
|
|
2933
|
+
texts: [{ text: 'hand written below', highlight: svg(handMark, { fill: '#f95555', isFill: true, isSingle: true, scale: 0.3, alignVertical: 'bottom' }) }]
|
|
2934
|
+
}),
|
|
2935
|
+
id: 'hl4'
|
|
2936
|
+
},
|
|
2937
|
+
// 硬换行独立 '\n' 段 + 两行异标(ElementMark splitTextByNewline 写入形态)
|
|
2938
|
+
{
|
|
2939
|
+
...base({
|
|
2940
|
+
left: 820,
|
|
2941
|
+
top: 420,
|
|
2942
|
+
width: 560,
|
|
2943
|
+
text: '上行划线\n下行圈圈',
|
|
2944
|
+
fontSize: 44,
|
|
2945
|
+
lineHeight: 1.4,
|
|
2946
|
+
texts: [
|
|
2947
|
+
{ text: '上行划线', highlight: svg(lineMark, { stroke: '#2060c0', strokeWidth: 8 }) },
|
|
2948
|
+
{ text: '\n' },
|
|
2949
|
+
{ text: '下行圈圈', highlight: svg(circleMark, { stroke: '#c03030', strokeWidth: 2.5 }) }
|
|
2950
|
+
]
|
|
2951
|
+
}),
|
|
2952
|
+
id: 'hl5'
|
|
2953
|
+
},
|
|
2954
|
+
// 粗细重调 + 旋转 + center 对齐(textAlign 影响行偏移 → run 左缘跟随)
|
|
2955
|
+
{
|
|
2956
|
+
...base({
|
|
2957
|
+
left: 80,
|
|
2958
|
+
top: 620,
|
|
2959
|
+
width: 620,
|
|
2960
|
+
text: '粗细重调旋转档',
|
|
2961
|
+
fontSize: 42,
|
|
2962
|
+
angle: 12,
|
|
2963
|
+
textAlign: 'center',
|
|
2964
|
+
texts: [{ text: '粗细重调旋转档', highlight: svg(lineMark, { stroke: '#746DFF', strokeWidth: 10 }) }]
|
|
2965
|
+
}),
|
|
2966
|
+
id: 'hl6'
|
|
2967
|
+
}
|
|
2968
|
+
];
|
|
2969
|
+
};
|
|
2970
|
+
/**
|
|
2971
|
+
* 弧形文本特效场景(批次 64):ArcText/CircleText + PSD 特效三族(投影/纯色
|
|
2972
|
+
* 填充/描边内外中)烘焙合成 parity(应用类沿 charTransformations 逐字绘制为
|
|
2973
|
+
* ground truth)。effects 数据形态照 makeTextFxScene(文本族 width 走 size.value、
|
|
2974
|
+
* stroke fillType 'color')。种子约定:generic 字体;无 outerGlow/gradientOverlay
|
|
2975
|
+
* (不承接族);无虚线/纹理类。
|
|
2976
|
+
*/
|
|
2977
|
+
export const makeArcTextFxScene = () => {
|
|
2978
|
+
const base = (over) => ({ scaleX: 1, scaleY: 1, angle: 0, originX: 'left', originY: 'top', opacity: 1, strokeWidth: 0, visible: true, fontFamily: 'sans-serif', lineHeight: 1.16, ...over });
|
|
2979
|
+
const shadow = (fill, blur, offsetX, offsetY) => ({ enabled: true, showInDialog: true, fill, blur, offsetX, offsetY });
|
|
2980
|
+
const solid = (fill) => ({ enabled: true, showInDialog: true, fillType: 0, fill });
|
|
2981
|
+
const stroke = (fill, value, position) => ({ enabled: true, showInDialog: true, fill, fillType: 'color', size: { value }, position });
|
|
2982
|
+
const fx = (effects) => ({
|
|
2983
|
+
stroke: [],
|
|
2984
|
+
solidFill: [],
|
|
2985
|
+
dropShadow: [],
|
|
2986
|
+
outerGlow: { enabled: true, showInDialog: true },
|
|
2987
|
+
gradientOverlay: [],
|
|
2988
|
+
...effects
|
|
2989
|
+
});
|
|
2990
|
+
return [
|
|
2991
|
+
// 弧+投影(正曲率)
|
|
2992
|
+
{
|
|
2993
|
+
...base({
|
|
2994
|
+
type: 'ArcText',
|
|
2995
|
+
left: 60,
|
|
2996
|
+
top: 40,
|
|
2997
|
+
text: '弧形投影文字',
|
|
2998
|
+
fontSize: 44,
|
|
2999
|
+
fill: 'rgba(30,90,150,0.95)',
|
|
3000
|
+
curvature: 70,
|
|
3001
|
+
effects: fx({ dropShadow: [shadow('rgba(200,40,40,0.55)', 12, 10, 8)] })
|
|
3002
|
+
}),
|
|
3003
|
+
id: 'afx0'
|
|
3004
|
+
},
|
|
3005
|
+
// 弧+外描边(负曲率下垂)
|
|
3006
|
+
{
|
|
3007
|
+
...base({ type: 'ArcText', left: 480, top: 30, text: '下垂外描边', fontSize: 44, fill: 'rgba(160,60,90,0.95)', curvature: -60, effects: fx({ stroke: [stroke('#ff6600', 6, 'outside')] }) }),
|
|
3008
|
+
id: 'afx1'
|
|
3009
|
+
},
|
|
3010
|
+
// 弧+内描边(source-atop 裁进字形域)
|
|
3011
|
+
{
|
|
3012
|
+
...base({ type: 'ArcText', left: 60, top: 250, text: '内描边弧形', fontSize: 40, fill: 'rgba(50,120,70,0.95)', curvature: 50, effects: fx({ stroke: [stroke('#20c0a0', 5, 'inside')] }) }),
|
|
3013
|
+
id: 'afx2'
|
|
3014
|
+
},
|
|
3015
|
+
// 弧+居中描边+纯色填充双层
|
|
3016
|
+
{
|
|
3017
|
+
...base({
|
|
3018
|
+
type: 'ArcText',
|
|
3019
|
+
left: 480,
|
|
3020
|
+
top: 240,
|
|
3021
|
+
text: '填充居描双层',
|
|
3022
|
+
fontSize: 40,
|
|
3023
|
+
fill: 'rgba(120,80,160,0.95)',
|
|
3024
|
+
curvature: 65,
|
|
3025
|
+
effects: fx({ solidFill: [solid('rgba(255,220,80,0.9)')], stroke: [stroke('#8040c0', 4, 'center')] })
|
|
3026
|
+
}),
|
|
3027
|
+
id: 'afx3'
|
|
3028
|
+
},
|
|
3029
|
+
// 圆形环绕+投影+外描边多层组合
|
|
3030
|
+
{
|
|
3031
|
+
...base({
|
|
3032
|
+
type: 'CircleText',
|
|
3033
|
+
left: 60,
|
|
3034
|
+
top: 450,
|
|
3035
|
+
text: '圆形环绕多层特效',
|
|
3036
|
+
fontSize: 30,
|
|
3037
|
+
fill: 'rgba(180,110,30,0.95)',
|
|
3038
|
+
circleSize: 85,
|
|
3039
|
+
circleSweep: 360,
|
|
3040
|
+
effects: fx({ dropShadow: [shadow('rgba(30,30,120,0.5)', 10, 8, 8)], stroke: [stroke('#2050ff', 4, 'outside')] })
|
|
3041
|
+
}),
|
|
3042
|
+
id: 'afx4'
|
|
3043
|
+
},
|
|
3044
|
+
// 弧+投影+外描边+填充全叠加
|
|
3045
|
+
{
|
|
3046
|
+
...base({
|
|
3047
|
+
type: 'ArcText',
|
|
3048
|
+
left: 420,
|
|
3049
|
+
top: 440,
|
|
3050
|
+
text: '全特效叠加弧形',
|
|
3051
|
+
fontSize: 36,
|
|
3052
|
+
fill: 'rgba(30,120,140,0.95)',
|
|
3053
|
+
curvature: 55,
|
|
3054
|
+
effects: fx({ dropShadow: [shadow('rgba(160,20,20,0.5)', 10, 7, 7)], solidFill: [solid('rgba(140,220,255,0.85)')], stroke: [stroke('#c02060', 4, 'outside')] })
|
|
3055
|
+
}),
|
|
3056
|
+
id: 'afx5'
|
|
3057
|
+
}
|
|
3058
|
+
];
|
|
3059
|
+
};
|
|
3060
|
+
/**
|
|
3061
|
+
* 弧形文本漏白回归场景(批次 80):用户报障同款形态——小字黑填充 + 双层外描边
|
|
3062
|
+
* (红 #e2534d 4px 内环 + 灰 #666666 8px 外环)。小字号(24)计数器窄,描边带
|
|
3063
|
+
* 淹入字形细缝——EDT 源与超采样尺度失配(rs 桶源被重采样)时细缝轮廓漂移露白,
|
|
3064
|
+
* 是漏白判别力最强的形态(大字号计数器宽,环带与字形边缘的亚像素失配不显形)。
|
|
3065
|
+
*/
|
|
3066
|
+
export const makeArcTextLeakScene = () => [
|
|
3067
|
+
{
|
|
3068
|
+
scaleX: 1,
|
|
3069
|
+
scaleY: 1,
|
|
3070
|
+
angle: 0,
|
|
3071
|
+
originX: 'left',
|
|
3072
|
+
originY: 'top',
|
|
3073
|
+
opacity: 1,
|
|
3074
|
+
strokeWidth: 0,
|
|
3075
|
+
visible: true,
|
|
3076
|
+
fontFamily: 'sans-serif',
|
|
3077
|
+
lineHeight: 1.16,
|
|
3078
|
+
type: 'ArcText',
|
|
3079
|
+
id: 'alk0',
|
|
3080
|
+
left: 60,
|
|
3081
|
+
top: 60,
|
|
3082
|
+
text: '点击编辑标题',
|
|
3083
|
+
fontSize: 24,
|
|
3084
|
+
fill: '#000000',
|
|
3085
|
+
curvature: 55,
|
|
3086
|
+
effects: {
|
|
3087
|
+
stroke: [
|
|
3088
|
+
{ enabled: true, showInDialog: true, fill: '#e2534d', fillType: 'color', size: { value: 4 }, position: 'outside' },
|
|
3089
|
+
{ enabled: true, showInDialog: true, fill: '#666666', fillType: 'color', size: { value: 8 }, position: 'outside' }
|
|
3090
|
+
],
|
|
3091
|
+
solidFill: [],
|
|
3092
|
+
dropShadow: [],
|
|
3093
|
+
outerGlow: { enabled: true, showInDialog: true },
|
|
3094
|
+
gradientOverlay: []
|
|
3095
|
+
}
|
|
3096
|
+
}
|
|
3097
|
+
];
|
|
3098
|
+
/**
|
|
3099
|
+
* 表格场景(Phase 4 P4-4):Table 的布局重算 + 摆位 quirk parity。
|
|
3100
|
+
*
|
|
3101
|
+
* 引擎与参考面(应用 Table.fromObject)都不消费序列化 objects/rowHeights——
|
|
3102
|
+
* 由 rows/cols/columnWidths/manualRowHeights/cellData 重算布局;fromObject 的
|
|
3103
|
+
* triggerLayout 会平移 left/top(构造期等列宽/空文本行高 → 重设宽高回锚),
|
|
3104
|
+
* tb1/tb2/tb6/tb7 显式覆盖 Δh/Δw/双轴/带旋转缩放的平移。
|
|
3105
|
+
* 覆盖:CJK 基线 / splitByGrapheme 换行(拉丁+CJK)/ 手动行高(含 manual <
|
|
3106
|
+
* 文本需求时回涨)/ colspan / rowspan(含 isMerged 从格跳过)/ verticalAlign×
|
|
3107
|
+
* textAlign 全档 + serif italic bold / cellSpacing + 不等列宽 + 逐格填充描边 /
|
|
3108
|
+
* 旋转缩放链 / 空文本格与 cellData 缺格。
|
|
3109
|
+
* 种子约定(已知缺口的规避带,见 roadmap):generic 字体(sans-serif/serif,
|
|
3110
|
+
* 避开 loadFontFamily 异步);单元格文本远离 collapseUnexpectedWrapIfSingleLineFits
|
|
3111
|
+
* 容差带(单行放宽 ≥20px 或溢出 ≥20px);无逐字 styles/charSpacing/表格 opacity。
|
|
3112
|
+
*/
|
|
3113
|
+
export const makeTableScene = () => {
|
|
3114
|
+
const base = (over) => ({ type: 'Table', scaleX: 1, scaleY: 1, angle: 0, originX: 'left', originY: 'top', opacity: 1, strokeWidth: 0, visible: true, ...over });
|
|
3115
|
+
// 单元格条目(真实 toObject 形态:fill/stroke/textFill/fontSize/fontFamily/textAlign
|
|
3116
|
+
// 全显式)。fontWeight/fontStyle 必写——fromObject 的 text.set 原样透传,undefined
|
|
3117
|
+
// 会抹掉 fabric 类默认 'normal' 且 fontStyle 触发即时重排(getFontCache 崩);
|
|
3118
|
+
// 生产 toObject 恒写这两键,种子须同形
|
|
3119
|
+
const cell = (row, col, over) => ({
|
|
3120
|
+
row,
|
|
3121
|
+
col,
|
|
3122
|
+
fill: '#ffffff',
|
|
3123
|
+
stroke: '#d6d6d6',
|
|
3124
|
+
text: '',
|
|
3125
|
+
textFill: '#333333',
|
|
3126
|
+
fontSize: 14,
|
|
3127
|
+
fontFamily: 'sans-serif',
|
|
3128
|
+
fontWeight: 'normal',
|
|
3129
|
+
fontStyle: 'normal',
|
|
3130
|
+
textAlign: 'center',
|
|
3131
|
+
...over
|
|
3132
|
+
});
|
|
3133
|
+
return [
|
|
3134
|
+
// 基线:等列宽 + 单行文本(w0==w1、h0==h1——摆位平移为零)
|
|
3135
|
+
{
|
|
3136
|
+
...base({
|
|
3137
|
+
left: 60,
|
|
3138
|
+
top: 50,
|
|
3139
|
+
rows: 3,
|
|
3140
|
+
cols: 3,
|
|
3141
|
+
columnWidths: [120, 120, 120],
|
|
3142
|
+
minCellHeight: 40,
|
|
3143
|
+
cellPadding: 8,
|
|
3144
|
+
cellSpacing: 0,
|
|
3145
|
+
cellStrokeWidth: 1,
|
|
3146
|
+
cellFill: '#ffffff',
|
|
3147
|
+
cellStroke: '#d0d0d0',
|
|
3148
|
+
textFill: '#333333'
|
|
3149
|
+
}),
|
|
3150
|
+
id: 'tb0',
|
|
3151
|
+
cellData: [
|
|
3152
|
+
cell(0, 0, { text: '名称' }),
|
|
3153
|
+
cell(0, 1, { text: '数量' }),
|
|
3154
|
+
cell(0, 2, { text: '单价' }),
|
|
3155
|
+
cell(1, 0, { text: '苹果' }),
|
|
3156
|
+
cell(1, 1, { text: '香蕉' }),
|
|
3157
|
+
cell(1, 2, { text: '葡萄' }),
|
|
3158
|
+
cell(2, 0, { text: '合计' }),
|
|
3159
|
+
cell(2, 1, { text: '十二' }),
|
|
3160
|
+
cell(2, 2, { text: '三十四', textFill: '#8a2b2b' })
|
|
3161
|
+
]
|
|
3162
|
+
},
|
|
3163
|
+
// splitByGrapheme 换行:拉丁逐字素断行 + CJK 撑高行(Δh 摆位平移)
|
|
3164
|
+
{
|
|
3165
|
+
...base({
|
|
3166
|
+
left: 500,
|
|
3167
|
+
top: 40,
|
|
3168
|
+
rows: 2,
|
|
3169
|
+
cols: 2,
|
|
3170
|
+
columnWidths: [130, 130],
|
|
3171
|
+
minCellHeight: 36,
|
|
3172
|
+
cellPadding: 6,
|
|
3173
|
+
cellSpacing: 0,
|
|
3174
|
+
cellStrokeWidth: 1,
|
|
3175
|
+
cellFill: '#ffffff',
|
|
3176
|
+
cellStroke: '#c8c8c8',
|
|
3177
|
+
textFill: '#333333'
|
|
3178
|
+
}),
|
|
3179
|
+
id: 'tb1',
|
|
3180
|
+
cellData: [
|
|
3181
|
+
cell(0, 0, { text: 'A rather long latin sentence to wrap', fontSize: 13, textAlign: 'left' }),
|
|
3182
|
+
cell(0, 1, { text: '春夏秋冬循环往复四季更替', fontSize: 13, textFill: '#1b4a8a' }),
|
|
3183
|
+
cell(1, 0, { text: 'short' }),
|
|
3184
|
+
cell(1, 1, { text: '短句' })
|
|
3185
|
+
]
|
|
3186
|
+
},
|
|
3187
|
+
// 手动行高:manual=64(高)/ manual=30 < 文本需求(回涨 31.82)/ null(默认);
|
|
3188
|
+
// (2,1) cellData 缺格(应用侧 = 空文本对象参与行高,引擎 emptyCellHeight 同义)
|
|
3189
|
+
{
|
|
3190
|
+
...base({
|
|
3191
|
+
left: 880,
|
|
3192
|
+
top: 50,
|
|
3193
|
+
rows: 3,
|
|
3194
|
+
cols: 2,
|
|
3195
|
+
columnWidths: [110, 110],
|
|
3196
|
+
manualRowHeights: [64, 30, null],
|
|
3197
|
+
minCellHeight: 40,
|
|
3198
|
+
cellPadding: 8,
|
|
3199
|
+
cellSpacing: 0,
|
|
3200
|
+
cellStrokeWidth: 1,
|
|
3201
|
+
cellFill: '#ffffff',
|
|
3202
|
+
cellStroke: '#d0d0d0',
|
|
3203
|
+
textFill: '#333333'
|
|
3204
|
+
}),
|
|
3205
|
+
id: 'tb2',
|
|
3206
|
+
cellData: [cell(0, 0, { text: '高行' }), cell(0, 1, { text: '手动' }), cell(1, 0, { text: '回涨', fontSize: 14 }), cell(1, 1, { text: '行' }), cell(2, 0, { text: '常规' })]
|
|
3207
|
+
},
|
|
3208
|
+
// colspan=2 表头(跨列文本盒 = 合并列宽 − 2×padding)+ 空文本格
|
|
3209
|
+
{
|
|
3210
|
+
...base({
|
|
3211
|
+
left: 60,
|
|
3212
|
+
top: 300,
|
|
3213
|
+
rows: 2,
|
|
3214
|
+
cols: 3,
|
|
3215
|
+
columnWidths: [100, 100, 100],
|
|
3216
|
+
minCellHeight: 40,
|
|
3217
|
+
cellPadding: 8,
|
|
3218
|
+
cellSpacing: 0,
|
|
3219
|
+
cellStrokeWidth: 1,
|
|
3220
|
+
cellFill: '#ffffff',
|
|
3221
|
+
cellStroke: '#d0d0d0',
|
|
3222
|
+
textFill: '#333333'
|
|
3223
|
+
}),
|
|
3224
|
+
id: 'tb3',
|
|
3225
|
+
cellData: [
|
|
3226
|
+
cell(0, 0, { text: '跨两列的表头', colspan: 2, fontSize: 15, fontWeight: 'bold', fill: '#f2f2f2' }),
|
|
3227
|
+
cell(0, 2, { text: '备注' }),
|
|
3228
|
+
cell(1, 0, { text: '甲' }),
|
|
3229
|
+
cell(1, 1, {}),
|
|
3230
|
+
cell(1, 2, { text: '丙' })
|
|
3231
|
+
]
|
|
3232
|
+
},
|
|
3233
|
+
// rowspan=2 纵向合并((1,0) 为 isMerged 从格——引擎不合成、参考面 opacity 0)
|
|
3234
|
+
{
|
|
3235
|
+
...base({
|
|
3236
|
+
left: 500,
|
|
3237
|
+
top: 300,
|
|
3238
|
+
rows: 3,
|
|
3239
|
+
cols: 2,
|
|
3240
|
+
columnWidths: [110, 110],
|
|
3241
|
+
minCellHeight: 40,
|
|
3242
|
+
cellPadding: 8,
|
|
3243
|
+
cellSpacing: 0,
|
|
3244
|
+
cellStrokeWidth: 1,
|
|
3245
|
+
cellFill: '#ffffff',
|
|
3246
|
+
cellStroke: '#d0d0d0',
|
|
3247
|
+
textFill: '#333333'
|
|
3248
|
+
}),
|
|
3249
|
+
id: 'tb4',
|
|
3250
|
+
cellData: [
|
|
3251
|
+
cell(0, 0, { text: '跨两行内容', rowspan: 2, fill: '#eef7ee', stroke: '#6ba36b' }),
|
|
3252
|
+
cell(0, 1, { text: '右上' }),
|
|
3253
|
+
cell(1, 0, { isMerged: true, mergeParent: { row: 0, col: 0 } }),
|
|
3254
|
+
cell(1, 1, { text: '右中' }),
|
|
3255
|
+
cell(2, 0, { text: '左下' }),
|
|
3256
|
+
cell(2, 1, { text: '右下' })
|
|
3257
|
+
]
|
|
3258
|
+
},
|
|
3259
|
+
// verticalAlign(top/middle/bottom)× textAlign(left/center/right)全档 +
|
|
3260
|
+
// serif italic bold 字体变体(行高 64 使对齐差异可见)
|
|
3261
|
+
{
|
|
3262
|
+
...base({
|
|
3263
|
+
left: 820,
|
|
3264
|
+
top: 300,
|
|
3265
|
+
rows: 3,
|
|
3266
|
+
cols: 2,
|
|
3267
|
+
columnWidths: [130, 130],
|
|
3268
|
+
minCellHeight: 64,
|
|
3269
|
+
cellPadding: 8,
|
|
3270
|
+
cellSpacing: 0,
|
|
3271
|
+
cellStrokeWidth: 1,
|
|
3272
|
+
cellFill: '#ffffff',
|
|
3273
|
+
cellStroke: '#d0d0d0',
|
|
3274
|
+
textFill: '#333333'
|
|
3275
|
+
}),
|
|
3276
|
+
id: 'tb5',
|
|
3277
|
+
cellData: [
|
|
3278
|
+
cell(0, 0, { text: '顶部居左', verticalAlign: 'top', textAlign: 'left' }),
|
|
3279
|
+
cell(0, 1, { text: '底部居右', verticalAlign: 'bottom', textAlign: 'right', fontFamily: 'serif', fontStyle: 'italic', fontWeight: 'bold', textFill: '#6a3fa0' }),
|
|
3280
|
+
cell(1, 0, { text: '垂直居中' }),
|
|
3281
|
+
cell(1, 1, { text: '顶部居右', verticalAlign: 'top', textAlign: 'right', fontWeight: 'bold' }),
|
|
3282
|
+
cell(2, 0, { text: '底部居左', verticalAlign: 'bottom', textAlign: 'left', textFill: '#1b4a8a' }),
|
|
3283
|
+
cell(2, 1, { text: '默认档' })
|
|
3284
|
+
]
|
|
3285
|
+
},
|
|
3286
|
+
// cellSpacing=2 + 不等列宽(Δw=−45 强摆位平移)+ 逐格填充描边(视觉左移到 ~15)
|
|
3287
|
+
{
|
|
3288
|
+
...base({
|
|
3289
|
+
left: 60,
|
|
3290
|
+
top: 560,
|
|
3291
|
+
rows: 2,
|
|
3292
|
+
cols: 3,
|
|
3293
|
+
columnWidths: [90, 150, 120],
|
|
3294
|
+
minCellHeight: 40,
|
|
3295
|
+
cellPadding: 8,
|
|
3296
|
+
cellSpacing: 2,
|
|
3297
|
+
cellStrokeWidth: 1,
|
|
3298
|
+
cellFill: '#ffffff',
|
|
3299
|
+
cellStroke: '#d6d6d6',
|
|
3300
|
+
textFill: '#333333'
|
|
3301
|
+
}),
|
|
3302
|
+
id: 'tb6',
|
|
3303
|
+
cellData: [
|
|
3304
|
+
cell(0, 0, { text: '甲', fill: '#e8f0fe', stroke: '#5b7fb9' }),
|
|
3305
|
+
cell(0, 1, { text: '宽列内容', fill: '#fdf0e8', stroke: '#b97a5b', textAlign: 'left' }),
|
|
3306
|
+
cell(0, 2, { text: '丙' }),
|
|
3307
|
+
cell(1, 0, { text: '丁', fill: '#eef7ee', stroke: '#6ba36b' }),
|
|
3308
|
+
cell(1, 1, { text: '戊' }),
|
|
3309
|
+
cell(1, 2, { text: '己' })
|
|
3310
|
+
]
|
|
3311
|
+
},
|
|
3312
|
+
// 旋转 + 缩放链(摆位平移随 angle 旋转、随 scale 缩放——mat2d 中心换算复刻)
|
|
3313
|
+
{
|
|
3314
|
+
...base({
|
|
3315
|
+
left: 900,
|
|
3316
|
+
top: 540,
|
|
3317
|
+
rows: 2,
|
|
3318
|
+
cols: 2,
|
|
3319
|
+
columnWidths: [120, 100],
|
|
3320
|
+
minCellHeight: 40,
|
|
3321
|
+
cellPadding: 8,
|
|
3322
|
+
cellSpacing: 1,
|
|
3323
|
+
cellStrokeWidth: 1,
|
|
3324
|
+
cellFill: '#ffffff',
|
|
3325
|
+
cellStroke: '#c0c0c0',
|
|
3326
|
+
textFill: '#333333',
|
|
3327
|
+
angle: 12,
|
|
3328
|
+
scaleX: 1.1,
|
|
3329
|
+
scaleY: 0.92
|
|
3330
|
+
}),
|
|
3331
|
+
id: 'tb7',
|
|
3332
|
+
cellData: [cell(0, 0, { text: '旋转表格' }), cell(0, 1, { text: '缩放', fill: '#fff7e8', stroke: '#c0a060' }), cell(1, 0, { text: '第二行' }), cell(1, 1, { text: '末格' })]
|
|
3333
|
+
}
|
|
3334
|
+
];
|
|
3335
|
+
};
|
|
3336
|
+
/**
|
|
3337
|
+
* 拼图/蒙版场景(P4-5b(2/2)):FabricPuzzle(Group + Mask 子对象 + layoutConfig)
|
|
3338
|
+
* 与顶层独立 Mask。覆盖:
|
|
3339
|
+
* - pz0 2×2 基线(四块全填充、cornerRadius 圆角)
|
|
3340
|
+
* - pz1 不规则布局(colSpan 跨列 + 空块——无 clipImage 直出形状位图)+ 双向
|
|
3341
|
+
* gap + groupPadding
|
|
3342
|
+
* - pz2 clipImage 变换链(angle/flip/clipX/clipY 偏移 + 用户缩放因子)
|
|
3343
|
+
* - pz3 组旋转 25° + 缩放 1.15 + 半透明(隔离合成口径)
|
|
3344
|
+
* - pz4 结构不完整(pieces 3 vs 实有 2 mask)→ 两侧自动收拢成 2 块(裁尾
|
|
3345
|
+
* 重算 cols=2)再重排(应用 updateLayout / 引擎 relayoutFromConfig 同公式),
|
|
3346
|
+
* authored 几何刻意写错以证明重排
|
|
3347
|
+
* - pz5 顶层独立 Mask(非拼图内)
|
|
3348
|
+
* 遮罩形状源与填充图共用本地素材(不透明位图 → destination-in 为恒等 alpha,
|
|
3349
|
+
* 圆角由烘焙 clip 提供);mask 序列化形态对齐生产 toObject(origin center、
|
|
3350
|
+
* 恒写 width/height/cropX/cropY、clipImage 为完整序列化 image 对象)。
|
|
3351
|
+
*/
|
|
3352
|
+
export const makePuzzleScene = () => {
|
|
3353
|
+
const shapeSrc = assetUrl('../../assets/images/nasty_fabric.png'); // 198×200(不透明)
|
|
3354
|
+
const woodSrc = assetUrl('../../assets/images/retina_wood.png'); // 512×512
|
|
3355
|
+
const floralSrc = assetUrl('../../assets/images/greyfloral.png'); // 150×124
|
|
3356
|
+
const rotateSrc = assetUrl('../../assets/images/rotate.png'); // 200×200
|
|
3357
|
+
const honeySrc = assetUrl('../../assets/images/honey_im_subtle.png'); // 179×132
|
|
3358
|
+
/** mask 序列化子对象(cover 初始比例由图片 natural 与块尺寸推出——生产链路
|
|
3359
|
+
* useHandleCreate 的 cover 填充同公式) */
|
|
3360
|
+
const clip = (src, natW, natH, w, h, extra = {}) => ({
|
|
3361
|
+
type: 'image',
|
|
3362
|
+
src,
|
|
3363
|
+
left: 0,
|
|
3364
|
+
top: 0,
|
|
3365
|
+
width: natW,
|
|
3366
|
+
height: natH,
|
|
3367
|
+
scaleX: Math.max(w / natW, h / natH),
|
|
3368
|
+
scaleY: Math.max(w / natW, h / natH),
|
|
3369
|
+
angle: 0,
|
|
3370
|
+
flipX: false,
|
|
3371
|
+
flipY: false,
|
|
3372
|
+
opacity: 1,
|
|
3373
|
+
originX: 'left',
|
|
3374
|
+
originY: 'top',
|
|
3375
|
+
crossOrigin: 'anonymous',
|
|
3376
|
+
cropX: 0,
|
|
3377
|
+
cropY: 0,
|
|
3378
|
+
strokeWidth: 0,
|
|
3379
|
+
visible: true,
|
|
3380
|
+
...extra
|
|
3381
|
+
});
|
|
3382
|
+
/** clipImage 带滤镜的 mask 种子(B1(余) 收尾片):属性赋值路线避开字面量 excess check */
|
|
3383
|
+
const maskClipWithFilters = (id, left, top, w, h, cornerRadius, clipObj, filters) => {
|
|
3384
|
+
;
|
|
3385
|
+
clipObj.filters = filters;
|
|
3386
|
+
return mask(id, left, top, w, h, cornerRadius, clipObj);
|
|
3387
|
+
};
|
|
3388
|
+
const mask = (id, left, top, w, h, cornerRadius, clipImage, extra = {}) => ({
|
|
3389
|
+
type: 'Mask',
|
|
3390
|
+
id,
|
|
3391
|
+
left,
|
|
3392
|
+
top,
|
|
3393
|
+
width: w,
|
|
3394
|
+
height: h,
|
|
3395
|
+
originX: 'center',
|
|
3396
|
+
originY: 'center',
|
|
3397
|
+
scaleX: 1,
|
|
3398
|
+
scaleY: 1,
|
|
3399
|
+
angle: 0,
|
|
3400
|
+
flipX: false,
|
|
3401
|
+
flipY: false,
|
|
3402
|
+
opacity: 1,
|
|
3403
|
+
strokeWidth: 0,
|
|
3404
|
+
visible: true,
|
|
3405
|
+
src: shapeSrc,
|
|
3406
|
+
crossOrigin: 'anonymous',
|
|
3407
|
+
cropX: 0,
|
|
3408
|
+
cropY: 0,
|
|
3409
|
+
cornerRadius,
|
|
3410
|
+
innerRadius: 12,
|
|
3411
|
+
outerRadius: 0,
|
|
3412
|
+
seamlessMode: false,
|
|
3413
|
+
seamlessNess: 0,
|
|
3414
|
+
clipX: 0,
|
|
3415
|
+
clipY: 0,
|
|
3416
|
+
...(clipImage ? { clipImage } : {}),
|
|
3417
|
+
...extra
|
|
3418
|
+
});
|
|
3419
|
+
const puzzle = (id, left, top, layout, masks, params, extra = {}) => ({
|
|
3420
|
+
type: 'Puzzle',
|
|
3421
|
+
id,
|
|
3422
|
+
left,
|
|
3423
|
+
top,
|
|
3424
|
+
originX: 'center',
|
|
3425
|
+
originY: 'center',
|
|
3426
|
+
scaleX: 1,
|
|
3427
|
+
scaleY: 1,
|
|
3428
|
+
angle: 0,
|
|
3429
|
+
flipX: false,
|
|
3430
|
+
flipY: false,
|
|
3431
|
+
opacity: 1,
|
|
3432
|
+
strokeWidth: 0,
|
|
3433
|
+
visible: true,
|
|
3434
|
+
subTargetCheck: true,
|
|
3435
|
+
interactive: false,
|
|
3436
|
+
...params,
|
|
3437
|
+
layoutConfig: layout,
|
|
3438
|
+
objects: masks,
|
|
3439
|
+
...extra
|
|
3440
|
+
});
|
|
3441
|
+
// pz0:300×300、gap10 → cell 145、step155、中心 ±77.5
|
|
3442
|
+
// pz1:340×220、padding6 → inner 328×208;cols3/rows2、hGap8/vGap14 → cell 104×97、step112/111
|
|
3443
|
+
// pz2:300×140、gap10 → cell 145×140、step155
|
|
3444
|
+
// pz3:260×260、rows2/cols1、gap10 → cell 260×125、step135
|
|
3445
|
+
// pz4:300×150、cols3 只做 2 块 → 自动收拢 cols=2:cell 144、step156、中心 ±78
|
|
3446
|
+
//(authored 几何故意错——收拢重排覆盖)
|
|
3447
|
+
return [
|
|
3448
|
+
puzzle('pz0', 185, 175, {
|
|
3449
|
+
rows: 2,
|
|
3450
|
+
cols: 2,
|
|
3451
|
+
pieces: [
|
|
3452
|
+
{ id: 1, row: 0, col: 0 },
|
|
3453
|
+
{ id: 2, row: 0, col: 1 },
|
|
3454
|
+
{ id: 3, row: 1, col: 0 },
|
|
3455
|
+
{ id: 4, row: 1, col: 1 }
|
|
3456
|
+
]
|
|
3457
|
+
}, [
|
|
3458
|
+
mask('pz0_m0', -77.5, -77.5, 145, 145, 12, clip(woodSrc, 512, 512, 145, 145)),
|
|
3459
|
+
mask('pz0_m1', 77.5, -77.5, 145, 145, 12, clip(floralSrc, 150, 124, 145, 145)),
|
|
3460
|
+
mask('pz0_m2', -77.5, 77.5, 145, 145, 12, clip(rotateSrc, 200, 200, 145, 145)),
|
|
3461
|
+
mask('pz0_m3', 77.5, 77.5, 145, 145, 12, clip(shapeSrc, 198, 200, 145, 145))
|
|
3462
|
+
], { layoutWidth: 300, layoutHeight: 300, hGap: 10, vGap: 10, groupPadding: 0, cornerRadius: 12 }),
|
|
3463
|
+
puzzle('pz1', 600, 175, {
|
|
3464
|
+
rows: 2,
|
|
3465
|
+
cols: 3,
|
|
3466
|
+
pieces: [
|
|
3467
|
+
{ id: 1, row: 0, col: 0, colSpan: 2 },
|
|
3468
|
+
{ id: 2, row: 0, col: 2 },
|
|
3469
|
+
{ id: 3, row: 1, col: 0 },
|
|
3470
|
+
{ id: 4, row: 1, col: 1, colSpan: 2 }
|
|
3471
|
+
]
|
|
3472
|
+
}, [
|
|
3473
|
+
mask('pz1_m0', -56, -55.5, 216, 97, 10, clip(woodSrc, 512, 512, 216, 97)),
|
|
3474
|
+
// 空块:无 clipImage → 形状位图直出(应用 super.render 同构)
|
|
3475
|
+
mask('pz1_m1', 112, -55.5, 104, 97, 10, null),
|
|
3476
|
+
// col0 单格中心 = (0−1)×112 = −112(列基准 (cols−1)/2 = 1——首版误写 −56
|
|
3477
|
+
// 与 m3 重叠 48px,种子自检测试锁定;见 puzzleLayout.spec「种子几何=公式」)
|
|
3478
|
+
mask('pz1_m2', -112, 55.5, 104, 97, 10, clip(honeySrc, 179, 132, 104, 97)),
|
|
3479
|
+
mask('pz1_m3', 56, 55.5, 216, 97, 10, clip(floralSrc, 150, 124, 216, 97))
|
|
3480
|
+
], { layoutWidth: 340, layoutHeight: 220, hGap: 8, vGap: 14, groupPadding: 6, cornerRadius: 10 }),
|
|
3481
|
+
puzzle('pz2', 990, 175, {
|
|
3482
|
+
rows: 1,
|
|
3483
|
+
cols: 2,
|
|
3484
|
+
pieces: [
|
|
3485
|
+
{ id: 1, row: 0, col: 0 },
|
|
3486
|
+
{ id: 2, row: 0, col: 1 }
|
|
3487
|
+
]
|
|
3488
|
+
}, [
|
|
3489
|
+
// clipImage 变换链:angle20 + flipX + 用户缩放 1.25×cover + clipX/Y 偏移
|
|
3490
|
+
mask('pz2_m0', -77.5, 0, 145, 140, 18, clip(rotateSrc, 200, 200, 145, 140, { angle: 20, flipX: true, scaleX: Math.max(145 / 200, 140 / 200) * 1.25, scaleY: Math.max(145 / 200, 140 / 200) * 1.25 }), { clipX: 12, clipY: -8 }),
|
|
3491
|
+
mask('pz2_m1', 77.5, 0, 145, 140, 18, clip(woodSrc, 512, 512, 145, 140, { angle: -30, clipX: -15, clipY: 10 }))
|
|
3492
|
+
], { layoutWidth: 300, layoutHeight: 140, hGap: 10, vGap: 10, groupPadding: 0, cornerRadius: 18 }),
|
|
3493
|
+
puzzle('pz3', 215, 510, {
|
|
3494
|
+
rows: 2,
|
|
3495
|
+
cols: 1,
|
|
3496
|
+
pieces: [
|
|
3497
|
+
{ id: 1, row: 0, col: 0 },
|
|
3498
|
+
{ id: 2, row: 1, col: 0 }
|
|
3499
|
+
]
|
|
3500
|
+
}, [mask('pz3_m0', 0, -67.5, 260, 125, 14, clip(shapeSrc, 198, 200, 260, 125)), mask('pz3_m1', 0, 67.5, 260, 125, 14, clip(honeySrc, 179, 132, 260, 125))], { layoutWidth: 260, layoutHeight: 260, hGap: 10, vGap: 10, groupPadding: 0, cornerRadius: 14 }, { angle: 25, scaleX: 1.15, scaleY: 1.15, opacity: 0.85 }),
|
|
3501
|
+
puzzle('pz4', 600, 520, {
|
|
3502
|
+
rows: 1,
|
|
3503
|
+
cols: 3,
|
|
3504
|
+
pieces: [
|
|
3505
|
+
{ id: 1, row: 0, col: 0 },
|
|
3506
|
+
{ id: 2, row: 0, col: 1 },
|
|
3507
|
+
{ id: 3, row: 0, col: 2 }
|
|
3508
|
+
]
|
|
3509
|
+
},
|
|
3510
|
+
// authored 几何/clip 比例故意偏离——自动收拢 cols=2 后两侧重排须覆盖为 cell 144/step 156
|
|
3511
|
+
[mask('pz4_m0', -50, 20, 60, 40, 8, clip(rotateSrc, 200, 200, 60, 40, { scaleX: 0.5, scaleY: 0.5 })), mask('pz4_m1', 90, -10, 70, 50, 8, clip(floralSrc, 150, 124, 70, 50))], { layoutWidth: 300, layoutHeight: 150, hGap: 12, vGap: 12, groupPadding: 0, cornerRadius: 8 }),
|
|
3512
|
+
// 顶层独立 Mask(非拼图内):clipImage angle10 + flipY + cover
|
|
3513
|
+
mask('pz5', 990, 520, 200, 150, 20, clip(floralSrc, 150, 124, 200, 150, { angle: 10, flipY: true })),
|
|
3514
|
+
// B1(余) Mask PSD effects:pz6 = 合成层(clipImage)+ 投影/纯色填充/双层描边
|
|
3515
|
+
// 全链(drawShadows 垫底 → 合成 → drawFills → drawStrokes 倒序外圈在底)
|
|
3516
|
+
{
|
|
3517
|
+
...mask('pz6', 820, 360, 200, 140, 16, clip(woodSrc, 512, 512, 200, 140)),
|
|
3518
|
+
effects: {
|
|
3519
|
+
dropShadow: [{ enabled: true, showInDialog: true, fill: 'rgba(40,40,60,0.45)', blur: 10, offsetX: 8, offsetY: 8 }],
|
|
3520
|
+
solidFill: [{ enabled: true, showInDialog: true, fillType: 0, fill: 'rgba(70,130,180,0.55)' }],
|
|
3521
|
+
stroke: [
|
|
3522
|
+
{ enabled: true, showInDialog: true, fill: 'rgba(200,60,60,1)', strokeWidth: 5, strokeAlignment: 'outside' },
|
|
3523
|
+
{ enabled: true, showInDialog: true, fill: 'rgba(60,60,200,1)', strokeWidth: 12, strokeAlignment: 'outside' }
|
|
3524
|
+
]
|
|
3525
|
+
}
|
|
3526
|
+
},
|
|
3527
|
+
// pz7 = 直出形状 + 投影 + center 描边(直出分支的 effects 同链)
|
|
3528
|
+
{
|
|
3529
|
+
...mask('pz7', 1060, 360, 180, 130, 14, null),
|
|
3530
|
+
effects: {
|
|
3531
|
+
dropShadow: [{ enabled: true, showInDialog: true, fill: 'rgba(60,30,30,0.4)', blur: 8, offsetX: -10, offsetY: 6 }],
|
|
3532
|
+
stroke: [{ enabled: true, showInDialog: true, fill: 'rgba(30,120,60,1)', strokeWidth: 6, strokeAlignment: 'center' }]
|
|
3533
|
+
}
|
|
3534
|
+
},
|
|
3535
|
+
// B1(余) 收尾片:Mask clipImage 滤镜——pz8 fabric 口径 Grayscale、pz8b PSD
|
|
3536
|
+
// 口径 Brightness(psd:1 量纲 /100)——双序列化形态覆盖;滤镜先跑全图、
|
|
3537
|
+
// 蒙版合成后置(与 fabric「clipImage._element 滤镜输出 → ensureClipImageCache」同链)。
|
|
3538
|
+
// clip 图取不透明素材(rotate.png 透明带宽——像素探针落点不稳)
|
|
3539
|
+
maskClipWithFilters('pz8', 820, 530, 200, 140, 16, clip(woodSrc, 512, 512, 200, 140), [{ type: 'Grayscale' }]),
|
|
3540
|
+
maskClipWithFilters('pz8b', 1060, 530, 180, 130, 12, clip(honeySrc, 179, 132, 180, 130), [{ type: 'Brightness', psd: 1, brightness: 30 }])
|
|
3541
|
+
];
|
|
3542
|
+
};
|
|
3543
|
+
/**
|
|
3544
|
+
* 吸附场景(P5-2):手动验证拖拽磁吸与辅助线(snapGuide 已默认开;关=?snapGuide=0)。
|
|
3545
|
+
* 布局设计:上排 A/B 留出 120px 水平间距(拖 T 进中间触发 center/side 间距吸附);
|
|
3546
|
+
* A 自身提供点对齐(左缘/中心/顶缘);旋转/文本/组参考覆盖常见候选族;
|
|
3547
|
+
* T 为拖拽目标(拖到 A 左侧 ±8px 内磁吸贴齐、拖进 A-B 中间触发等距)。
|
|
3548
|
+
*/
|
|
3549
|
+
/**
|
|
3550
|
+
* 蒙版裁剪会话场景(B3 余量):顶层 Mask ×2(会话进入条件 = 顶层 + 静态 clip)。
|
|
3551
|
+
* - mcp0 基线:240×180 圆角 12,clip=wood 512×512 显式 scale 0.7(源 358×358 →
|
|
3552
|
+
* crop 活动域 [0,118]×[0,89]——coverage 钳制两侧都可达,e2e 两向拖拽断言用)
|
|
3553
|
+
* - mcp1 变换链:200×150 angle 12 + mask scale 1.15,clip=rotate 200×200
|
|
3554
|
+
* 显式 scale 1.4(源 280×280 → crop 域 [0,80]×[0,65])——旋转/缩放下
|
|
3555
|
+
* 拖图方向反解与手柄锚定的回归面
|
|
3556
|
+
* clip 显式 scale 覆盖 cover 缺省(makePuzzleScene 的 clip 同款 extra 机制)。
|
|
3557
|
+
*/
|
|
3558
|
+
export const makeMaskCropScene = () => {
|
|
3559
|
+
const shapeSrc = assetUrl('../../assets/images/nasty_fabric.png'); // 198×200(不透明)
|
|
3560
|
+
const woodSrc = assetUrl('../../assets/images/retina_wood.png'); // 512×512
|
|
3561
|
+
const rotateSrc = assetUrl('../../assets/images/rotate.png'); // 200×200
|
|
3562
|
+
const clip = (src, natW, natH, w, h, extra = {}) => ({
|
|
3563
|
+
type: 'image',
|
|
3564
|
+
src,
|
|
3565
|
+
left: 0,
|
|
3566
|
+
top: 0,
|
|
3567
|
+
width: natW,
|
|
3568
|
+
height: natH,
|
|
3569
|
+
scaleX: Math.max(w / natW, h / natH),
|
|
3570
|
+
scaleY: Math.max(w / natW, h / natH),
|
|
3571
|
+
angle: 0,
|
|
3572
|
+
flipX: false,
|
|
3573
|
+
flipY: false,
|
|
3574
|
+
opacity: 1,
|
|
3575
|
+
originX: 'left',
|
|
3576
|
+
originY: 'top',
|
|
3577
|
+
crossOrigin: 'anonymous',
|
|
3578
|
+
cropX: 0,
|
|
3579
|
+
cropY: 0,
|
|
3580
|
+
strokeWidth: 0,
|
|
3581
|
+
visible: true,
|
|
3582
|
+
...extra
|
|
3583
|
+
});
|
|
3584
|
+
const mask = (id, left, top, w, h, cornerRadius, clipImage, extra = {}) => ({
|
|
3585
|
+
type: 'Mask',
|
|
3586
|
+
id,
|
|
3587
|
+
left,
|
|
3588
|
+
top,
|
|
3589
|
+
width: w,
|
|
3590
|
+
height: h,
|
|
3591
|
+
originX: 'center',
|
|
3592
|
+
originY: 'center',
|
|
3593
|
+
scaleX: 1,
|
|
3594
|
+
scaleY: 1,
|
|
3595
|
+
angle: 0,
|
|
3596
|
+
flipX: false,
|
|
3597
|
+
flipY: false,
|
|
3598
|
+
opacity: 1,
|
|
3599
|
+
strokeWidth: 0,
|
|
3600
|
+
visible: true,
|
|
3601
|
+
src: shapeSrc,
|
|
3602
|
+
crossOrigin: 'anonymous',
|
|
3603
|
+
cropX: 0,
|
|
3604
|
+
cropY: 0,
|
|
3605
|
+
cornerRadius,
|
|
3606
|
+
innerRadius: 12,
|
|
3607
|
+
outerRadius: 0,
|
|
3608
|
+
seamlessMode: false,
|
|
3609
|
+
seamlessNess: 0,
|
|
3610
|
+
clipX: 0,
|
|
3611
|
+
clipY: 0,
|
|
3612
|
+
clipImage,
|
|
3613
|
+
...extra
|
|
3614
|
+
});
|
|
3615
|
+
return [
|
|
3616
|
+
mask('mcp0', 170, 110, 240, 180, 12, clip(woodSrc, 512, 512, 240, 180, { scaleX: 0.7, scaleY: 0.7 })),
|
|
3617
|
+
mask('mcp1', 600, 150, 200, 150, 0, clip(rotateSrc, 200, 200, 200, 150, { scaleX: 1.4, scaleY: 1.4 }), { angle: 12, scaleX: 1.15, scaleY: 1.15 })
|
|
3618
|
+
];
|
|
3619
|
+
};
|
|
3620
|
+
/**
|
|
3621
|
+
* 动态 clipImage 蒙版场景(B1(余) 收尾片·贰):视频/GIF 填充蒙版——
|
|
3622
|
+
* renderClipImageDirectly 语义的引擎面。gifSrc/videoSrc 由调用方生成
|
|
3623
|
+
* (dev 页 makeGifBlobUrl 五帧纯色 64×64@100ms / makeVideoBlobUrl 色相循环),
|
|
3624
|
+
* 帧内容确定可做像素探针(帧色切换 = 动画真实推进;角外 = 圆角+形状裁剪)。
|
|
3625
|
+
* gif 帧 100ms/帧 × 5 = 500ms 循环;视频 320×568 色相 4s/圈。
|
|
3626
|
+
*/
|
|
3627
|
+
export const makeDynamicMaskScene = (gifSrc, videoSrc) => {
|
|
3628
|
+
const shapeSrc = assetUrl('../../assets/images/nasty_fabric.png'); // 198×200(不透明——形状恒等,圆角是唯一裁剪特征)
|
|
3629
|
+
const mask = (id, left, top, w, h, cornerRadius, clip) => ({
|
|
3630
|
+
type: 'Mask',
|
|
3631
|
+
id,
|
|
3632
|
+
left,
|
|
3633
|
+
top,
|
|
3634
|
+
width: w,
|
|
3635
|
+
height: h,
|
|
3636
|
+
originX: 'center',
|
|
3637
|
+
originY: 'center',
|
|
3638
|
+
scaleX: 1,
|
|
3639
|
+
scaleY: 1,
|
|
3640
|
+
angle: 0,
|
|
3641
|
+
flipX: false,
|
|
3642
|
+
flipY: false,
|
|
3643
|
+
opacity: 1,
|
|
3644
|
+
strokeWidth: 0,
|
|
3645
|
+
visible: true,
|
|
3646
|
+
src: shapeSrc,
|
|
3647
|
+
crossOrigin: 'anonymous',
|
|
3648
|
+
cropX: 0,
|
|
3649
|
+
cropY: 0,
|
|
3650
|
+
cornerRadius,
|
|
3651
|
+
clipX: 0,
|
|
3652
|
+
clipY: 0,
|
|
3653
|
+
// src/type 由各块的 clip 显式给(基座不含——首版基座写死 src: gifSrc,
|
|
3654
|
+
// 视频块漏覆写 src,GIF 的 blob 被当视频加载恒 code 4,排障绕了大弯)
|
|
3655
|
+
clipImage: { left: 0, top: 0, originX: 'left', originY: 'top', crossOrigin: 'anonymous', ...clip }
|
|
3656
|
+
});
|
|
3657
|
+
// GIF 蒙版:240×180、cover(64→240/180 取 3.75)、圆角 28——帧色逐帧切换
|
|
3658
|
+
// 视频蒙版:260×200、cover(CDN 368×244 → max(260/368, 200/244)=0.8197)、loop
|
|
3659
|
+
return [
|
|
3660
|
+
mask('dm-gif', 200, 200, 240, 180, 28, { type: 'GIF', src: gifSrc, width: 64, height: 64, scaleX: 3.75, scaleY: 3.75 }),
|
|
3661
|
+
mask('dm-video', 620, 200, 260, 200, 28, { type: 'Video', src: videoSrc, width: 368, height: 244, scaleX: 0.8197, scaleY: 0.8197, loop: true })
|
|
3662
|
+
];
|
|
3663
|
+
};
|
|
3664
|
+
export const makeSnapScene = () => {
|
|
3665
|
+
const node = (over) => ({ scaleX: 1, scaleY: 1, angle: 0, originX: 'left', originY: 'top', opacity: 1, strokeWidth: 0, visible: true, ...over });
|
|
3666
|
+
return [
|
|
3667
|
+
node({ type: 'rect', id: 'snA', left: 100, top: 100, width: 120, height: 80, fill: 'rgba(154,165,177,0.95)' }),
|
|
3668
|
+
node({ type: 'rect', id: 'snB', left: 340, top: 100, width: 120, height: 80, fill: 'rgba(154,165,177,0.95)' }),
|
|
3669
|
+
node({ type: 'rect', id: 'snRot', left: 560, top: 300, width: 140, height: 90, angle: 30, fill: 'rgba(240,180,90,0.95)' }),
|
|
3670
|
+
node({ type: 'textbox', id: 'snTxt', left: 160, top: 320, width: 240, text: '吸附参考文本', fontFamily: 'sans-serif', fontSize: 36, fill: 'rgba(50,50,80,0.95)', lineHeight: 1.16 }),
|
|
3671
|
+
{
|
|
3672
|
+
...node({ type: 'Group', id: 'snGrp', left: 480, top: 480, width: 200, height: 120, angle: -8 }),
|
|
3673
|
+
objects: [
|
|
3674
|
+
node({ type: 'rect', left: -100, top: -60, width: 100, height: 120, fill: 'rgba(110,170,210,0.95)' }),
|
|
3675
|
+
node({ type: 'rect', left: 0, top: -60, width: 100, height: 120, fill: 'rgba(210,140,190,0.95)' })
|
|
3676
|
+
]
|
|
3677
|
+
},
|
|
3678
|
+
node({ type: 'rect', id: 'snT', left: 700, top: 100, width: 100, height: 60, fill: 'rgba(47,111,237,0.95)' })
|
|
3679
|
+
];
|
|
3680
|
+
};
|
|
3681
|
+
/**
|
|
3682
|
+
* 批次 77:列表前缀(paragraph)parity 种子。
|
|
3683
|
+
*
|
|
3684
|
+
* 覆盖面:有序多行逐行编号 / 无序 content 符号 / 窄盒自动换行视觉行续号 /
|
|
3685
|
+
* 行首字符样式覆写(前缀声明同款度量)/ center 对齐整体收边 / 装饰线与盒平移
|
|
3686
|
+
* 共存 / 竖排 left 对齐(列首前缀,不旋转)/ 无 paragraph 孪生锚(回归——
|
|
3687
|
+
* 纯文本零平移)。fabricReference 对 paragraph 键路由应用 Textbox(本批修复)。
|
|
3688
|
+
*
|
|
3689
|
+
* variant='ordered-only' 只返回 pp0(有序三行):全帧 parity 的失配底有
|
|
3690
|
+
* ~4% 的字形边缘 AA 噪声(与「引擎丢前缀」的 4.6~8.3% 重叠,批次 61 假绿
|
|
3691
|
+
* 同款坑),单对象口径绿 0.83% 才有判别力——e2e 双门:全帧 ≤5% 门(回归
|
|
3692
|
+
* 面)+ ordered-only ≤1.5% 门(前缀保真判别器)。
|
|
3693
|
+
*/
|
|
3694
|
+
export const makeTextParagraphScene = (variant) => {
|
|
3695
|
+
const base = (over) => ({
|
|
3696
|
+
type: 'textbox',
|
|
3697
|
+
scaleX: 1,
|
|
3698
|
+
scaleY: 1,
|
|
3699
|
+
angle: 0,
|
|
3700
|
+
originX: 'left',
|
|
3701
|
+
originY: 'top',
|
|
3702
|
+
opacity: 1,
|
|
3703
|
+
strokeWidth: 0,
|
|
3704
|
+
visible: true,
|
|
3705
|
+
fontFamily: 'sans-serif',
|
|
3706
|
+
lineHeight: 1.16,
|
|
3707
|
+
textAlign: 'left',
|
|
3708
|
+
fill: 'rgba(26,26,26,0.95)',
|
|
3709
|
+
...over
|
|
3710
|
+
});
|
|
3711
|
+
const ordered = { id: 0, type: 0, content: '1' };
|
|
3712
|
+
const pp0 = () =>
|
|
3713
|
+
// 有序三行(硬换行):前缀 1/2/3 + 三行全部右移
|
|
3714
|
+
({ ...base({ left: 80, top: 60, width: 520, text: '一一列表条目\n二二列表条目\n三三列表条目', fontSize: 44, paragraph: ordered }), id: 'pp0' });
|
|
3715
|
+
if (variant === 'ordered-only')
|
|
3716
|
+
return [
|
|
3717
|
+
pp0(),
|
|
3718
|
+
// 宽 content 前缀('●●●'≈3em 位移):丢前缀时整行大位移——判别信号放大器
|
|
3719
|
+
//(数字前缀 ~0.5em 位移的失配只比 AA 底噪高一倍,门不稳)
|
|
3720
|
+
{ ...base({ left: 820, top: 60, width: 560, text: '宽前缀位移条目\n第二行宽前缀\n第三行宽前缀\n第四行宽前缀', fontSize: 44, paragraph: { id: 1, type: 0, content: '●●●●' } }), id: 'pp1w' }
|
|
3721
|
+
];
|
|
3722
|
+
return [
|
|
3723
|
+
pp0(),
|
|
3724
|
+
// 无序 content 符号前缀
|
|
3725
|
+
{ ...base({ left: 820, top: 60, width: 560, text: '无序符号条目', fontSize: 44, paragraph: { id: 1, type: 0, content: '·' } }), id: 'pp1' },
|
|
3726
|
+
// 窄盒自动换行:视觉行续号(wrap 不吃前缀、measure 后编号递增)
|
|
3727
|
+
{ ...base({ left: 80, top: 250, width: 430, text: '自动换行条目内容较长跨行后视觉行编号继续递增', fontSize: 40, paragraph: ordered }), id: 'pp2' },
|
|
3728
|
+
// 行首字符样式覆写(fontSize 60 + 填充色):前缀用同款声明度量与绘制
|
|
3729
|
+
{
|
|
3730
|
+
...base({
|
|
3731
|
+
left: 820,
|
|
3732
|
+
top: 250,
|
|
3733
|
+
width: 560,
|
|
3734
|
+
text: '行首字符样式前缀',
|
|
3735
|
+
fontSize: 40,
|
|
3736
|
+
paragraph: ordered,
|
|
3737
|
+
styles: { 0: { 0: { fontSize: 60, fill: '#F96023' } } }
|
|
3738
|
+
}),
|
|
3739
|
+
id: 'pp3'
|
|
3740
|
+
},
|
|
3741
|
+
// center 对齐:前缀+文字整体收边(getLineWidth 含前缀宽)
|
|
3742
|
+
{ ...base({ left: 80, top: 460, width: 520, text: '居中对齐整体收边\n第二行居中收边', fontSize: 40, textAlign: 'center', paragraph: ordered }), id: 'pp4' },
|
|
3743
|
+
// 装饰线与盒平移共存(underline run 从平移后的盒起跑,前缀区不画线)
|
|
3744
|
+
{ ...base({ left: 820, top: 460, width: 560, text: '装饰线与前缀共存', fontSize: 40, underline: true, paragraph: ordered }), id: 'pp5' },
|
|
3745
|
+
// 竖排 left 对齐:列首前缀不旋转(fabric 前缀块无竖排分支)
|
|
3746
|
+
{ ...base({ left: 80, top: 640, width: 300, text: '竖排\n编号条目', fontSize: 40, vertical: true, paragraph: ordered }), id: 'pp6' },
|
|
3747
|
+
// 无 paragraph 孪生锚:纯文本零平移(回归锚)
|
|
3748
|
+
{ ...base({ left: 820, top: 640, width: 560, text: '无前缀孪生锚文本', fontSize: 44 }), id: 'pp7' }
|
|
3749
|
+
];
|
|
3750
|
+
};
|
|
3751
|
+
/**
|
|
3752
|
+
* 圆角场景(批次 98:rect rx/ry + 图片 rx/ry 承接)。
|
|
3753
|
+
* 五形态一对照:
|
|
3754
|
+
* - rr-fr:FabricRect 视觉 radius 源(render 每帧 rx=(1/sx)·radius 反算——引擎
|
|
3755
|
+
* 同式),红 #ef4444
|
|
3756
|
+
* - rr-rect:轻量 Rect 直读 rx/ry(30/14 椭圆角——SDF 椭圆零值面),蓝 #3b82f6
|
|
3757
|
+
* - rr-img:图片族 rx(uniform r = min(max(rx,ry),w/2,h/2),应用
|
|
3758
|
+
* getRoundedClipRadius 同式),本地木纹素材(离线确定性)
|
|
3759
|
+
* - rr-clip:rect 宿主 + 圆角 rect clipPath(居中全幅窗——CPU kappa 剪影/
|
|
3760
|
+
* GPU 圆角网格两路;批次 99 修复 maskInv 列主序打包错+反馈环后验收面)
|
|
3761
|
+
* - rr-poly:polygon(mesh) 宿主 clip(批次 99 反馈环回归锚——修复前 mesh 进
|
|
3762
|
+
* FBO 即 INVALID_OPERATION 全灭)
|
|
3763
|
+
* - rr-scale:FabricRect radius + 非均匀 scale(视觉圆角不随 scale 变椭圆)
|
|
3764
|
+
* - rr-sharp:直角对照(探针自校准——角点应=填充色而非底板色)
|
|
3765
|
+
* 板底 #eef1f4(角落探针=板色即「圆角裁掉」,=填充色即红态直角形态)。
|
|
3766
|
+
*/
|
|
3767
|
+
export const makeRoundedCornerScene = () => {
|
|
3768
|
+
const base = (over) => ({ scaleX: 1, scaleY: 1, angle: 0, originX: 'left', originY: 'top', opacity: 1, strokeWidth: 0, visible: true, ...over });
|
|
3769
|
+
return [
|
|
3770
|
+
base({ type: 'rect', id: 'WorkSpaceDrawType', left: 0, top: 0, width: 2000, height: 1400, fill: '#eef1f4' }),
|
|
3771
|
+
base({ type: 'FabricRect', id: 'rr-fr', left: 60, top: 80, width: 220, height: 160, radius: 40, fill: '#ef4444' }),
|
|
3772
|
+
base({ type: 'Rect', id: 'rr-rect', left: 340, top: 80, width: 220, height: 160, rx: 30, ry: 14, fill: '#3b82f6' }),
|
|
3773
|
+
base({ type: 'image', id: 'rr-img', left: 620, top: 80, width: 220, height: 160, rx: 36, src: assetUrl('../../assets/images/retina_wood.png') }),
|
|
3774
|
+
{
|
|
3775
|
+
...base({ type: 'rect', id: 'rr-clip', left: 60, top: 320, width: 220, height: 160, fill: '#eab308' }),
|
|
3776
|
+
// fabric 相对 clipPath 语义:left/top 从宿主中心度量、锚 clip 原点(含
|
|
3777
|
+
// origin 折算)——居中全幅窗 = (-w/2, -h/2)(批次 99 勘误:初版 0/0 把窗
|
|
3778
|
+
// 摆到宿主右下角,恰成「宿主不可见」假象)
|
|
3779
|
+
clipPath: { type: 'rect', left: -110, top: -80, width: 220, height: 160, rx: 40 }
|
|
3780
|
+
},
|
|
3781
|
+
base({ type: 'FabricRect', id: 'rr-scale', left: 340, top: 320, width: 220, height: 160, radius: 40, scaleX: 1.5, scaleY: 1, fill: '#8b5cf6' }),
|
|
3782
|
+
{
|
|
3783
|
+
// shape(mesh) 宿主 clip 回归锚(批次 99:反馈环修复的观测面——修复前
|
|
3784
|
+
// mesh 进 FBO 即 INVALID_OPERATION 全灭)
|
|
3785
|
+
...base({
|
|
3786
|
+
type: 'polygon',
|
|
3787
|
+
id: 'rr-poly',
|
|
3788
|
+
left: 700,
|
|
3789
|
+
top: 330,
|
|
3790
|
+
opacity: 0.7,
|
|
3791
|
+
fill: 'rgba(40,40,80,0.9)',
|
|
3792
|
+
points: [
|
|
3793
|
+
{ x: 0, y: 0 },
|
|
3794
|
+
{ x: 120, y: 12 },
|
|
3795
|
+
{ x: 100, y: 80 },
|
|
3796
|
+
{ x: 12, y: 74 }
|
|
3797
|
+
]
|
|
3798
|
+
}),
|
|
3799
|
+
clipPath: { type: 'rect', left: 10, top: 10, width: 60, height: 40 }
|
|
3800
|
+
},
|
|
3801
|
+
base({ type: 'rect', id: 'rr-sharp', left: 620, top: 320, width: 220, height: 160, fill: '#22c55e' })
|
|
3802
|
+
];
|
|
3803
|
+
};
|