@jetprint/editor-sdk 1.2.5 → 1.2.7
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/dist/components/Editor/headless/composeProductionImage.d.ts +2 -1
- package/dist/components/Editor/headless/entry.d.ts +5 -2
- package/dist/components/Editor/headless/productionRender.d.ts +35 -0
- package/dist/components/Editor/utils/embroideryQuantize.d.ts +47 -0
- package/dist/components/Editor/utils/embroideryStitchPaths.d.ts +41 -0
- package/dist/editor-sdk.es.js +12426 -12391
- package/dist/style.css +1 -1
- package/dist/utils/protection/encryptedModules.generated.d.ts +1 -1
- package/package.json +1 -1
|
@@ -30,5 +30,6 @@ export declare function getSplitChildrenWithBounds(layerList: any[], layerName?:
|
|
|
30
30
|
/**
|
|
31
31
|
* @param fabricScreenshotList 每分片印刷位图({id,name,blob})
|
|
32
32
|
* @param productJson 生产图布局:{ canvasWidth, canvasHeight?, layerList(含 split 分组 bounds) }
|
|
33
|
+
* @param typeModel 设计模式:'pillow3d' 时每分片沿轮廓描 5px 红边(异形抱枕裁切引导线)
|
|
33
34
|
*/
|
|
34
|
-
export declare function composeProductionImage(fabricScreenshotList: FabricScreenshotItem[], productJson: any, format?: 'png' | 'jpeg'): Promise<ComposeResult>;
|
|
35
|
+
export declare function composeProductionImage(fabricScreenshotList: FabricScreenshotItem[], productJson: any, format?: 'png' | 'jpeg', typeModel?: string): Promise<ComposeResult>;
|
|
@@ -8,10 +8,13 @@
|
|
|
8
8
|
* 是 @jetprint/editor-sdk 包的一部分(随 SDK 版本同步),Go 侧 `npm i @jetprint/editor-sdk` 后 go:embed 此文件即可。
|
|
9
9
|
*/
|
|
10
10
|
import { generateProductionImage, type GenerateProductionImageInput } from './productionRender';
|
|
11
|
+
import { generateEmbroideryStitches, type GenerateEmbroideryStitchesInput, type EmbroideryStitchResult } from './productionRender';
|
|
11
12
|
declare global {
|
|
12
13
|
interface Window {
|
|
13
14
|
generateProductionImage?: (input: GenerateProductionImageInput) => Promise<Blob>;
|
|
15
|
+
/** 刺绣针迹生成(typeModel=embroidery):返回各色块机器针迹坐标,供 Go 写 DST/PES */
|
|
16
|
+
generateEmbroideryStitches?: (input: GenerateEmbroideryStitchesInput) => Promise<EmbroideryStitchResult>;
|
|
14
17
|
}
|
|
15
18
|
}
|
|
16
|
-
export { generateProductionImage };
|
|
17
|
-
export type { GenerateProductionImageInput };
|
|
19
|
+
export { generateProductionImage, generateEmbroideryStitches };
|
|
20
|
+
export type { GenerateProductionImageInput, GenerateEmbroideryStitchesInput, EmbroideryStitchResult };
|
|
@@ -45,3 +45,38 @@ export declare function resolveSizePieceTasks(fabric: any, mode: 'COMPLETE' | 'S
|
|
|
45
45
|
export declare function renderDiecutPieceBitmaps(tasks: DiecutPieceRenderTask[], fileToken?: string, restoreOnly?: boolean): Promise<FabricScreenshotItem[]>;
|
|
46
46
|
/** 自包含生产图:解析 → 每分片渲染 → productJson 拼贴。 */
|
|
47
47
|
export declare function generateProductionImage(input: GenerateProductionImageInput): Promise<Blob>;
|
|
48
|
+
export interface GenerateEmbroideryStitchesInput {
|
|
49
|
+
/** 保存的画布 JSON(含 typeModel='embroidery' + embroidery 数据):URL 或对象 */
|
|
50
|
+
fabricJson: string | Record<string, unknown>;
|
|
51
|
+
/** 资源访问 token */
|
|
52
|
+
fileToken?: string;
|
|
53
|
+
}
|
|
54
|
+
export interface EmbroideryStitchColor {
|
|
55
|
+
/** 该色块绣线色 */
|
|
56
|
+
color: [number, number, number];
|
|
57
|
+
/** 针法类型 */
|
|
58
|
+
stitchType: string;
|
|
59
|
+
/** 针距(px,工作坐标系) */
|
|
60
|
+
spacing: number;
|
|
61
|
+
/** 角度(度) */
|
|
62
|
+
angle: number;
|
|
63
|
+
/** 有序落针点(工作坐标系,px);空段由后端按距离插跳针 */
|
|
64
|
+
stitches: Array<[number, number]>;
|
|
65
|
+
}
|
|
66
|
+
export interface EmbroideryStitchResult {
|
|
67
|
+
/** 工作坐标系尺寸(px)——与 stitches 坐标同系 */
|
|
68
|
+
width: number;
|
|
69
|
+
height: number;
|
|
70
|
+
/** 原图来源 */
|
|
71
|
+
sourceSrc: string;
|
|
72
|
+
/** 量化参数(后端可据此复现) */
|
|
73
|
+
colorCount: number;
|
|
74
|
+
mergeColorDist: number;
|
|
75
|
+
/** 按缝制/换线顺序的色块针迹 */
|
|
76
|
+
colors: EmbroideryStitchColor[];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* 自包含刺绣针迹:解析 embroidery 数据 → 载原图按 maxWorkSize 量化(与编辑器同算法,确定性) →
|
|
80
|
+
* 按颜色匹配存档色块的针法/针距/角度 → 逐色块生成机器针迹坐标。Go 拿到后写 DST/PES。
|
|
81
|
+
*/
|
|
82
|
+
export declare function generateEmbroideryStitches(input: GenerateEmbroideryStitchesInput): Promise<EmbroideryStitchResult>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 刺绣 · 颜色量化内核(共享模块,无 Worker / 无 DOM 依赖)
|
|
3
|
+
*
|
|
4
|
+
* 从 embroidery.worker.ts 抽出,供:① 编辑器 Worker(分块预览)② 无头渲染 generateEmbroideryStitches(出针迹)共用。
|
|
5
|
+
* 算法确定性(K-Means++ 用黄金比散列初始化,无随机)→ 后端用相同 colorCount/mergeColorDist 重量化得到**完全相同**的色块。
|
|
6
|
+
*
|
|
7
|
+
* 流程:rgb→Lab → K-Means 聚类到 k 个「绣线色」→ 全图归类 → 调色板相近色合并(union-find, Lab ΔE) → 每像素颜色组 id + 组汇总。
|
|
8
|
+
*/
|
|
9
|
+
export type RGB = [number, number, number];
|
|
10
|
+
export type Lab = [number, number, number];
|
|
11
|
+
export interface QuantizeOptions {
|
|
12
|
+
/** 目标色数(K-Means 簇数) */
|
|
13
|
+
k: number;
|
|
14
|
+
/** 面积小于该像素数的颜色组过滤掉,默认按总面积自适应 max(16, total*0.0004) */
|
|
15
|
+
minRegionArea?: number;
|
|
16
|
+
/** alpha 阈值,低于则视为透明不参与,默认 128 */
|
|
17
|
+
alphaThreshold?: number;
|
|
18
|
+
/** 相邻调色板颜色 Lab 色差(ΔE) 小于此则合并为同一组,默认 14 */
|
|
19
|
+
mergeColorDist?: number;
|
|
20
|
+
}
|
|
21
|
+
export interface QuantizeRegion {
|
|
22
|
+
id: number;
|
|
23
|
+
color: RGB;
|
|
24
|
+
area: number;
|
|
25
|
+
bbox: {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
w: number;
|
|
29
|
+
h: number;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export interface QuantizeResult {
|
|
33
|
+
width: number;
|
|
34
|
+
height: number;
|
|
35
|
+
/** 每像素颜色组 id(-1=透明/被过滤);length = width*height */
|
|
36
|
+
regionIds: Int32Array;
|
|
37
|
+
/** 颜色组列表(已过滤极小组),按 id 升序 */
|
|
38
|
+
regions: QuantizeRegion[];
|
|
39
|
+
/** K-Means 色板(k 个绣线色,合并前) */
|
|
40
|
+
palette: RGB[];
|
|
41
|
+
}
|
|
42
|
+
export declare function rgbToLab(r: number, g: number, b: number): Lab;
|
|
43
|
+
/**
|
|
44
|
+
* 对一张 RGBA 图量化分块。输入像素 + 尺寸 + 选项,输出每像素颜色组 id 与组汇总。
|
|
45
|
+
* @param pixels RGBA Uint8ClampedArray(length = width*height*4)
|
|
46
|
+
*/
|
|
47
|
+
export declare function quantizeImage(pixels: Uint8ClampedArray, width: number, height: number, options: QuantizeOptions): QuantizeResult;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 刺绣 · 针迹路径生成(机器针迹,非视觉纹理)
|
|
3
|
+
*
|
|
4
|
+
* 给定量化后的「每像素颜色组 id」(regionIds) + 某颜色组 id + 针法类型 + 针距/角度,
|
|
5
|
+
* 生成该色块的**真实针迹坐标序列**(工作坐标系,单位=像素),供后端写 DST/PES。
|
|
6
|
+
*
|
|
7
|
+
* 与 embroideryStitch.ts(视觉纹理)不同:这里产出的是「每一针的落针点」,机器照此走针。
|
|
8
|
+
* 13 种针法按几何族实现:
|
|
9
|
+
* - 扫描线填充族 fill/tartan/zigzag/estitch/meander → 平行线往返填充
|
|
10
|
+
* - 缎面 satin → 密集扫描线
|
|
11
|
+
* - 走线/轮廓族 running/bean → 外轮廓追踪(bean 三重)
|
|
12
|
+
* - 同心族 contour/circular → 同心内缩轮廓
|
|
13
|
+
* - 图元族 cross/frenchKnot/spiral → 网格图元 / 螺旋
|
|
14
|
+
*/
|
|
15
|
+
import type { StitchKey } from './embroideryStitch';
|
|
16
|
+
export type Point = [number, number];
|
|
17
|
+
export interface RegionStitchOptions {
|
|
18
|
+
regionIds: Int32Array;
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
/** 目标颜色组 id(regionIds 中等于它的像素=该色块) */
|
|
22
|
+
targetId: number;
|
|
23
|
+
/** 色块包围盒(来自量化 regions),缩小遍历范围 */
|
|
24
|
+
bbox: {
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
w: number;
|
|
28
|
+
h: number;
|
|
29
|
+
};
|
|
30
|
+
stitchType: StitchKey;
|
|
31
|
+
/** 针距(px);默认按针法取 STITCH_DEFAULT_SPACING */
|
|
32
|
+
spacing: number;
|
|
33
|
+
/** 角度(度),仅 fill/satin/running/bean 有意义 */
|
|
34
|
+
angle: number;
|
|
35
|
+
/** 单针最大步长(px),长于此在填充线上细分落针。默认 = max(2.5, spacing*0.6) */
|
|
36
|
+
stitchLen?: number;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* 生成某色块的针迹序列(工作坐标系落针点)。空段由后端按距离插跳针。
|
|
40
|
+
*/
|
|
41
|
+
export declare function generateRegionStitches(o: RegionStitchOptions): Point[];
|