@yft-design/engine 0.0.8 → 0.0.10

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.
@@ -8,8 +8,12 @@
8
8
  * aRadius=(halfW, −code)——码取负与填充圆角实例的 ry≥0 判别),批合并/z 序/
9
9
  * 增量上传/保留帧重放零改动。
10
10
  *
11
- * 回落烘焙门(返回 null 走 strokePainter 原链,stale 协议不动):dash 全族、
12
- * alignment inside/outside(应用的 destination-out 残留 parity 单独立项)、
11
+ * 回落烘焙门(返回 null 走 strokePainter 原链,stale 协议不动):dash 收窄域外
12
+ * (>2 段 pattern 着色器无法动态循环;round/square 帽 canvas 逐 dash 帽形与门
13
+ * 硬切有差;strokeUniform 的 dash 单位=pen 空间=场景单位,本地弧长门需逐边轴向
14
+ * 换算无槽位;椭圆/圆角 rect 弧长无初等解析式——方向三第一刀,
15
+ * docs/2026-10-13_webgl2-sdf-dash-stroke-blueprint.md §3)、alignment
16
+ * inside/outside(应用的 destination-out 残留 parity 单独立项)、
13
17
  * path/polygon/polyline/triangle/arrow/Dimension/referenceline 族、直角 rect
14
18
  * 的 join≠miter 或 miterLimit<1.5(bevel/round 角语义 Chebyshev 盒不承接)、
15
19
  * 零长线段、非有限端点/尺寸。
@@ -26,6 +30,11 @@ export interface StrokeSdfParams {
26
30
  /** quad 尺寸(对象 dims + 2×margin;实例矩阵=对象矩阵,vLocal 含 margin 求值区) */
27
31
  quadW: number;
28
32
  quadH: number;
33
+ /** aDash 槽(方向三第一刀):本地单位 [on, cycle, phase]——null=非 dash 实例
34
+ * (槽位写 0,着色器跳过门)。phase=decl.dashOffset 原值(canvas
35
+ * lineDashOffset 语义:mod(s+phase, cycle)——正 offset 图案向起点回退,
36
+ * 符号由 strokeSdfDash.spec 镜像对拍 + e2e 像素 A/B 实证锁定) */
37
+ dash: readonly [number, number, number] | null;
29
38
  }
30
39
  /**
31
40
  * eligibility 与打包:不合形态返回 null(调用方回落烘焙链)。
@@ -1,3 +1,4 @@
1
+ import { isStrokeSdfDashEnabled } from '../engineFlag';
1
2
  import { rectCornerRadii } from '../core/roundedRect';
2
3
  /** 描边码位段:kind(0-2) | cap(3-5) | penUniform(6)——与 strokeCoverage 解码一致 */
3
4
  const STROKE_KIND_RECT = 1;
@@ -12,8 +13,24 @@ const MITER_SAFE_LIMIT = 1.5;
12
13
  * 换入的导出 vpt 自动跟随)——uniform 笔宽与烘焙分辨率换算共用同一 k。
13
14
  */
14
15
  export const strokeSdfParams = (node, decl, zoom, dpr) => {
15
- if (decl.dashArray)
16
- return null;
16
+ // dash 放行(方向三第一刀):两段 pattern 的 butt 帽非 uniform dash 走解析式
17
+ // 弧长门;收窄域外全族回落(枚举见文件头注)。奇数段按 canvas 语义补 [a,a]
18
+ // (setLineDash 对奇数列表复制翻倍,烘焙链同语义)
19
+ let dash = null;
20
+ if (decl.dashArray) {
21
+ if (!isStrokeSdfDashEnabled())
22
+ return null;
23
+ if (decl.dashArray.length > 2)
24
+ return null;
25
+ if (decl.lineCap !== 'butt')
26
+ return null;
27
+ if (decl.uniform)
28
+ return null;
29
+ const on = decl.dashArray[0];
30
+ const off = decl.dashArray.length > 1 ? decl.dashArray[1] : on;
31
+ if (on + off > 0)
32
+ dash = [on, on + off, decl.dashOffset];
33
+ }
17
34
  if (decl.alignment !== 'center')
18
35
  return null;
19
36
  const raw = node.raw;
@@ -37,6 +54,9 @@ export const strokeSdfParams = (node, decl, zoom, dpr) => {
37
54
  // miterLimit 过低(bevel 截断)不承接。圆角路径角区平滑,join 无语义不设门
38
55
  if (rx < 1e-4 && ry < 1e-4 && (decl.lineJoin !== 'miter' || decl.miterLimit < MITER_SAFE_LIMIT))
39
56
  return null;
57
+ // 圆角 rect + dash:弧长沿圆角弧无四段直边解析式(蓝图独立下刀)——回落
58
+ if (dash && (rx >= 1e-4 || ry >= 1e-4))
59
+ return null;
40
60
  shape = [rx, ry, dims.x / 2, dims.y / 2];
41
61
  }
42
62
  else if (type === 'line') {
@@ -51,6 +71,9 @@ export const strokeSdfParams = (node, decl, zoom, dpr) => {
51
71
  shape = [x1, y1, x2, y2];
52
72
  }
53
73
  else if (type === 'ellipse' || type === 'circle') {
74
+ // 椭圆 dash:弧长无初等解析式(需椭圆积分近似)——回落(蓝图独立下刀)
75
+ if (dash)
76
+ return null;
54
77
  shape = [0, 0, dims.x / 2, dims.y / 2];
55
78
  }
56
79
  else {
@@ -70,5 +93,5 @@ export const strokeSdfParams = (node, decl, zoom, dpr) => {
70
93
  const quadH = dims.y + 2 * margin;
71
94
  if (!Number.isFinite(quadW) || !Number.isFinite(quadH))
72
95
  return null;
73
- return { halfW, code: -code, shape, quadW, quadH };
96
+ return { halfW, code: -code, shape, quadW, quadH, dash };
74
97
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yft-design/engine",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "description": "yft-design 的 WebGL2 画布引擎:接受 fabric toObject 格式 JSON,输出 GL 画布 / 位图(任意倍率 FBO 读回)/ SVG(纯数据序列化器)",
5
5
  "repository": {
6
6
  "type": "git",