
演示
草草一画,形状完美。
随手画一个圆,Shapes 就把它吸附成规整的圆。Shapes 拟合出精确的矢量几何,吸附到坐标轴、正圆、正方形和 15 度旋转,并拒绝那些并不是形状的涂鸦。
在 Apple 平台上,一次调用就能给 PencilKit 画布加上「备忘录」式的智能形状吸附,实时预览照常保留。Apple 自家的「Snap to Shape」是第三方应用无法调用的私有 API,Shapes 用一行代码做同样的事。
模型足够小,可以直接随应用发布,无需下载。在浏览器里,Shapes 通过 LiteRT.js 运行。
每笔用时不到 10 毫秒。
每笔用时不到 10 毫秒,模型在 Apple 上 0.2 MB,在 Android 和 Web 上 1.3 MB。
内部测量数据。Apple 端使用 Core ML,浏览器端使用 LiteRT.js,Node 端使用预编译的原生库。
应用场景
草草一画,形状完美。.
「备忘录」式智能形状
用 canvasView.enableShapeSnapping() 为 PencilKit 画布添加形状吸附。保留实时预览、撤销和重做,填补 Apple 私有 Snap to Shape API 留下的空缺。
把手绘草图整理干净
在图表或白板工具里,粗糙的笔画会变成精确的几何图形。可配合 tldraw 和 Excalidraw 的笔画数据使用。
跨平台绘图
一个识别器覆盖 iOS、Android 和 Web,吸附的代码只写一次。
随应用一起发布,不用另行下载
在 Apple 上识别器只有 0.2 MB,直接打包在二进制文件里,Android 包也默认内置。在浏览器中,SDK 只需获取一次 1.3 MB 的模型并缓存下来。
灵感
用 Shapes 构建的点子。把提示词复制到你的编码 agent 里就能开始。
Build a whiteboard that snaps rough sketches into clean shapes.
Clean up a freehand diagram into crisp shapes.
Add shape recognition to a web canvas with no download.
Snap flowchart boxes and connector lines as you sketch them.
Add smart-shape drawing to a kids' learning app.
Recognize gesture shapes to trigger app actions.
模型能做什么
- 一次一笔,以其
[x, y]点的形式传入,来自 PencilKit、tldraw、Excalidraw 或你自己的画布。 - 识别矩形、椭圆、三角形、星形和直线,并拒绝非形状。
- 吸附到坐标轴、正圆、正方形和 15 度旋转。
- 只需一次调用即可实现 PencilKit 实时吸附:
canvasView.enableShapeSnapping()。 - 在浏览器中通过 LiteRT.js 运行。Node 使用预编译的原生库。
快速上手
只需几行代码,即可为你的 iOS or macOS, Android or web 应用加上 形状识别。 Shapes 文档.
// Swift Package Manager
.package(url: "https://github.com/Desert-Ant-Labs/desert-ant-core", from: "3.5.0")
// target dependency
.product(name: "Shapes", package: "desert-ant-core")
import Shapes
let shapes = Shapes()
let shape = try await shapes.recognize(points: stroke)
// Shape? -> rectangle, ellipse, triangle, star, line
import PencilKit
import Shapes
// Live smart-shape snapping on a PencilKit canvas, in one line.
// Pause after a stroke to preview the fit, lift to snap. Undo-safe,
// and it uses the same recognizer, bundled by default.
canvasView.enableShapeSnapping()
Add Shapes from Desert Ant Labs to this Swift project (iOS, macOS). What it does: Shapes:设备端单笔画形状识别. SDK: Swift (iOS, macOS) Repo: https://github.com/Desert-Ant-Labs/desert-ant-core#readme // Swift Package Manager .package(url: "https://github.com/Desert-Ant-Labs/desert-ant-core", from: "3.5.0") // target dependency .product(name: "Shapes", package: "desert-ant-core") Reference: - Model page: https://desertant.com/models/shapes/ - Full catalog and other models: https://desertant.com/llms.txt Add the SDK, then follow its README for the exact API and current version. Do not invent API names or method signatures; confirm them against the README.
// build.gradle.kts (Maven Central)
implementation("ai.desertant:shapes:3.5.0")
import ai.desertant.shapes.Shapes
val shapes = Shapes(context)
val shape = shapes.recognize(points)
// Shape? -> rectangle, ellipse, triangle, star, line
Add Shapes from Desert Ant Labs to this Kotlin project (Android).
What it does: Shapes:设备端单笔画形状识别.
SDK:
Kotlin (Android)
Repo: https://github.com/Desert-Ant-Labs/desert-ant-core#readme
// build.gradle.kts (Maven Central)
implementation("ai.desertant:shapes:3.5.0")
Reference:
- Model page: https://desertant.com/models/shapes/
- Full catalog and other models: https://desertant.com/llms.txt
Add the SDK, then follow its README for the exact API and current version. Do not invent API names or method signatures; confirm them against the README.
npm i @desert-ant-labs/shapes @litertjs/core
import { Shapes } from "@desert-ant-labs/shapes"; // browser
// import { Shapes } from "@desert-ant-labs/shapes/native"; // server-side Node
const shapes = await Shapes.load();
const shape = await shapes.recognize(points);
// { kind: "ellipse", center: {...}, ... } or null
Add Shapes from Desert Ant Labs to this JavaScript / TypeScript project (Web, Node.js). What it does: Shapes:设备端单笔画形状识别. SDK: JavaScript / TypeScript (Web, Node.js) Repo: https://github.com/Desert-Ant-Labs/desert-ant-core#readme npm i @desert-ant-labs/shapes @litertjs/core Reference: - Model page: https://desertant.com/models/shapes/ - Full catalog and other models: https://desertant.com/llms.txt Add the SDK, then follow its README for the exact API and current version. Do not invent API names or method signatures; confirm them against the README.
规格
- 形状类别
- 矩形、椭圆、三角形、星形、直线
- 设备端体积
- 0.2 MB Core ML(Apple);1.3 MB LiteRT(Android、Web)
- 速度
- <10 毫秒
- Web 运行时
- 浏览器端 LiteRT.js,Node 端原生库
Shapes 一次只读一笔,因此分两笔画出的形状不会被识别。太潦草或太含糊的笔画会被有意拒绝,涂鸦不会被吸附成三角形。多笔画的图形需要你先自行做一步笔画归组。
常见问题
Shapes 是什么?
设备端形状识别,把一笔手绘线条变成矩形、椭圆、三角形、星形或直线,用时不到 10 毫秒。
Shapes 在设备上运行吗?
是的。Shapes 在设备上运行,不调用任何服务器,因此数据始终留在用户手中。
Shapes 支持哪些平台?
Shapes 以面向 Swift, Kotlin, JavaScript / TypeScript 的原生设备端 SDK 形式提供。
Shapes 的价格是多少?
每个模型免费支持最多 10 万台月活跃设备。推理次数不限。 如需定制授权,请联系我们。
Shapes 的准确度和速度如何?
每笔用时不到 10 毫秒,模型在 Apple 上 0.2 MB,在 Android 和 Web 上 1.3 MB。