Skip to main content
Glama
ext-sakamoro

Aseprite MCP Tools

by ext-sakamoro

draw_rectangle

Add rectangles to Aseprite pixel art files by specifying position, dimensions, color, and fill options for precise canvas modifications.

Instructions

Draw a rectangle on the canvas.

Args: filename: Name of the Aseprite file to modify x: Top-left x coordinate y: Top-left y coordinate width: Width of the rectangle height: Height of the rectangle color: Hex color code (default: "#000000") fill: Whether to fill the rectangle (default: False)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filenameYes
xYes
yYes
widthYes
heightYes
colorNo#000000
fillNo

Implementation Reference

  • The draw_rectangle tool handler function in drawing.py. It validates inputs, constructs a Lua script using LuaBuilder, and executes it via Aseprite.
    async def draw_rectangle(filename: str, x: int, y: int, width: int, height: int, color: str = "#000000", fill: bool = False) -> str:
        """Draw a rectangle on the canvas.
    
        Args:
            filename: Name of the Aseprite file to modify
            x: Top-left x coordinate
            y: Top-left y coordinate
            width: Width of the rectangle
            height: Height of the rectangle
            color: Hex color code (default: "#000000")
            fill: Whether to fill the rectangle (default: False)
        """
        try:
            # Validate inputs
            file_path = validate_file_path(filename, must_exist=True)
            color = validate_color(color)
            
            if width < 1:
                raise ValidationError("width", width, "Width must be at least 1")
            if height < 1:
                raise ValidationError("height", height, "Height must be at least 1")
            
            # Build Lua script
            builder = LuaBuilder()
            builder.add_line('local spr = app.activeSprite')
            builder.if_condition('not spr')
            builder.add_line('error("No active sprite")')
            builder.end_if()
            builder.add_line()
            
            builder.begin_transaction()
            builder.draw_rectangle(x, y, width, height, color, fill)
            builder.end_transaction()
            builder.save_sprite()

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/ext-sakamoro/AsepriteMCP'

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