draw_pixels
Draw multiple pixels simultaneously in pixel art projects to create shapes, patterns, or fill areas efficiently using specified coordinates and colors.
Instructions
Draw multiple pixels at once
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | Project identifier | |
| layerIndex | No | Layer index (default: 0) | |
| frameIndex | No | Frame index (default: 0) | |
| pixels | Yes | Array of pixel coordinates | |
| color | Yes | Color in hex format |
Implementation Reference
- src/server/PiskelServer.ts:1063-1073 (handler)The server-side handler for the 'draw_pixels' tool, which fetches the correct frame and calls the core `drawPixels` function.
private drawPixelsTool( projectId: string, layerIndex: number, frameIndex: number, pixels: Array<{ x: number; y: number }>, color: string ): object { const frame = this.getFrame(projectId, layerIndex, frameIndex); const count = drawPixels(frame, pixels, color); return { success: true, pixelsDrawn: count }; } - src/tools/drawing.ts:40-56 (helper)The core logic for drawing pixels on a frame.
export function drawPixels( frame: Frame, pixels: Array<{ x: number; y: number }>, color: number | string ): number { let count = 0; const colorInt = typeof color === 'string' ? colorToInt(color) : color; for (const { x, y } of pixels) { if (frame.containsPixel(x, y)) { frame.setPixel(x, y, colorInt); count++; } } return count; } - src/server/PiskelServer.ts:274-295 (registration)Registration of the 'draw_pixels' tool within the server's tool definitions.
name: 'draw_pixels', description: 'Draw multiple pixels at once', 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)', }, pixels: { type: 'array', items: { type: 'object', properties: {