--- name: draw description: Draw on a shared 2D pixel canvas via the board API. Supports setting individual pixels and drawing lines, rectangles, and circles on a 256x144 pixel grid. --- # 2D Board Drawing Skill Draw on shared pixel canvases using the 2D Board API. Each canvas is a 256x144 pixel grid identified by a channel name. ## Base URL The server runs at `https://dice.fyi`. ## Drawing Shapes (rasterized to pixels) Use `curl` via the Bash tool to draw shapes: ### Line ```bash curl -s -X POST https://dice.fyi/api/CHANNEL/draw \ -H 'Content-Type: application/json' \ -d '{"type":"line","x1":0,"y1":0,"x2":100,"y2":50,"color":"#FF0000","stroke_width":2}' ``` ### Rectangle ```bash curl -s -X POST https://dice.fyi/api/CHANNEL/draw \ -H 'Content-Type: application/json' \ -d '{"type":"rect","x":10,"y":10,"w":50,"h":30,"color":"#00FF00","fill":true}' ``` ### Circle ```bash curl -s -X POST https://dice.fyi/api/CHANNEL/draw \ -H 'Content-Type: application/json' \ -d '{"type":"circle","cx":128,"cy":72,"r":20,"color":"#0000FF","fill":true}' ``` ## Setting Individual Pixels ```bash curl -s -X POST https://dice.fyi/api/CHANNEL/pixels \ -H 'Content-Type: application/json' \ -d '[{"x":0,"y":0,"r":255,"g":0,"b":0},{"x":1,"y":0,"r":0,"g":255,"b":0}]' ``` ## Viewing the Canvas - **PNG image**: `curl -s -o /tmp/canvas.png https://dice.fyi/CHANNEL/png` (scaled 4x to 1024x576), then use the Read tool on `/tmp/canvas.png` to see it - **PNG at native res**: `curl -s -o /tmp/canvas.png https://dice.fyi/CHANNEL/png?scale=1` (256x144) - **CSV data**: `curl https://dice.fyi/CHANNEL/csv` — lists only non-white pixels as `x,y,r,g,b` Always download the PNG and read it with the Read tool after drawing to verify the result. ## Managing the Canvas - **Clear to white**: `curl -X POST https://dice.fyi/api/CHANNEL/clear` - **Clear to color**: `curl -X POST https://dice.fyi/api/CHANNEL/clear -H 'Content-Type: application/json' -d '{"color":"#000000"}'` - **List channels**: `curl https://dice.fyi/api/channels` ## Canvas Details - Grid: 256 x 144 pixels (16:9) - Coordinate system: (0,0) is top-left, (255,143) is bottom-right - Colors: hex format `#RRGGBB` or raw RGB (r,g,b each 0-255) - Default color: `#000000` (black) - Drawing is permanent — no undo, only paint over or clear ## Workflow 1. Pick a channel name (e.g., "myart") 2. Draw shapes or set pixels using POST requests 3. View the result: download the PNG or read the CSV 4. Iterate — paint over existing pixels or clear and start over