2026-07-03 06:25:56 +00:00
|
|
|
---
|
|
|
|
|
id: index
|
|
|
|
|
title: API 参考
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
# 📖 API 参考
|
|
|
|
|
|
|
|
|
|
## 导入
|
|
|
|
|
|
|
|
|
|
```tsx
|
|
|
|
|
import MaskSegmentCanvas, {
|
|
|
|
|
type MaskSegmentCanvasRef,
|
|
|
|
|
type MaskSegmentCanvasProps,
|
|
|
|
|
type MaskSegmentSession,
|
|
|
|
|
type MaskSegmentWatchState,
|
|
|
|
|
type MaskSegmentWatchDetail,
|
|
|
|
|
type BgrColor,
|
|
|
|
|
type MaskSemanticColor,
|
|
|
|
|
type PaintCallbackPayload,
|
|
|
|
|
type PaintedRegionRecord,
|
|
|
|
|
type PipelineConfig,
|
|
|
|
|
type MaskSegmentConfig,
|
|
|
|
|
type PaintConfig,
|
|
|
|
|
type InteractionConfig,
|
|
|
|
|
type SavePaintResult,
|
feat: add manual lasso wall splitting with magnetic edge-snapping and active contour refinement
- New magneticLasso module: Sobel energy map + Dijkstra shortest-path + Douglas-Peucker
- New activeContour module: greedy snake + balloon force for polygon-to-edge refinement
- wallTextureSplit: edge barrier mask, morphological mask hole closing, Moore boundary tracing, simplified polygon contours, manual pick map patching, gap absorption
- MaskSegmentCanvas: full lasso gesture pipeline (tap vertices, drag, magnetic paths, close polygon, endLasso/cancelLasso/deleteLasso)
- New maskConfig options: splitWallsEdgeBarrierThreshold, splitWallsCloseMaskRadius, manualSplitWalls, manualSplitWallsMaxCount, manualSplitWallsGapAbsorbDilatePx, magneticLasso, activeContourRefine
- New ref methods: startLasso, endLasso, cancelLasso, getManualRegions, deleteLasso
- New exported types: LassoPolygon, ManualWallPartition
- RegionMaskData carries indexToName and wallSemanticIdx through downsample
- Simplify README to point to documentation site
- Update documentation site (EN + ZH-CN) with all new APIs and interaction guide
- Example app: lasso mode toggles and operation buttons
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-07 03:23:57 +00:00
|
|
|
type LassoPolygon,
|
|
|
|
|
type ManualWallPartition,
|
2026-07-03 06:25:56 +00:00
|
|
|
MASK_SEMANTIC_COLORS,
|
|
|
|
|
BASEBOARD_SEMANTIC_NAME,
|
|
|
|
|
prewarmPngBgrCacheAsync,
|
|
|
|
|
DEFAULT_PIPELINE_CONFIG,
|
|
|
|
|
DEFAULT_MASK_CONFIG,
|
|
|
|
|
DEFAULT_PAINT_CONFIG,
|
|
|
|
|
DEFAULT_INTERACTION_CONFIG,
|
|
|
|
|
} from 'react-native-mask-segment-canvas';
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
| 分类 | 名称 |
|
|
|
|
|
| --- | --- |
|
|
|
|
|
| 组件 | `MaskSegmentCanvas`(默认导出) |
|
|
|
|
|
| Ref / Props 类型 | `MaskSegmentCanvasRef`, `MaskSegmentCanvasProps` |
|
|
|
|
|
| 会话 / 回调类型 | `MaskSegmentSession`, `PaintCallbackPayload`, `PaintedRegionRecord`, `SavePaintResult` |
|
feat: add manual lasso wall splitting with magnetic edge-snapping and active contour refinement
- New magneticLasso module: Sobel energy map + Dijkstra shortest-path + Douglas-Peucker
- New activeContour module: greedy snake + balloon force for polygon-to-edge refinement
- wallTextureSplit: edge barrier mask, morphological mask hole closing, Moore boundary tracing, simplified polygon contours, manual pick map patching, gap absorption
- MaskSegmentCanvas: full lasso gesture pipeline (tap vertices, drag, magnetic paths, close polygon, endLasso/cancelLasso/deleteLasso)
- New maskConfig options: splitWallsEdgeBarrierThreshold, splitWallsCloseMaskRadius, manualSplitWalls, manualSplitWallsMaxCount, manualSplitWallsGapAbsorbDilatePx, magneticLasso, activeContourRefine
- New ref methods: startLasso, endLasso, cancelLasso, getManualRegions, deleteLasso
- New exported types: LassoPolygon, ManualWallPartition
- RegionMaskData carries indexToName and wallSemanticIdx through downsample
- Simplify README to point to documentation site
- Update documentation site (EN + ZH-CN) with all new APIs and interaction guide
- Example app: lasso mode toggles and operation buttons
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-07 03:23:57 +00:00
|
|
|
| 套索类型 | `LassoPolygon`, `ManualWallPartition` |
|
2026-07-03 06:25:56 +00:00
|
|
|
| Watch 类型 | `MaskSegmentWatchState`, `MaskSegmentWatchDetail` |
|
|
|
|
|
| 配置类型 | `PipelineConfig`, `MaskSegmentConfig`, `PaintConfig`, `InteractionConfig` |
|
|
|
|
|
| 语义颜色 | `MASK_SEMANTIC_COLORS`, `BASEBOARD_SEMANTIC_NAME` |
|
|
|
|
|
| 工具函数 | `prewarmPngBgrCacheAsync` |
|
|
|
|
|
| 运行时默认值 | `DEFAULT_*_CONFIG` |
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Props 概览
|
|
|
|
|
|
|
|
|
|
| 分类 | 描述 |
|
|
|
|
|
| --- | --- |
|
|
|
|
|
| [图像与初始化](/docs/api/props-image) | `originUrl`, `maskUrl`, `initialSession`, `initialPaintColor` |
|
|
|
|
|
| [语义颜色与轮廓](/docs/api/props-semantic) | `semanticColors`, `regionOutlineColor` |
|
|
|
|
|
| [maskConfig](/docs/api/mask-config) | 分割和语义区域配置 |
|
|
|
|
|
| [pipelineConfig](/docs/api/pipeline-config) | 分辨率和处理管线配置 |
|
|
|
|
|
| [paintConfig](/docs/api/paint-config) | 上色渲染和纹理混合配置 |
|
|
|
|
|
| [interactionConfig](/docs/api/interaction-config) | 触摸交互和命中测试配置 |
|
|
|
|
|
| [UI 控件与样式](/docs/api/ui-controls) | 可见性开关、自定义渲染器、样式 |
|
|
|
|
|
| [回调](/docs/api/callbacks) | `onWatch`, `onPaintCallback`, `onError` |
|
|
|
|
|
| [Ref 方法](/docs/api/ref-methods) | 通过 `ref` 调用的命令式方法 |
|
|
|
|
|
| [存储约定](/docs/api/storage) | 会话持久化和 PNG 导出 |
|