Skip to main content
Glama

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
NameRequiredDescriptionDefault
projectIdYesProject identifier
layerIndexNoLayer index (default: 0)
frameIndexNoFrame index (default: 0)
x0YesBounding box top-left X
y0YesBounding box top-left Y
x1YesBounding box bottom-right X
y1YesBounding box bottom-right Y
colorYesColor in hex format
filledNoWhether to fill the circle (default: false)
penSizeNoStroke width for outline (default: 1)

Implementation Reference

  • 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 };
  • 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++;
        }
  • 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'],
      },
    },
  • The tool execution routing in executeToolCall directs 'draw_circle' requests to the drawCircleTool handler.
    case 'draw_circle':
      return this.drawCircleTool(
        args.projectId as string,

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/yafeiaa/piskel-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server