get_frame_data
Extract pixel data from animation frames as 2D arrays for analysis, manipulation, or export in pixel art projects.
Instructions
Get all pixel data from a frame as a 2D array
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | Project identifier | |
| layerIndex | No | Layer index (default: 0) | |
| frameIndex | No | Frame index (default: 0) |
Implementation Reference
- src/server/PiskelServer.ts:1182-1204 (handler)The implementation of the 'get_frame_data' tool logic, which retrieves pixels from a specific frame and converts them into a 2D array of color strings.
private getFrameDataTool( projectId: string, layerIndex: number, frameIndex: number ): object { const piskel = this.getProject(projectId); const frame = this.getFrame(projectId, layerIndex, frameIndex); const width = piskel.getWidth(); const height = piskel.getHeight(); const pixels = frame.getPixels(); const data: string[][] = []; for (let y = 0; y < height; y++) { const row: string[] = []; for (let x = 0; x < width; x++) { const color = pixels[y * width + x]; row.push(color === 0 ? 'transparent' : intToHex(color)); } data.push(row); } return { width, height, data }; }