feat(image-vectorize): v0.3.0 按孤岛拆分元素(Figma 里可单独选中)
用户需求:「现在元素是一个整体,我需要有个勾选按单个元素分解,孤岛是分离的, 输出时能选分类的还是整体的」。 potrace 出厂把所有轮廓塞进一个 <path>(800×800 菜单图 1 个 path / 129 个子路径, 靠 fill-rule=evenodd 互相挖洞),所以粘到 Figma 只是一个整体。 新增 plugin/islands.js: - 解析 d 为子路径(只认 potrace 输出的 M/C/L/Z,全绝对坐标) - 按几何包含建父子关系(bbox + 射线法点在多边形内),深度偶数 = 外壳、奇数 = 孔洞 - 每个外壳 + 它的孔洞合成一个 path(孔洞必须同 path,evenodd 才挖得出洞), 不同组并列输出、不包 <g>;元素按面积降序(大块在下,遮挡关系同原图) - 为什么不能按 M 直接切:切了孔洞就变实心("O" 中间被填满) UI:输出区加「按孤岛拆分」开关(默认开,ctx.settings 记忆),统计改显示元素数, 合并时标注「N 孤岛合并」;复制反馈说明粘过去是 N 个独立元素还是 1 个整体。 验证:harness 47 项(新增 8 项:多 path / 无 g / 统计一致 / 取消勾选合回 1 个 / 坐标集合完全一致 / 渲染差异 0.003%)、真站 e2e 18 项全绿。
This commit is contained in:
1 parent
d151de74a1
commit
866c420c5c
11 files changed
+1234
-39
No files matched your search
@@ -347,6 +347,66 @@
|
||||
.vz-color::-webkit-color-swatch { border: none; border-radius: 4px; }
|
||||
.vz-color:disabled { cursor: default; }
|
||||
|
||||
/* 勾选开关(按孤岛拆分):原生 checkbox 在深色面板里太小、且难以点中。
|
||||
用 label 包一层,点整块都能切换;focus-visible 保留键盘可达的焦点环。 */
|
||||
.vz-row-switch {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
.vz-row-text {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 3px;
|
||||
min-width: 0;
|
||||
font-size: 12px;
|
||||
color: #b6b6c8;
|
||||
}
|
||||
.vz-row-text span {
|
||||
color: #6f6f85;
|
||||
font-size: 10.5px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.vz-switch {
|
||||
position: relative;
|
||||
flex: 0 0 auto;
|
||||
width: 34px;
|
||||
height: 20px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.vz-switch input {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
opacity: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
.vz-switch i {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
border-radius: 999px;
|
||||
background: #3a3a4a;
|
||||
transition: background 0.15s ease;
|
||||
pointer-events: none;
|
||||
}
|
||||
.vz-switch i::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 2px;
|
||||
left: 2px;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
border-radius: 50%;
|
||||
background: #b9b9c9;
|
||||
transition: transform 0.15s ease, background 0.15s ease;
|
||||
}
|
||||
.vz-switch input:checked + i { background: #2f7d5b; }
|
||||
.vz-switch input:checked + i::after { transform: translateX(14px); background: #ffffff; }
|
||||
.vz-switch input:focus-visible + i { box-shadow: 0 0 0 2px rgba(90, 200, 160, 0.45); }
|
||||
|
||||
|
||||
.vz-adv { margin-top: 10px; }
|
||||
.vz-adv[hidden] { display: none; }
|
||||
|
||||
Reference in new issue
Block a user