Skip to main content

🎨 基础绘图工具 - 12个核心MCP绘图工具

Project description

🎨 GamePainter - 基础绘图工具

提供 12 个核心绘图工具,通过组合可绑制任意复杂图形!

Python MCP License

✨ 特性

  • 🎨 12 个基础工具 - 精简设计,功能完整
  • 🔧 MCP 工具集成 - 可被 AI 助手直接调用
  • 📐 灵活组合 - 基础图形组合成复杂图案
  • 🚀 开箱即用 - 无需复杂配置

🚀 快速开始

安装

# 克隆项目
git clone https://github.com/dzqdzq/game-painter.git
cd game-painter

# 创建虚拟环境并安装依赖
python -m venv .venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate
pip install -r requirements.txt

直接使用

from painter import GamePainter

# 创建画布
p = GamePainter(200, 150, bg_color=(240, 240, 240, 255))

# 画一个房子
p.pen_rect(50, 60, 100, 80, fill_color=(255, 230, 180, 255))  # 墙
p.pen_polygon([(50, 60), (100, 20), (150, 60)], fill_color=(180, 80, 50, 255))  # 屋顶
p.pen_rect(85, 100, 30, 40, fill_color=(139, 90, 43, 255))  # 门

# 保存
p.save("house.png")

🔌 MCP 工具配置

Cursor 配置

{
  "mcpServers": {
    "game-painter": {
      "command": "python",
      "args": ["/path/to/game-painter/server.py"]
    }
  }
}

Claude Desktop 配置

{
  "mcpServers": {
    "game-painter": {
      "command": "/path/to/game-painter/.venv/bin/python",
      "args": ["/path/to/game-painter/server.py"]
    }
  }
}

🛠️ 工具列表 (12 个)

画布管理

工具 说明
create_canvas 创建画布(第一步)
save 保存画布为图片

线条类

工具 说明
line 直线/虚线
polyline 折线/多段线
arc 弧线
bezier 贝塞尔曲线
wave 波浪线

形状类

工具 说明
rect 矩形/圆角矩形
ellipse 椭圆/正圆
polygon 多边形(三角形、六边形等)

图标类

工具 说明
icon 五角星、箭头

辅助类

工具 说明
text 文字

📖 工具详情

1. create_canvas - 创建画布

width: 画布宽度(默认 200)
height: 画布高度(默认 200)
bg_color: 背景颜色 [R,G,B,A](默认透明)
canvas_id: 画布 ID(默认 "default")

2. line - 画直线

x1, y1: 起点坐标
x2, y2: 终点坐标
color: 颜色 [R,G,B,A]
width: 线宽
dash: 虚线模式 [线段长, 间隔长],如 [10, 5]

3. polyline - 画折线

points: 点坐标列表 [[x1,y1], [x2,y2], ...]
closed: 是否闭合
dash: 虚线模式

4. arc - 画弧线

x, y: 外接矩形左上角
width, height: 外接矩形尺寸
start_angle: 起始角度(度)
end_angle: 结束角度(度)

5. bezier - 画贝塞尔曲线

points: 控制点列表
  - 2 点 = 直线
  - 3 点 = 二次曲线
  - 4 点 = 三次曲线

6. wave - 画波浪线

x1, y1: 起点
x2, y2: 终点
amplitude: 振幅(默认 10)
wavelength: 波长(默认 20)

7. rect - 画矩形

x, y: 左上角坐标
width, height: 尺寸
fill_color: 填充颜色
border_color: 边框颜色
radius: 圆角半径(0 为直角)

8. ellipse - 画椭圆

x, y: 外接矩形左上角
width, height: 尺寸(相等则为正圆)
fill_color: 填充颜色
border_color: 边框颜色

9. polygon - 画多边形

支持两种模式:

模式 1:自定义顶点

points: [[x1,y1], [x2,y2], ...]

模式 2:正多边形

cx, cy: 中心坐标
radius: 外接圆半径
sides: 边数(3=三角形, 6=六边形)
rotation: 旋转角度

10. icon - 画图标

icon_type: "star" 或 "arrow"
cx, cy: 中心坐标
size: 图标大小
direction: 箭头方向(up/down/left/right)
points: 星角数量(默认 5)

11. text - 写文字

x, y: 位置
text: 文字内容
color: 颜色
font_size: 字体大小

12. save - 保存画布

filename: 文件名
output_dir: 输出目录(可选)

🎨 使用示例

画小汽车

1. create_canvas(width=200, height=100)
2. polygon(points=车身坐标)        # 车身
3. polygon(points=车顶坐标)        # 车顶
4. polygon(points=车窗坐标)        # 车窗
5. ellipse(x, y, 30, 30)           # 轮子
6. save(filename="car.png")

画花朵

1. create_canvas(width=150, height=180)
2. rect(茎)
3. bezier(叶子弯曲)
4. ellipse(花瓣 x 4)
5. ellipse(花心)
6. save(filename="flower.png")

📄 License

MIT License


Made with ❤️ for Developers

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

game_painter-2.0.0.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

game_painter-2.0.0-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file game_painter-2.0.0.tar.gz.

File metadata

  • Download URL: game_painter-2.0.0.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for game_painter-2.0.0.tar.gz
Algorithm Hash digest
SHA256 d7d19dbbfd15f02467c775e8e9b2fa9357cb8a59569ce514bbe1aac568885af8
MD5 37c66311719d8dfaf6a130c80c4c682a
BLAKE2b-256 b1292853dd433d8a0d212e02e8796a34f1bf9980d87f167509204c51e7f59c72

See more details on using hashes here.

File details

Details for the file game_painter-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: game_painter-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for game_painter-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5837946110c4215264496ca6d323702d9ef63c738a2fe5b9529f3ebbb9f7ae66
MD5 f50372ec8abcd3f2f4f9b74ee423c68c
BLAKE2b-256 bd2a729d201cad3f9207e2c68cf06dbb0c00078e50c696c5759fb4ca448e78fa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page