Skip to content

feat(avatar): Human-drawn Custom Parts in a headpiece slot (asset version 3) - #11

Merged
DoodleBears merged 1 commit into
mainfrom
claude/festive-gauss-gv7xu2
Oct 8, 2026
Merged

DoodleBears merged 1 commit into
mainfrom
claude/festive-gauss-gv7xu2

Conversation

@DoodleBears

@DoodleBears DoodleBears commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This is the BotPixel half of BotHarness/DeepSeekBot#1211 (ADR-0148, Q7, Q15, Q16, Q22–Q24). BotPixel owns the part data, validation, rendering and drawing algorithms; DeepSeekBot will own the Part Library, the editor and import/export.

PixelCustomPart: { slot: 'headpiece', front, back }

  • Slot: the headpiece covers the top 32×16 of the tile, in tile coordinates, so the Avatar centerline is between x 15 and 16.
  • Cells: each is [x, y, color, tone].
    • color is an appearance color slot (hairColor, skinColor, eyeColor, shirtColor), so the part recolors with the Avatar, or a fixed #rrggbb.
    • tone is a step from −2 to +2 on the rig's shade ramp (partToneColor).
  • Validation (isPixelCustomPart): cells must be inside the slot, unique and well-typed; at most 16 fixed colors; no extra keys.
  • Identity (customPartId): the SHA-256 of the canonical content (cells in row order, lowercase fixed colors). Name, author, origin and parent are left to the consumer's library.

Rendering

  • The back layer is drawn behind the hair and the front layer over it. Front cells are kept out of hair shading, so a part keeps its own tones.
  • Both layers follow the head through turns. On a strong turn, far-side cells more than 5 columns from the centerline pull one column inward.
  • The part sits on the head layer, so head motion animates it too.

Recipes

  • withHeadpiece(recipe, part) embeds a canonical copy as asset version 3, and withHeadpiece(recipe, undefined) takes it off (back to version 2).
  • withSpecies keeps version 3.
  • Consumers built before this release reject version 3 recipes through isPixelAvatarRecipe, so they can fall back to a saved snapshot.

Drawing algorithms (dense layers)

  • paintPartLayer covers pencil and eraser strokes.
  • fillPartLayer is a 4-connected flood fill.
  • mirrorPartX mirrors across the centerline; both helpers take a mirror flag.
  • partLayer / partCells / createCustomPart convert between drawn layers and parts.

The version goes to 0.5.0.

Verification

  • pnpm verify passes: format, lint, typecheck and 68 tests.
  • botharness-golden.json, species-golden.json and species-more-golden.json are unchanged.
  • New custom-part.test.ts:
    • validation bounds (slot edges, non-integers, unknown color slots, short hex, tone range, duplicate cells, extra keys, fixed-color limit);
    • content-hash stability across cell order and hex case, checked against Node's SHA-256;
    • mirror axis for paint and erase;
    • flood fill stopping at a ring, not crossing diagonals, recoloring a region, and mirrored fills;
    • asset version 3 validation and canonicalisation;
    • the front layer over the hair recoloring with it; the back layer hidden behind hair and visible when bald;
    • following a turn; removing the part restoring the identical render; speech mouth layers kept;
    • a new custom-part-golden.json.
  • Visual check at 4×, front and three turns: a fixed-gold crown (front layer) on a human and a goblin, and hair-colored bunny ears (back layer) on a white-haired human and a pink-haired elf.

After merge, release 0.5.0 for DeepSeekBot.

Refs BotHarness/DeepSeekBot#1211 · Agent-Task: claude/cloud/session_01MozvQ2eMvqX1MzSqm9G2o8

🤖 Generated with Claude Code

https://claude.ai/code/session_01MozvQ2eMvqX1MzSqm9G2o8


Generated by Claude Code

Summary by CodeRabbit

  • New Features
    • Added customizable pixel-art headpieces with front and back layers, turn-aware rendering, and colors linked to appearance slots or set directly.
    • Added drawing tools for creating, filling, and mirroring custom parts.
    • Added support for saving headpieces in avatar recipes. Recipes with headpieces require a newer asset version; earlier recipes continue to render unchanged.
  • Documentation
    • Added guidance on creating and using custom headpieces.

…sion 3)

A PixelCustomPart has a back layer drawn behind the hair and a front layer
over it. Cells reference an appearance color slot or a fixed color plus a
tone step, so a part recolors with the Avatar and follows head turns.
withHeadpiece embeds a canonical copy as asset version 3; customPartId is
a SHA-256 of the canonical content. paintPartLayer, fillPartLayer
(4-connected) and mirrorPartX provide the drawing algorithms. Existing
golden output is unchanged.

Refs: BotHarness/DeepSeekBot#1211
Agent-Task: claude/cloud/session_01MozvQ2eMvqX1MzSqm9G2o8
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MozvQ2eMvqX1MzSqm9G2o8
@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0904650c-b394-403e-a202-c626737026ee
📥 Commits

Reviewing files that changed from the base of the PR and between c89ff86 and a7e6d27.

📒 Files selected for processing (9)
  • CHANGELOG.md
  • packages/avatar/README.md
  • packages/avatar/package.json
  • packages/avatar/src/figure.ts
  • packages/avatar/src/index.ts
  • packages/avatar/src/part.ts
  • packages/avatar/src/recipe.ts
  • packages/avatar/test/custom-part.test.ts
  • packages/avatar/test/fixtures/custom-part-golden.json
 _______________________________________
< r/CodeReview: Where I'm the top post. >
 ---------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copy link
Copy Markdown
Contributor Author

@coderabbitai review


Generated by Claude Code

@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Pull request base or head changed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@DoodleBears
DoodleBears merged commit 423aa2d into main Oct 8, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants