{
  "name": "canvas",
  "title": "画布绘制",
  "description": "基于node-canvas的画布绘制工具，支持矩形、圆形、文字、线条、路径、渐变、图片合成等HTML Canvas API操作。触发关键词：画布绘制、canvas绘图、canvas画图",
  "group": "media",
  "type": "function",
  "main": "./index.js",
  "strict": true,
  "add_params": false,
  "params": [
    {
      "name": "action",
      "description": "操作类型：rect(矩形)/circle(圆形)/text(文字)/line(线条)/path(路径)/image(图片合成)/clear(清空)",
      "type": "string",
      "enum": ["rect", "circle", "text", "line", "path", "image", "clear"]
    },
    {
      "name": "shapes",
      "description": "批量绘制数组，每个元素包含type及对应参数。使用此参数可在一个操作中绘制多个图形，支持rect/circle/text/line/path/image。",
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "type": { "type": "string", "description": "图形类型：rect/circle/text/line/path/image" },
          "x": { "type": "number", "description": "X坐标" },
          "y": { "type": "number", "description": "Y坐标" },
          "color": { "type": "string", "description": "颜色，如 #FF0000" },
          "fillColor": { "type": "string", "description": "填充颜色" },
          "strokeColor": { "type": "string", "description": "描边颜色" },
          "rectWidth": { "type": "number", "description": "矩形宽度" },
          "rectHeight": { "type": "number", "description": "矩形高度" },
          "radius": { "type": "number", "description": "圆形半径" },
          "text": { "type": "string", "description": "文字内容" },
          "fontSize": { "type": "number", "description": "字号" },
          "fontFamily": { "type": "string", "description": "字体" },
          "x1": { "type": "number", "description": "线条起点X" },
          "y1": { "type": "number", "description": "线条起点Y" },
          "x2": { "type": "number", "description": "线条终点X" },
          "y2": { "type": "number", "description": "线条终点Y" },
          "lineWidth": { "type": "number", "description": "线条宽度" },
          "pathCommands": { "type": "array", "description": "路径命令数组，如 [{cmd:'moveTo',x:0,y:0},{cmd:'lineTo',x:100,y:100}]" },
          "imagePath": { "type": "string", "description": "图片文件路径" },
          "imageWidth": { "type": "number", "description": "图片绘制宽度" },
          "imageHeight": { "type": "number", "description": "图片绘制高度" },
          "opacity": { "type": "number", "description": "透明度 0-1" },
          "gradient": { "type": "object", "description": "渐变配置" },
          "shadow": { "type": "object", "description": "阴影配置 {color, blur, offsetX, offsetY}" }
        }
      }
    },
    {
      "name": "width",
      "description": "画布宽度（像素），默认800",
      "type": "number",
      "default": 800
    },
    {
      "name": "height",
      "description": "画布高度（像素），默认600",
      "type": "number",
      "default": 600
    },
    {
      "name": "format",
      "description": "输出格式：png/jpeg/webp，默认png",
      "type": "string",
      "enum": ["png", "jpeg", "jpg", "webp"],
      "default": "png"
    },
    {
      "name": "output",
      "description": "输出文件路径（可选，不传则自动生成）",
      "type": "string"
    },
    {
      "name": "quality",
      "description": "输出质量（1-100），jpeg/webp格式有效，默认90",
      "type": "number",
      "default": 90
    },
    {
      "name": "background",
      "description": "背景颜色，如 #ffffff，默认白色",
      "type": "string",
      "default": "#ffffff"
    },
    {
      "name": "x",
      "description": "X坐标，单次绘制时使用",
      "type": "number"
    },
    {
      "name": "y",
      "description": "Y坐标，单次绘制时使用",
      "type": "number"
    },
    {
      "name": "color",
      "description": "颜色，如 #FF0000（红色），单次绘制时使用",
      "type": "string",
      "default": "#000000"
    },
    {
      "name": "fillColor",
      "description": "填充颜色，用于矩形/圆形等有填充的图形",
      "type": "string"
    },
    {
      "name": "strokeColor",
      "description": "描边颜色",
      "type": "string"
    },
    {
      "name": "rectWidth",
      "description": "矩形宽度",
      "type": "number"
    },
    {
      "name": "rectHeight",
      "description": "矩形高度",
      "type": "number"
    },
    {
      "name": "radius",
      "description": "圆形半径",
      "type": "number"
    },
    {
      "name": "text",
      "description": "文字内容",
      "type": "string"
    },
    {
      "name": "fontSize",
      "description": "字号",
      "type": "number"
    },
    {
      "name": "fontFamily",
      "description": "字体名称",
      "type": "string"
    },
    {
      "name": "x1",
      "description": "线条起点X",
      "type": "number"
    },
    {
      "name": "y1",
      "description": "线条起点Y",
      "type": "number"
    },
    {
      "name": "x2",
      "description": "线条终点X",
      "type": "number"
    },
    {
      "name": "y2",
      "description": "线条终点Y",
      "type": "number"
    },
    {
      "name": "lineWidth",
      "description": "线条宽度",
      "type": "number"
    },
    {
      "name": "pathCommands",
      "description": "路径命令数组，支持moveTo/lineTo/quadraticCurveTo/bezierCurveTo/arc/arcTo/closePath",
      "type": "array"
    },
    {
      "name": "imagePath",
      "description": "要合成的图片文件路径",
      "type": "string"
    },
    {
      "name": "imageWidth",
      "description": "图片绘制宽度（可选，不传使用原图宽）",
      "type": "number"
    },
    {
      "name": "imageHeight",
      "description": "图片绘制高度（可选，不传使用原图高）",
      "type": "number"
    },
    {
      "name": "opacity",
      "description": "透明度 0-1，默认1（不透明）",
      "type": "number",
      "default": 1
    },
    {
      "name": "gradient",
      "description": "渐变配置，如 {type:'linear',stops:[{offset:0,color:'#000'},{offset:1,color:'#fff'}],x0:0,y0:0,x1:100,y1:100}",
      "type": "object"
    },
    {
      "name": "shadow",
      "description": "阴影配置，如 {color:'#000',blur:10,offsetX:5,offsetY:5}",
      "type": "object"
    }
  ],
  "returns": [
    {
      "name": "code",
      "type": "number",
      "description": "操作状态代码，0表示成功",
      "default": 0
    },
    {
      "name": "msg",
      "type": "string",
      "description": "操作反馈消息"
    },
    {
      "name": "file_path",
      "type": "string",
      "description": "生成的文件路径"
    },
    {
      "name": "format",
      "type": "string",
      "description": "输出格式"
    },
    {
      "name": "width",
      "type": "number",
      "description": "画布宽度"
    },
    {
      "name": "height",
      "type": "number",
      "description": "画布高度"
    },
    {
      "name": "size",
      "type": "number",
      "description": "文件大小（字节）"
    }
  ],
  "sort": 10,
  "state": 1,
  "show": 0,
  "end": false
}
