draw_circle
Add circles or ellipses to pixel art projects by specifying bounding box coordinates and color, with options for outline or filled shapes.
Instructions
Draw a circle/ellipse (outline or filled)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | Project identifier | |
| layerIndex | No | Layer index (default: 0) | |
| frameIndex | No | Frame index (default: 0) | |
| x0 | Yes | Bounding box top-left X | |
| y0 | Yes | Bounding box top-left Y | |
| x1 | Yes | Bounding box bottom-right X | |
| y1 | Yes | Bounding box bottom-right Y | |
| color | Yes | Color in hex format | |
| filled | No | Whether to fill the circle (default: false) | |
| penSize | No | Stroke width for outline (default: 1) |
Implementation Reference
- src/server/PiskelServer.ts:1110-1126 (handler)The drawCircleTool method in PiskelServer serves as the handler for the 'draw_circle' tool, delegating the logic to either drawFilledCircle or the imported drawCircle function.
private drawCircleTool( projectId: string, layerIndex: number, frameIndex: number, x0: number, y0: number, x1: number, y1: number, color: string, filled: boolean, penSize: number ): object { const frame = this.getFrame(projectId, layerIndex, frameIndex); const count = filled ? drawFilledCircle(frame, x0, y0, x1, y1, color) : drawCircle(frame, x0, y0, x1, y1, color, penSize); return { success: true, pixelsDrawn: count }; - src/tools/drawing.ts:159-180 (handler)The drawCircle function in src/tools/drawing.ts implements the actual pixel manipulation logic for drawing an outline circle.
export function drawCircle( frame: Frame, x0: number, y0: number, x1: number, y1: number, color: number | string, penSize: number = 1 ): number { const colorInt = typeof color === 'string' ? colorToInt(color) : color; const pixels = getCirclePixels(x0, y0, x1, y1, penSize); let count = 0; const drawnSet = new Set<string>(); for (const [x, y] of pixels) { const key = `${x},${y}`; if (!drawnSet.has(key) && frame.containsPixel(x, y)) { drawnSet.add(key); frame.setPixel(x, y, colorInt); count++; } - src/server/PiskelServer.ts:408-456 (schema)The schema definition for 'draw_circle' in PiskelServer, specifying inputs such as coordinates, color, and optional filled/penSize properties.
name: 'draw_circle', description: 'Draw a circle/ellipse (outline or filled)', inputSchema: { type: 'object', properties: { projectId: { type: 'string', description: 'Project identifier', }, layerIndex: { type: 'number', description: 'Layer index (default: 0)', }, frameIndex: { type: 'number', description: 'Frame index (default: 0)', }, x0: { type: 'number', description: 'Bounding box top-left X', }, y0: { type: 'number', description: 'Bounding box top-left Y', }, x1: { type: 'number', description: 'Bounding box bottom-right X', }, y1: { type: 'number', description: 'Bounding box bottom-right Y', }, color: { type: 'string', description: 'Color in hex format', }, filled: { type: 'boolean', description: 'Whether to fill the circle (default: false)', }, penSize: { type: 'number', description: 'Stroke width for outline (default: 1)', }, }, required: ['projectId', 'x0', 'y0', 'x1', 'y1', 'color'], }, }, - src/server/PiskelServer.ts:801-803 (registration)The tool execution routing in executeToolCall directs 'draw_circle' requests to the drawCircleTool handler.
case 'draw_circle': return this.drawCircleTool( args.projectId as string,