get_pixel
Retrieve the color value of a specific pixel from a pixel art project by specifying coordinates, project ID, and optional layer and frame indices.
Instructions
Get the color of a pixel
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | Project identifier | |
| layerIndex | No | Layer index (default: 0) | |
| frameIndex | No | Frame index (default: 0) | |
| x | Yes | X coordinate | |
| y | Yes | Y coordinate |
Implementation Reference
- src/server/PiskelServer.ts:1155-1182 (handler)The handler function for the get_pixel tool. It retrieves the frame and calls its getPixel method, then formats the result.
private getPixelTool( projectId: string, layerIndex: number, frameIndex: number, x: number, y: number ): object { const frame = this.getFrame(projectId, layerIndex, frameIndex); const color = frame.getPixel(x, y); if (color === null) { return { x, y, color: 'out_of_bounds', colorInt: null, }; } return { x, y, color: color === 0 ? 'transparent' : intToHex(color), colorInt: color, }; } private getFrameDataTool( - src/server/PiskelServer.ts:527-545 (schema)The schema definition for the get_pixel tool registration.
{ name: 'get_pixel', description: 'Get the color of a pixel', 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)', }, x: { - src/core/Frame.ts:168-173 (helper)The low-level helper function on the Frame class that retrieves the pixel value from the underlying pixel array.
getPixel(x: number, y: number): number | null { if (!this.containsPixel(x, y)) { return null; } return this.pixels[y * this.width + x]; }