create_canvas
Create a new Aseprite canvas by specifying width and height in pixels to start pixel art projects with custom dimensions.
Instructions
Create a new Aseprite canvas with specified dimensions.
Args: width: Width of the canvas in pixels height: Height of the canvas in pixels filename: Name of the output file (default: canvas.aseprite)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| width | Yes | ||
| height | Yes | ||
| filename | No | canvas.aseprite |
Implementation Reference
- aseprite_mcp/tools/canvas.py:15-49 (handler)The create_canvas tool is registered with the @mcp.tool() decorator and implemented as an async function that validates dimensions, constructs a Lua script using LuaBuilder, and executes it via the command interface.
@mcp.tool() async def create_canvas(width: int, height: int, filename: str = "canvas.aseprite") -> str: """Create a new Aseprite canvas with specified dimensions. Args: width: Width of the canvas in pixels height: Height of the canvas in pixels filename: Name of the output file (default: canvas.aseprite) """ try: log_operation("create_canvas", filename, width=width, height=height) # Validate inputs width, height = validate_dimensions(width, height) file_path = validate_file_path(filename, must_exist=False) # Build Lua script builder = LuaBuilder() builder.create_sprite(width, height) builder.save_sprite(str(file_path)) # Execute script cmd = get_command() success, output = cmd.execute_lua_script(builder.build()) logger.info(f"Canvas created successfully", file=str(file_path), dimensions=f"{width}x{height}") return f"Canvas created successfully: {file_path}" except (ValidationError, AsepriteError) as e: log_error(f"Failed to create canvas", e, "create_canvas", filename=filename) return f"Failed to create canvas: {e}" except Exception as e: log_error(f"Unexpected error in create_canvas", e, "create_canvas", filename=filename) return f"Unexpected error: {e}"