Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Pixel Avatars can be an elf, dwarf, orc or talking flower with beards, medieval

### Added

- Every other part can be drawn as well: outfit, accessory, beard, glasses, nose, cheeks, petals and flower base each offer **Draw or edit this piece**, starting from the style you wear. Pixels in an appearance color stay recolorable. A drawn face part never covers the speaking mouth. Drawn parts hide where the species or headwear hides the built-in part, and **Back to the built-in style** restores your choice. Picking a built-in style no longer upgrades an older Avatar's recipe unless a drawn part is being taken off ([#1240](https://github.com/BotHarness/DeepSeekBot/issues/1240)).
- Hair pieces can be drawn too: open bangs, left or right side hair or back hair and start from the style you wear, flattened to pixels. Reshape it with the same tools, save it to the Part Library and wear it in that slot. The drawn hair is shaded and recolored like built-in hair, turns with the head and hides under helmets, hoods and on flowers. **Back to the built-in style** restores your original choice ([#1238](https://github.com/BotHarness/DeepSeekBot/issues/1238)).
- You can draw your own headpiece for a pixel Avatar: pencil, eraser, fill, mirroring across the face, a front layer over the hair and a back layer behind it, undo and redo, and a 1× preview on the real Avatar. Colors can follow the Avatar's hair, skin, eye or outfit color in five tones, or be fixed. Saved parts go into a Part Library in your Profile and can be worn by any PersonaBot. The worn copy turns and speaks with the Window Companion and travels with an exported Bot, and editing a library part saves a new part without changing Avatars that already wear the old one ([#1211](https://github.com/BotHarness/DeepSeekBot/issues/1211)).
- Pixel Avatars can be an elf, dwarf, orc or talking flower. Beards always leave the speaking mouth visible. Armor, robe, tunic and cloak outfits are available, and a helmet or hood hides the hair underneath. Flowers have bead eyes, five petal styles and a stem or pot. Choices a species or headwear doesn't show stay saved, with a note, and return when switched back ([#1212](https://github.com/BotHarness/DeepSeekBot/issues/1212), [#1213](https://github.com/BotHarness/DeepSeekBot/issues/1213)).
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

### Added

- 其他部件也都能自己画了:衣服、配饰、胡子、眼镜、鼻子、腮红、花瓣和花盆都有 **绘制/修改这一片**,从当前戴的样式开始;外形颜色的像素仍会跟着变色;自绘的脸部部件不会挡住说话的嘴;物种或头饰隐藏内置部件时,自绘部件也会隐藏;**换回内置样式** 可恢复原来的选择。只有在取下自绘部件时,选内置样式才会升级旧头像的 recipe([#1240](https://github.com/BotHarness/DeepSeekBot/issues/1240))。
- 头发也能自己画了:在前发、左右侧发或后发里,从当前戴的样式开始(压平成像素),用同样的工具改形状,存进部件库并戴在这个位置。自绘头发会像内置头发一样上阴影、跟着发色变色、随头部转动,戴头盔/兜帽或变成花朵时会隐藏。点 **换回内置样式** 可恢复原来的选择([#1238](https://github.com/BotHarness/DeepSeekBot/issues/1238))。
- 可以为像素头像自己画头饰:铅笔、橡皮、填充、沿脸部中线镜像,前层盖在头发上、后层在头发后面,支持撤销重做,并在真实头像上显示 1× 预览。颜色可以跟随头像的发色、肤色、眼睛或衣服颜色(五档明暗),也可以是固定色。保存的部件进入 Profile 里的部件库,任何 PersonaBot 都能戴上;戴上的副本会在窗口伙伴里随头部转动和说话,并随导出的 Bot 一起带走;修改库里的部件会另存为新部件,不会改变已经戴着旧部件的头像([#1211](https://github.com/BotHarness/DeepSeekBot/issues/1211))。
- 像素头像新增精灵、矮人、兽人和会说话的花。胡子始终露出说话的嘴,新增盔甲、法袍、束腰外衣和斗篷,戴上头盔或兜帽会遮住下面的头发。花有豆豆眼、五种花瓣样式,以及茎叶或花盆。当前物种或头饰不显示的选择会保留并给出提示,换回后恢复([#1212](https://github.com/BotHarness/DeepSeekBot/issues/1212)、[#1213](https://github.com/BotHarness/DeepSeekBot/issues/1213))。
Expand Down
21 changes: 21 additions & 0 deletions docs/assets/pr/1240-drawn-parts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# #1240 Draw every other part starting from the built-in style

Captured on an isolated DSH instance built from this branch with `@botharness/pixel-avatar` 0.7.0 (BotHarness/BotPixel#15).

| Outfit flattened from the worn sailor outfit | Gold badges and a darker hem drawn in |
| -------------------------------------------- | --------------------------------------------- |
| ![outfit start](outfit-start-en-light.webp) | ![outfit edited](outfit-edited-en-light.webp) |

| Round glasses flattened | Lenses filled pink |
| --------------------------------------------- | ----------------------------------------------- |
| ![glasses start](glasses-start-en-light.webp) | ![glasses edited](glasses-edited-en-light.webp) |

| Shirt color recolors the shirt-colored pixels of the drawn outfit | Window Companion speaking (simulated) |
| ----------------------------------------------------------------- | ----------------------------------------- |
| ![recolor](parts-recolor-en-light.webp) | ![speaking](parts-speaking-en-light.webp) |

The speech is simulated: a test script drives the companion's own mouth layers, and no model reply was involved.

![full flow](drawn-parts-flow.gif)

Video: [drawn-parts-flow.mp4](drawn-parts-flow.mp4)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 27 additions & 15 deletions packages/client/src/client/avatar-appearance-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import {
wornAvatarPart,
hairPieceStart,
isHairPartSlot,
isReplacePartSlot,
replacePartStart,
type PartSlot,
customPartId,
type PixelCustomPart,
Expand Down Expand Up @@ -131,12 +133,14 @@ const PART_CATEGORY: Partial<Record<string, PartSlot>> = {
sideHair: 'leftSideHair',
rightSideHair: 'rightSideHair',
backHair: 'backHair',
};
const PIECE_CATEGORY: Record<string, string> = {
bangs: 'bangs',
leftSideHair: 'sideHair',
rightSideHair: 'rightSideHair',
backHair: 'backHair',
outfit: 'outfit',
accessory: 'accessory',
beard: 'beard',
glasses: 'glasses',
nose: 'nose',
cheeks: 'cheeks',
petals: 'petals',
flowerBase: 'flowerBase',
};
const V2_ONLY = (part: string, value: string | number) =>
(part === 'outfit' || part === 'accessory') &&
Expand Down Expand Up @@ -357,7 +361,7 @@ export function AvatarAppearanceEditor({
const builtIn = (key: string, value: string): AvatarRecipe => {
const next = withPart(draft!, key, value);
const slot = PART_CATEGORY[key];
return slot && next.family === 'illustrated'
return slot && next.family === 'illustrated' && wornAvatarPart(next, slot)
? withAvatarCustomPart(next, slot, undefined)
: next;
};
Expand Down Expand Up @@ -396,7 +400,7 @@ export function AvatarAppearanceEditor({
) : null;
const partActions = (slot: PartSlot, recipe: IllustratedAvatarRecipe) => {
const worn = wornAvatarPart(recipe, slot);
const hair = isHairPartSlot(slot);
const hair = isHairPartSlot(slot) || isReplacePartSlot(slot);
const own = (parts ?? []).filter((entry) => entry.part.slot === slot);
const draw = () =>
setDrawing(
Expand All @@ -405,15 +409,23 @@ export function AvatarAppearanceEditor({
slot,
base: withAvatarCustomPart(recipe, slot, undefined),
restore: recipe,
backdrop: withPart(
withAvatarCustomPart(recipe, slot, undefined),
PIECE_CATEGORY[slot]!,
'none',
) as IllustratedAvatarRecipe,
initial: hairPieceStart(recipe, slot),
backdrop: withAvatarCustomPart(recipe, slot, {
slot,
front: [],
back: [],
}) as IllustratedAvatarRecipe,
initial: isHairPartSlot(slot)
? hairPieceStart(recipe, slot)
: replacePartStart(recipe, slot as Parameters<typeof replacePartStart>[1]),
...(worn
? { parent: customPartId(worn) }
: { note: t('profile.avatar.part.flattenNote') }),
: {
note: t(
isHairPartSlot(slot)
? 'profile.avatar.part.flattenNote'
: 'profile.avatar.part.flattenPartNote',
),
}),
}
: { slot, base: recipe, restore: recipe },
);
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/client/custom-part-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function CustomPartEditor({
t: BotHarnessTranslate;
}): ReactElement {
const { width: W, height: H } = PART_SLOTS[slot];
const hair = isHairPartSlot(slot);
const hair = slot !== 'headpiece';
const [layers, setLayers] = useState<Layers>(() => ({
front: initial ? partLayer(slot, initial.front) : emptyPartLayer(slot),
back: initial ? partLayer(slot, initial.back) : emptyPartLayer(slot),
Expand Down
3 changes: 3 additions & 0 deletions packages/client/src/client/locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1759,6 +1759,7 @@ export const zh = {
'profile.avatar.part.drawPiece': '绘制/修改这一片',
'profile.avatar.part.removePiece': '换回内置样式',
'profile.avatar.part.flattenNote': '从当前样式开始:画好后形状固定,不再跟随脸型和发长变化。',
'profile.avatar.part.flattenPartNote': '从当前样式开始:画好后形状固定,不再跟随脸型或物种变化。',
'profile.avatar.leftSideHairColor': '左侧发色',
'profile.avatar.rightSideHairColor': '右侧发色',
'profile.avatar.followHairColor': '跟随发色',
Expand Down Expand Up @@ -4325,6 +4326,8 @@ My relationship with you, established lore and topics to avoid: [fill in].
'profile.avatar.part.removePiece': 'Back to the built-in style',
'profile.avatar.part.flattenNote':
'Starting from the current style. The drawn piece keeps this shape and no longer follows face shape or hair length.',
'profile.avatar.part.flattenPartNote':
'Starting from the current style. The drawn part keeps this shape and no longer adapts to face shape or species.',
'profile.avatar.leftSideHairColor': 'Left side hair color',
'profile.avatar.rightSideHairColor': 'Right side hair color',
'profile.avatar.followHairColor': 'Follow hair color',
Expand Down
63 changes: 63 additions & 0 deletions packages/client/test/avatar-appearance-editor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
canonicalCustomPart,
customPartId,
hairPieceStart,
replacePartStart,
type PixelCustomPart,
} from '../../core/src/bots/avatar-appearance.js';
import type { PartLibraryEntry } from '../../core/src/bots/part-library.js';
Expand Down Expand Up @@ -642,6 +643,68 @@ describe('Profile Avatar Appearance editing', () => {
}
});

it('draws an outfit from the built-in style and switches back', async () => {
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
const save = vi.fn(async () => true);
const add = vi.fn(async (part: PixelCustomPart, name: string): Promise<PartLibraryEntry> => ({
id: customPartId(part),
part: canonicalCustomPart(part),
name,
origins: ['drawn'],
addedAt: '',
}));
const container = document.createElement('div');
document.body.append(container);
const root = createRoot(container);
const bot = {
slug: 'ada',
displayName: 'Ada',
roles: [],
aggregateState: 'idle',
workspaces: [],
createdAt: '',
};
const $ = (selector: string) => container.querySelector<HTMLElement>(selector);
const click = async (selector: string) => act(() => $(selector)!.click());
const start = replacePartStart(seededAvatarRecipe('Ada'), 'outfit');
const [x, y, color, tone] = start.front[0]!;
try {
await act(() =>
root.render(
createElement(AvatarAppearanceEditor, {
bot,
channelId: 'dm-ada',
onSave: save,
library: { load: vi.fn(async () => []), add },
t: zhTranslate,
}),
),
);
await click('[data-avatar-edit]');
await click('[data-avatar-category="outfit"]');
await click('[data-part-draw="outfit"]');
expect($('[data-part-note]')?.textContent).toBe(
zhTranslate('profile.avatar.part.flattenPartNote'),
);
expect($('[data-part-layer="back"]')).toBeNull();
expect($(`[data-part-cell="${x},${y}"]`)?.getAttribute('data-part-ink')).toBe(
`${color}:${tone}`,
);
await click('[data-part-save]');
const [part] = add.mock.calls[0]!;
expect(part.slot).toBe('outfit');
expect(part.front).toHaveLength(start.front.length);
await click('[data-avatar-save]');
expect(save).toHaveBeenCalledWith(
'dm-ada',
expect.objectContaining({ assetVersion: 3, outfitPart: canonicalCustomPart(part) }),
);
} finally {
await act(() => root.unmount());
container.remove();
}
});

it('retries loading the Part Library after a failed load', async () => {
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
const load = vi
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"./package.json": "./package.json"
},
"dependencies": {
"@botharness/pixel-avatar": "0.6.0",
"@botharness/pixel-avatar": "0.7.0",
"@botharness/pixel-banner": "0.1.0",
"@resvg/resvg-js": "2.6.2",
"silk-wasm": "3.7.1"
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/bots/avatar-appearance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ export {
withCustomPart as withAvatarCustomPart,
wornPart as wornAvatarPart,
hairPieceStart,
replacePartStart,
REPLACE_PART_SLOTS,
isReplacePartSlot,
type ReplacePartSlot,
HAIR_PART_SLOTS,
isHairPartSlot,
type HairPartSlot,
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ minimumReleaseAgeExclude:
- '@deepseek-ai/dsh-experimental-schedule-bundle@0.2.0-rc.1'
- '@deepseek-ai/dsh-host-product-telemetry-otel@0.2.0-rc.1'
- '@deepseek-ai/dsh-otel@0.2.0-rc.1'
- '@botharness/pixel-avatar@0.1.0 || 0.2.0 || 0.3.0 || 0.4.0 || 0.5.0 || 0.6.0'
- '@botharness/pixel-avatar@0.1.0 || 0.2.0 || 0.3.0 || 0.4.0 || 0.5.0 || 0.6.0 || 0.7.0'
- '@botharness/pixel-banner@0.1.0'
- '@botharness/pixel-morph@0.1.0 || 0.2.0'

Expand Down
Loading