Shapes.
设备端形状识别,把一笔手绘线条变成矩形、椭圆、三角形、星形或直线,用时不到 10 毫秒。
演示
草草一画,形状完美。
随手画一个圆,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.
Build a drawing canvas where a freehand stroke is passed to Desert Ant's Shapes on-device and snapped to a clean rectangle, ellipse, triangle, star, or line in under 10ms. Keep the ink as an undo. Works offline. Build it with the Desert Ant SDK. Shapes (Swift, Kotlin, JavaScript / TypeScript). Install and API: https://desertant.com/docs/shapes/. Install: SwiftPM desert-ant-core; Maven ai.desertant:shapes:3.1.0; npm i @desert-ant-labs/shapes @litertjs/core. SDK source: https://github.com/Desert-Ant-Labs/desert-ant-core. Machine-readable catalog of every model and SDK: https://desertant.com/llms.txt.
Clean up a freehand diagram into crisp shapes.
In a diagramming tool, run Desert Ant's Shapes on each stroke to convert rough sketches into clean geometry as the user draws. Build it with the Desert Ant SDK. Shapes (Swift, Kotlin, JavaScript / TypeScript). Install and API: https://desertant.com/docs/shapes/. Install: SwiftPM desert-ant-core; Maven ai.desertant:shapes:3.1.0; npm i @desert-ant-labs/shapes @litertjs/core. SDK source: https://github.com/Desert-Ant-Labs/desert-ant-core. Machine-readable catalog of every model and SDK: https://desertant.com/llms.txt.
Add shape recognition to a web canvas with no download.
Add Desert Ant's Shapes to a browser drawing app (WebAssembly), so a hand-drawn stroke snaps to a clean shape with nothing to download and no server. Build it with the Desert Ant SDK. Shapes (Swift, Kotlin, JavaScript / TypeScript). Install and API: https://desertant.com/docs/shapes/. Install: SwiftPM desert-ant-core; Maven ai.desertant:shapes:3.1.0; npm i @desert-ant-labs/shapes @litertjs/core. SDK source: https://github.com/Desert-Ant-Labs/desert-ant-core. Machine-readable catalog of every model and SDK: https://desertant.com/llms.txt.
Snap flowchart boxes and connector lines as you sketch them.
In a diagram or flowchart tool, run Desert Ant's Shapes on each stroke so hand-drawn boxes and connector lines snap to clean geometry live. (Add your own arrowheads on a recognized line.) Build it with the Desert Ant SDK. Shapes (Swift, Kotlin, JavaScript / TypeScript). Install and API: https://desertant.com/docs/shapes/. Install: SwiftPM desert-ant-core; Maven ai.desertant:shapes:3.1.0; npm i @desert-ant-labs/shapes @litertjs/core. SDK source: https://github.com/Desert-Ant-Labs/desert-ant-core. Machine-readable catalog of every model and SDK: https://desertant.com/llms.txt.
Add smart-shape drawing to a kids' learning app.
Use Desert Ant's Shapes on-device so a child's rough drawing of a circle or triangle snaps to a clean shape, teaching by doing. Works offline. Build it with the Desert Ant SDK. Shapes (Swift, Kotlin, JavaScript / TypeScript). Install and API: https://desertant.com/docs/shapes/. Install: SwiftPM desert-ant-core; Maven ai.desertant:shapes:3.1.0; npm i @desert-ant-labs/shapes @litertjs/core. SDK source: https://github.com/Desert-Ant-Labs/desert-ant-core. Machine-readable catalog of every model and SDK: https://desertant.com/llms.txt.
Recognize gesture shapes to trigger app actions.
Use Desert Ant's Shapes to turn a drawn gesture (a circle, a triangle) into an app action, recognized on-device in under 10ms. Build it with the Desert Ant SDK. Shapes (Swift, Kotlin, JavaScript / TypeScript). Install and API: https://desertant.com/docs/shapes/. Install: SwiftPM desert-ant-core; Maven ai.desertant:shapes:3.1.0; npm i @desert-ant-labs/shapes @litertjs/core. SDK source: https://github.com/Desert-Ant-Labs/desert-ant-core. Machine-readable catalog of every model and SDK: https://desertant.com/llms.txt.
模型能做什么
- 一次一笔,以其
[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.1.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.1.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.1.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.1.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 的价格是多少?
每个模型的每个 SDK 均可免费支持最多 10 万台月活跃设备。每位用户调用模型的次数不设上限。 如需定制授权,请联系我们。
Shapes 的准确度和速度如何?
每笔用时不到 10 毫秒,模型在 Apple 上 0.2 MB,在 Android 和 Web 上 1.3 MB。