Install
$ agentstack add skill-hhhh124hhhh-skillmate-canvas-design ✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
Verified badge
Passed review? Show it. Paste this badge into your README, it links to the public security report.
Reliability & compatibility
Declared compatibility
Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.
We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.
How agent discovery & health will work →About
Canvas 设计工具
概述
使用 HTML5 Canvas API 创建高质量的设计和艺术作品。
核心功能:
- 2D 图形绘制
- 图像处理
- 文字排版
- 导出 PNG/PDF
基础设置
创建 Canvas
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
// 设置画布大小
canvas.width = 1920;
canvas.height = 1080;
// 设置背景
ctx.fillStyle = '#ffffff';
ctx.fillRect(0, 0, canvas.width, canvas.height);
绘图操作
基本形状
// 矩形
ctx.fillStyle = '#3498db';
ctx.fillRect(x, y, width, height);
// 圆形
ctx.beginPath();
ctx.arc(x, y, radius, 0, Math.PI * 2);
ctx.fillStyle = '#e74c3c';
ctx.fill();
// 线条
ctx.beginPath();
ctx.moveTo(x1, y1);
ctx.lineTo(x2, y2);
ctx.strokeStyle = '#2ecc71';
ctx.lineWidth = 2;
ctx.stroke();
文字渲染
// 设置字体
ctx.font = 'bold 48px Arial';
ctx.fillStyle = '#333333';
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
// 绘制文字
ctx.fillText('Hello Canvas', x, y);
// 文字描边
ctx.strokeText('Outlined Text', x, y);
渐变
// 线性渐变
const gradient = ctx.createLinearGradient(x1, y1, x2, y2);
gradient.addColorStop(0, '#3498db');
gradient.addColorStop(1, '#9b59b6');
ctx.fillStyle = gradient;
ctx.fillRect(x, y, width, height);
// 径向渐变
const radialGradient = ctx.createRadialGradient(x, y, r1, x, y, r2);
radialGradient.addColorStop(0, '#ffffff');
radialGradient.addColorStop(1, '#000000');
ctx.fillStyle = radialGradient;
ctx.beginPath();
ctx.arc(x, y, radius, 0, Math.PI * 2);
ctx.fill();
高级效果
阴影
ctx.shadowColor = 'rgba(0, 0, 0, 0.5)';
ctx.shadowBlur = 10;
ctx.shadowOffsetX = 5;
ctx.shadowOffsetY = 5;
ctx.fillRect(x, y, width, height);
透明度
ctx.globalAlpha = 0.5;
ctx.fillRect(x, y, width, height);
ctx.globalAlpha = 1.0; // 重置
组合操作
// 源图像在目标图像之上
ctx.globalCompositeOperation = 'source-over';
// 目标图像在源图像之上
ctx.globalCompositeOperation = 'destination-over';
// 交集
ctx.globalCompositeOperation = 'source-in';
图像处理
加载图像
const img = new Image();
img.onload = () => {
ctx.drawImage(img, x, y, width, height);
};
img.src = 'image.png';
图像滤镜
// 像素级操作
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
const data = imageData.data;
for (let i = 0; i {
draw();
});
// 离屏 Canvas
const offscreenCanvas = document.createElement('canvas');
const offscreenCtx = offscreenCanvas.getContext('2d');
// 在离屏 canvas 上绘制
3. 响应式设计
function resizeCanvas() {
const container = canvas.parentElement;
canvas.width = container.clientWidth;
canvas.height = container.clientHeight;
redraw();
}
依赖要求
- 浏览器环境或 Node.js canvas 库
- jsPDF(可选,用于 PDF 导出)
代码风格指南
- 使用常量定义颜色和尺寸
- 封装绘制函数
- 添加注释说明复杂逻辑
- 使用模块化代码结构
常见陷阱
避免:
- ❌ 在循环中重复创建对象
- ❌ 忘记重置状态(globalAlpha, shadow 等)
- ❌ 硬编码坐标(使用相对定位)
推荐:
- ✅ 使用 save/restore 保护状态
- ✅ 缓存常用对象
- ✅ 使用变量控制布局参数
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: hhhh124hhhh
- Source: hhhh124hhhh/SkillMate
- License: Apache-2.0
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet, be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.