Skip to main content
Glama

draw_line

Draw straight lines between two coordinates in pixel art projects to create shapes, outlines, or connect elements.

Instructions

Draw a line between two points

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdYesProject identifier
layerIndexNoLayer index (default: 0)
frameIndexNoFrame index (default: 0)
x0YesStart X coordinate
y0YesStart Y coordinate
x1YesEnd X coordinate
y1YesEnd Y coordinate
colorYesColor in hex format
penSizeNoPen size (default: 1)

Implementation Reference

  • The implementation of the drawLine tool, which calculates pixel coordinates for a line and applies color to the frame.
    export function drawLine(
      frame: Frame,
      x0: number,
      y0: number,
      x1: number,
      y1: number,
      color: number | string,
      penSize: number = 1,
      uniform: boolean = false
    ): number {
      const colorInt = typeof color === 'string' ? colorToInt(color) : color;
      const linePixels = uniform
        ? getUniformLinePixels(x0, x1, y0, y1)
        : getLinePixels(x0, x1, y0, y1);
    
      let count = 0;
    
      if (penSize === 1) {
        for (const pixel of linePixels) {
          if (frame.containsPixel(pixel.col, pixel.row)) {
            frame.setPixel(pixel.col, pixel.row, colorInt);
            count++;
          }
        }
      } else {
        // Draw with larger pen size
        const drawnSet = new Set<string>();
    
        for (const pixel of linePixels) {
          const resized = resizePixel(pixel.col, pixel.row, penSize);
          for (const [px, py] of resized) {
            const key = `${px},${py}`;
            if (!drawnSet.has(key) && frame.containsPixel(px, py)) {
              drawnSet.add(key);
              frame.setPixel(px, py, colorInt);
              count++;
            }
          }
        }
      }
    
      return count;
    }
  • The handler method in PiskelServer that parses inputs and calls the drawing function.
    private drawLineTool(
      projectId: string,
      layerIndex: number,
      frameIndex: number,
      x0: number,
      y0: number,
      x1: number,
      y1: number,
      color: string,
      penSize: number
    ): object {
      const frame = this.getFrame(projectId, layerIndex, frameIndex);
      const count = drawLine(frame, x0, y0, x1, y1, color, penSize);
      return { success: true, pixelsDrawn: count };
    }
    
    private drawRectangleTool(
      projectId: string,
      layerIndex: number,
      frameIndex: number,
      x0: number,
      y0: number,
      x1: number,
      y1: number,
      color: string,
      filled: boolean,
      penSize: number
  • Tool registration switch case in PiskelServer for 'draw_line'.
    case 'draw_line':
      return this.drawLineTool(
        args.projectId as string,
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action ('Draw') but doesn't cover critical aspects like whether this is a mutation (likely yes), permissions needed, side effects (e.g., modifying a project), or error conditions. The description lacks behavioral context beyond the basic action.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste—'Draw a line between two points' is front-loaded and directly conveys the core purpose without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (a mutation tool with 9 parameters, no annotations, and no output schema), the description is inadequate. It doesn't explain the context (e.g., that it modifies a project in a drawing/animation system), behavioral traits, or what happens on success/failure, leaving significant gaps for an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents all 9 parameters. The description adds no parameter-specific information beyond implying coordinates (x0, y0, x1, y1) for 'two points'. This meets the baseline of 3 since the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Draw a line between two points' clearly states the action (draw) and resource (line), with 'between two points' specifying the geometric operation. It distinguishes from siblings like draw_circle or draw_rectangle by focusing on lines, though it doesn't explicitly contrast with them.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like draw_pixel or draw_rectangle, nor any context about prerequisites (e.g., needing an existing project). The description implies usage for line drawing but offers no explicit when/when-not instructions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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