Install
openclaw skills install bitmap-vectorize将位图图像(截图、手绘照片、示意图等)转换为精确的矢量图形代码(SVG或Canvas)。当用户提供一张图片并希望将其重新绘制成可缩放、可编辑的矢量图形时,应使用本技能。特别适合物理示意图、几何图形、电路图、标注图等需要精确还原的场景。
openclaw skills install bitmap-vectorize将高中物理题的示意图(位图)转换为精确的矢量图形代码,全程分 6 步完成任务。本技能为物理动画制作提供前期准备工作。
根据图像内容建立坐标系,并记录关键参数:
读取并分析用户提供的图像,识别以下元素:
完成后向用户描述识别到的内容。
获取用户提供的物理题目文字,逐项核对:
此步不可跳过,必须与用户交互完成。
根据校对后的元素列表,生成矢量图形代码:
与用户交互,逐项检查:
此步必须与客户交互完成。
根据客户需求导出:
// 坐标转换:数学坐标 → Canvas坐标
// 数学坐标 (mx, my) → Canvas坐标 (cx, cy)
// cx = originX + mx * scale
// cy = originY - my * scale // 注意y轴方向反转
// 常用绘制方法
ctx.beginPath();
ctx.arc(cx, cy, radius, startAngle, endAngle); // 圆弧
ctx.moveTo(x1, y1); ctx.lineTo(x2, y2); // 直线
ctx.strokeStyle = '#333'; ctx.lineWidth = 2;
ctx.stroke();
// 虚线
ctx.setLineDash([5, 5]);
ctx.stroke();
ctx.setLineDash([]); // 恢复实线
// 箭头
function drawArrow(ctx, fromX, fromY, toX, toY) {
const headLen = 10;
const angle = Math.atan2(toY - fromY, toX - fromX);
ctx.beginPath();
ctx.moveTo(fromX, fromY);
ctx.lineTo(toX, toY);
ctx.lineTo(toX - headLen * Math.cos(angle - Math.PI/6), toY - headLen * Math.sin(angle - Math.PI/6));
ctx.moveTo(toX, toY);
ctx.lineTo(toX - headLen * Math.cos(angle + Math.PI/6), toY - headLen * Math.sin(angle + Math.PI/6));
ctx.stroke();
}
// 半圆弧,圆心在 (cx, cy),半径 R
// 在Canvas中:从 π 到 0(顺时针方向)
ctx.arc(cx, cy, R, Math.PI, 0, false); // 下半圆(Canvas中y向下)
// x轴
drawArrow(ctx, 30, originY, width-20, originY);
ctx.fillText('x', width-15, originY+5);
// y轴(物理向上,Canvas向下绘制)
drawArrow(ctx, originX, height-20, originX, 20);
ctx.fillText('y', originX-15, 25);
// 虚线从点到坐标轴
ctx.setLineDash([4, 4]);
ctx.beginPath();
ctx.moveTo(px, py);
ctx.lineTo(px, originY); // 垂直虚线到x轴
ctx.stroke();
ctx.setLineDash([]);
// 标注点(实心圆)
ctx.beginPath();
ctx.arc(px, py, 4, 0, 2 * Math.PI);
ctx.fillStyle = 'black';
ctx.fill();
physics_shapes.md:常见物理图形的 Canvas/SVG 代码片段(圆弧、力箭头、弹簧等)| 坐标系 | Y轴方向 | 角度正方向 |
|---|---|---|
| Canvas | Y轴向下(y增大=向下) | 顺时针 |
| 数学/物理 | Y轴向上(y增大=向上) | 逆时针 |
arc(cx, cy, R, 0, Math.PI, true),下半圆是 arc(cx, cy, R, Math.PI, 0, false)数学坐标 (mx, my) → Canvas坐标 (cx, cy)
cx = originX + mx * scale
cy = originY - my * scale // 注意y轴方向反转
Transform bitmap images of high school physics problems into precise vector graphics code. This skill prepares diagrams for physics animation production through a 6-step workflow.
Recognize these elements from the image:
Cross-check Step 1 with the physics problem description:
This step is mandatory - must complete with user interaction.
Create Canvas code based on verified elements:
Interact with user to check:
Export based on user needs:
| System | Y-axis | Angle Direction |
|---|---|---|
| Canvas | Downward | Clockwise |
| Math/Physics | Upward | Counter-clockwise |
Math (mx, my) → Canvas (cx, cy)
cx = originX + mx * scale
cy = originY - my * scale // Note: y-axis inverted