ANSIClaw 🦞🎨
Draw ANSI art via the local Clawbius REST API. Use anytime the user asks for ANSI art, or when you want to create it on your own initiative.
Project home:
- Github: https://github.com/n2tr0n/ansiclaw
- Clawhub: https://clawhub.ai/n2tr0n/ansiclaw
Requirements:
- Clawbius (https://github.com/n2tr0n/clawbius); API enabled ANSI drawer - runs on tcp/7777
- node.js v18 for running Clawbius
- Python 'requests' (pip install requests) for scripting API calls.
⛔ HARD RULES — BEFORE ANYTHING ELSE
- 1. NEVER modify reference files. Files in
resources/ are your source material. Do not open them via /api/file/open without immediately calling /api/file/new afterward to switch to a fresh canvas. Opening a file in Clawbius makes it the active canvas — any draw calls will corrupt it. Analyze reference files by reading canvas data ONLY, then immediately create a new canvas before drawing.
- 2. NEVER save or export over an existing ANS file without operators explicit instruction. Always use a new versioned filename (e.g.
flower_v2.ans).
- 3. NEVER use
/api/file/export-png — the correct endpoint is /api/file/export/png (with a slash before png).
1. Session Start Checklist
Every new ANSIClaw session, in order:
- 1.
GET http://127.0.0.1:7777/api/canvas/info — confirm Clawbius is running
- If not running it can be started from the clawbius folder with:
launch_clawbius.sh
- 2.
GET http://127.0.0.1:7777/api/openapi.json — check for API changes - Study reference files (see Section 4 below) — mandatory before drawing
- Read
references/api.md for full endpoint details - Check that ice colors are set to OFF unless Operator says otherwise (see Section 2 below)
- Only draw ONE iteration of the image, but analyze your result and ask the operator if you can improve it and tell them how you will improve it before drawing again. ANSI art is an iterative process — you should be learning and improving with each iteration.
- Only draw iterations when authorized, a maximum of 5 at a time. Ensure you keep copies of each iteration .PNG and .ANS named apprproately; v1, v2 etc using a strategy like _v1a to resolve conflicts
Output dir: the 'outputs' folder in your skill folder — save ANS + PNG here - create the folder if it is not there
2. Color Rules
⚠️ ICE COLORS — DEFAULT IS OFF.
Ice colors are OFF by default. Do not use colors 8–15 as background colors.
If operator specifics that this is an 'ice colors ansi' you may turn ice colors control ON and use 8-15 as background colors.
- - Colors 0–7 are always safe as background
- Colors 0–15 are always safe as foreground
Turning ice colors ON:
- - Call INLINECODE11
- Also pass
"ice_colors": true in your POST /api/file/new call - Now bg colors 8–15 are available for BACKGROUND use and open up new color mixing possibilities.
16-Color Palette
CODEBLOCK0
3. Block types
Shade Blocks (F1–F4)
CODEBLOCK1
Dithering is achieved by varying the shade block (F1–F4) with different foreground/background color pairs. This is the primary tool for gradients, texture, and depth in ANSI art. Avoid large areas of solid color blocks without shade variation, unless a 'toon' style is called for in which case favor a bright/dark cell shaded approach with minimal dithering.
Half-Blocks useful for edges and, smoother curves and anti-aliasing techniques
CODEBLOCK2
4. Studying Reference Files (MANDATORY)
Before drawing anything, study the reference files in resources/. Inspect the whole folder, not just the readme. Do these things:
- - Load the file if it is .ANS or .ASC and analyze it in clawbius - determine form and structure using your API and file analysis skills. focus on how blocks are used to generate aesthetic effects, how colors are combined, and how transitions are handled.
- analyze any PNG or image file for the same qualities - these are also ANSI art but rendered as images, so you can see the intended final output without the limitations of the ANSI format. Look for how colors are distributed, where half-blocks are used, and how shading is achieved.
Study the reference files with the mindset of a detective — look for patterns, techniques, and stylistic choices that you can learn from and apply in your own work. This is a critical step that should not be skipped.
Step 1 — Read the README
resources/README.md
Get the description of each file and what it demonstrates. Also check the folder for any files not described in the readme.
Step 2 — Open and analyze canvas data via API
CODEBLOCK4
Look for:
- - What foreground/background color pairs dominate each region?
- Which shade blocks (F1–F4), and half-blocks are used and where?
- How are transitions handled between regions?
- What background colors are used — are they all 0–7?
Step 3 — Analyze the reference PNG
Each reference file in
resources/ should have a matching
.png alongside the
.ans file. Use the
image tool to analyze the PNG directly:
image(image="<absolute_path_to_resources/file.png>", prompt="...")
Study:
- - Color regions and how they transition
- Where black separators appear between colored areas
- Half-block usage on edges and curves
- Overall composition and density
4. Core Style Rules
No-Tocar (Colored Areas Must Not Touch)
This is an important stylistic rule of some ANSI art.
Different objects can look more appealing when not touching each other directly. They can be separated by black (fg or bg=0) half-blocks or full blocks. This gives the art a clean, distinct look.
Wrong: Red block directly adjacent to yellow block
Right: Red block → black half-block separator → yellow block
Use ▌(221), ▐(222), ▀(223), ▄(220) with fg=color, bg=BLACK to create clean color boundaries.
Example — transitioning from red to yellow area:
CODEBLOCK6
Shading & Depth
- - Use F1–F4 shade blocks to build gradients — never just solid color fills for large areas
- Light source: decide where the light is coming from and be consistent
- Lit faces: use lighter shade blocks (F1/F2) or higher-contrast fg color
- Shadow faces: use F3/F4 or black fg
- Edges catch light: use
UH(223) or LH(220) with bright fg on dark bg for edge highlights
Typical Shading Patterns
CODEBLOCK7
Half-Block Edge Technique
At the boundary between a filled area and black space, use half-blocks to smooth the edge and add depth:
- -
UH(223) fg=color bg=BLACK — object color on top, black below (bottom edge of object) - INLINECODE27 — black on top, object color below (top edge of object)
- These also double as separators (no-tocar) between two color regions
- Also use half blocks for round, circular edges and diagonal lines and organic shapes like hair or the curvature of an object
5. Drawing Approach
Write Python scripts using requests. Never curl individual cells — always batch with scripts.
Script template:
CODEBLOCK8
Save scripts to skill folder scripts/
Save output to skill folder output/ — always export both ANS and PNG.
6. Input Files (Image-to-ANSI Renditions)
Operator may drop a source image into inputs/ and ask for an ANSI rendition of it. Do not check this folder unless explicitly asked.
When asked to render an input file:
- 1. Read the image with the
image tool — study shapes, dominant colors, light source, and composition - Map the image's colors to the 16-color ANSI palette (find the closest match for each major region)
- Plan the canvas layout — decide which regions become which shade/color blocks
- Simplify aggressively — ANSI art is abstraction, not photorealism. Pick 3-5 dominant colors max
- Sketch the composition in comments before coding: major regions, where half-blocks go, light direction
- Draw it — apply all the usual style rules (no-tocars, shade gradients, half-block edges)
- Save output to the usual place
7. Full API Reference
See references/api.md — full endpoint details, parameter lists, CP437 extended codes.
8. Lessons Learned (from real sessions)
Sky / Background Gradients
- - Don't use random noise for texture — even at 15-18% density it creates "rain" or "static" artifacts that look terrible.
- Don't use per-column checkerboard dithering on every row — ANSI cells are tall and narrow, so alternating x%2 columns creates visible vertical stripes, not smooth blending.
- Do use clean solid bands — banding is natural and expected in ANSI art sky gradients. 4-5 rows per band (F4→F3→F2→F1, DBLUE on BLACK) reads cleanly.
- If you want a subtle transition between bands, a single dither row between solid blocks is the maximum — and even that can stripe visually, so test it.
Petals / Organic Shapes
- - Start wider than you think you need. Horizontal spread reads better at ANSI cell aspect ratio than height.
- Use the full shade gradient within each petal (F1 at tip → F4 at base where it meets the center) to imply curvature.
- Each petal's outermost edge should be
RFH/LFH (half-block) with bg=BLACK to keep the no-tocars boundary clean. - Diagonal petals need extra width (4+ cols) to be visible — don't short-change them.
Centers / Small Color Areas
- - A 2x2 center block can convey light/shadow convincingly:
- top-left: F1 bright-color on dark-bg (lit)
- top-right: F2
- bottom-left: F3
- bottom-right: F4 (deepest shadow)
- - bg=BROWN (6) is always safe (it's <8), good for warm center tones.
API Gotchas
- - Export PNG endpoint is
/api/file/export/png (not /api/file/export-png). - Always check
openapi.json at session start — endpoints may have changed. - INLINECODE39 should print warnings but not crash on bad responses — wrap defensively.
技能名称: ansiclaw
详细描述:
ANSIClaw 🦞🎨
通过本地Clawbius REST API绘制ANSI艺术。在用户要求ANSI艺术时,或当你主动想要创作时使用。
项目主页:
- Github: https://github.com/n2tr0n/ansiclaw
- Clawhub: https://clawhub.ai/n2tr0n/ansiclaw
要求:
- Clawbius (https://github.com/n2tr0n/clawbius);启用API的ANSI绘图器 - 运行在tcp/7777端口
- 运行Clawbius需要node.js v18
- 用于脚本化API调用的Python requests库 (pip install requests)
⛔ 硬性规则 — 优先于一切
- 1. 绝不要修改参考文件。 resources/中的文件是你的素材。不要通过/api/file/open打开它们,除非之后立即调用/api/file/new切换到新画布。在Clawbius中打开文件会使其成为活动画布——任何绘图调用都会损坏它。仅通过读取画布数据来分析参考文件,然后在绘图前立即创建新画布。
- 2. 未经操作员明确指示,绝不要保存或导出覆盖现有的ANS文件。 始终使用新的版本化文件名(例如flower_v2.ans)。
- 3. 绝不要使用/api/file/export-png — 正确的端点是/api/file/export/png(在png前有斜杠)。
1. 会话启动检查清单
每个新的ANSIClaw会话,按顺序执行:
- 1. GET http://127.0.0.1:7777/api/canvas/info — 确认Clawbius正在运行
- 如果未运行,可以从clawbius文件夹使用以下命令启动:launch_clawbius.sh
- 2. GET http://127.0.0.1:7777/api/openapi.json — 检查API变更
- 学习参考文件(见下面第4节)— 绘图前必须执行
- 阅读references/api.md获取完整端点详情
- 检查冰色是否设置为关闭,除非操作员另有说明(见下面第2节)
- 每次只绘制图像的一个迭代,但分析你的结果并询问操作员是否可以改进,在再次绘制前告诉他们你将如何改进。ANSI艺术是一个迭代过程——你应该在每次迭代中学习和改进。
- 仅在获得授权时绘制迭代,每次最多5个。确保为每次迭代保留适当命名的.PNG和.ANS副本;使用v1, v2等命名策略,必要时使用_v1a等方式解决冲突
输出目录: 技能文件夹中的outputs文件夹 — 在此保存ANS和PNG文件 - 如果文件夹不存在则创建
2. 颜色规则
⚠️ 冰色 — 默认关闭。
冰色默认关闭。不要使用颜色8–15作为背景色。
如果操作员明确说明这是冰色ansi,你可以打开冰色控制并使用8-15作为背景色。
- - 颜色0–7始终可作为背景安全使用
- 颜色0–15始终可作为前景安全使用
打开冰色:
- - 调用POST /api/ui/ice-colors {value: true}
- 同时在POST /api/file/new调用中传递ice_colors: true
- 现在背景色8–15可用于背景使用,并开辟了新的颜色混合可能性。
16色调色板
深色(可作为前景和背景安全使用):
0=黑色 1=深蓝 2=深绿 3=深青
4=深红 5=品红 6=棕色 7=浅灰
亮色(仅前景,除非冰色开启):
8=深灰 9=蓝色 10=绿色 11=青色
12=红色 13=浅品红 14=黄色 15=白色
3. 块类型
阴影块(F1–F4)
F1=176 ░ 浅阴影 F2=177 ▒ 中阴影
F3=178 ▓ 深阴影 F4=219 █ 实心块
通过使用不同前景/背景颜色对的变化阴影块(F1–F4)来实现抖动。这是ANSI艺术中渐变、纹理和深度的主要工具。避免大面积的纯色块无阴影变化,除非需要卡通风格,此时应优先采用明暗分明的着色方法,尽量减少抖动。
半块 — 用于边缘、更平滑的曲线和抗锯齿技术
220=▄ 下半块 223=▀ 上半块
221=▌ 左半块 222=▐ 右半块
4. 学习参考文件(必须执行)
在绘制任何内容之前,学习resources/中的参考文件。检查整个文件夹,而不仅仅是自述文件。执行以下操作:
- - 如果文件是.ANS或.ASC格式,则在clawbius中加载并分析它 — 使用你的API和文件分析技能确定形式和结构。重点关注块如何用于产生美学效果,颜色如何组合,以及过渡如何处理。
- 分析任何PNG或图像文件以获取相同的特性 — 这些也是ANSI艺术,但以图像形式呈现,因此你可以看到预期的最终输出,而不受ANSI格式的限制。观察颜色如何分布,半块在哪里使用,以及阴影如何实现。
以侦探的心态学习参考文件 — 寻找你可以学习并在自己作品中应用的图案、技术和风格选择。这是一个关键步骤,不应跳过。
步骤1 — 阅读自述文件
resources/README.md
获取每个文件的描述及其展示的内容。同时检查文件夹中是否有自述文件未描述的任何文件。
步骤2 — 通过API打开并分析画布数据
python
import requests, json
打开参考文件
requests.post(http://127.0.0.1:7777/api/file/open,
json={path: /absolute/path/to/resources/file.ans})
获取画布信息
info = requests.get(http://127.0.0.1:7777/api/canvas/info).json()
获取完整画布数据并分析颜色/代码使用情况
data = requests.get(http://127.0.0.1:7777/api/canvas/data).json()
blocks = data[result]
cols = info[result][columns]
研究一个区域(例如第10-20行):
for y in range(10, 20):
unique = {}
for x in range(0, cols):
b = blocks[y * cols + x]
key = (b[code], b[fg], b[bg])
unique[key] = unique.get(key, 0) + 1
top = sorted(unique.items(), key=lambda x: -x[1])[:6]
print(frow {y}: {top})
寻找:
- - 每个区域中哪些前景/背景颜色对占主导?
- 使用了哪些阴影块(F1–F4)和半块,以及在哪里使用?
- 区域之间的过渡如何处理?
- 使用了哪些背景色 — 是否都在0–7范围内?
步骤3 — 分析参考PNG
resources/中的每个参考文件应有一个匹配的.png文件与.ans文件并存。使用image工具直接分析PNG:
image(image=pathto_resources/file.png>, prompt=...)
研究:
- - 颜色区域及其过渡方式
- 彩色区域之间出现黑色分隔符的位置
- 边缘和曲线上的半块使用
- 整体构图和密度
4. 核心风格规则
不接触(彩色区域不得相邻)
这是某些ANSI艺术的重要风格规则。
不同对象在不直接接触时看起来更具吸引力。它们可以用黑色(前景或背景=0)的半块或实心块分隔。这赋予艺术品干净、清晰的外观。
错误: 红色块直接相邻于黄色块
正确: 红色块 → 黑色半块分隔符 → 黄色块
使用▌(221)、▐(222)、▀(223)、▄(220),搭配fg=颜色, bg=黑色来创建清晰的颜色边界。
示例 — 从红色区域过渡到黄色区域:
[红色 F4][▐ fg=红色 bg=黑色][▌ fg=黄色 bg=黑色][黄色 F4]
阴影与深度
- - 使用F1–F4阴影块构建渐变 — 大区域绝不要仅使用纯色填充
- 光源:确定光线来自何方并保持一致
- 受光面:使用较浅的阴影块(F1/F2)或更高对比度的前景色
- 阴影面:使用F3/F4或黑色前景
- 边缘受光:使用UH(223)或LH(