@botharness/pixel-avatar 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/index.d.ts +77 -5
- package/dist/index.js +1859 -1483
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,5 +18,7 @@ const svg = pixelAvatarSvg(recipe); // 32×32 viewBox, crisp edges, no ids or sc
|
|
|
18
18
|
- `AVATAR_PARTS`, `AVATAR_SWATCHES`, `AVATAR_PRESETS`, `DEFAULT_RECIPE`: everything an editor needs.
|
|
19
19
|
- `isPixelAvatarRecipe`, `canonicalRecipe`: validate and normalise saved recipes.
|
|
20
20
|
- `AVATAR_HAIR_PARTS`, `AVATAR_RANGES`, `detailedRecipe(recipe)`: optional finer controls. A recipe may carry `bangs`, `sideHair`, `backHair`, `spacing`, `height` and `hairLength`, all six or none; `detailedRecipe` derives them from the plain `hair` so an editor can start from what is on screen. Recipes without them render exactly as before.
|
|
21
|
+
- `AVATAR_SPECIES`, `AVATAR_SPECIES_SWATCHES`, `AVATAR_PIECE_COLORS`, `withSpecies(recipe, species)`: Avatar Species (`human`, `goblin`) on the same rig, as asset version 2. `withSpecies` keeps every choice, splits side hair into `sideHair` (left) and `rightSideHair`, and accepts optional `leftSideHairColor`/`rightSideHairColor`, where left and right are as seen on screen. Consumers built before version 2 reject these recipes with `isPixelAvatarRecipe` and can show a saved snapshot instead.
|
|
22
|
+
- `AVATAR_PARTS_V2`, `AVATAR_EXTRA_PARTS`, `hiddenChoices(recipe)`: version 2 adds elf, dwarf, orc and flower species, armor/robe/tunic/cloak outfits, helmet/hood headwear, an optional `beard`, and a flower's `petals` and `flowerBase`. `hiddenChoices` names saved choices the current species or headwear keeps but does not draw, so an editor can say so instead of discarding them.
|
|
21
23
|
- `faceCells`, `pixelSymbolCells`, `symbolArtCells`: pixels for [`@botharness/pixel-morph`](../morph).
|
|
22
24
|
- `pixelAvatarSvg(recipe, { turns, classPrefix })`: optional pre-rendered head turns, and rig layer classes (`<prefix>-body`, `-head`, `-face`, `-gaze`, `-blink`) for CSS animation.
|
package/dist/index.d.ts
CHANGED
|
@@ -30,15 +30,76 @@ type AvatarRange = keyof typeof AVATAR_RANGES;
|
|
|
30
30
|
type AvatarPart = keyof typeof AVATAR_PARTS;
|
|
31
31
|
declare const AVATAR_COLORS: readonly ["skinColor", "hairColor", "eyeColor", "shirtColor"];
|
|
32
32
|
type AvatarColor = (typeof AVATAR_COLORS)[number];
|
|
33
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Avatar Species: a base on the pixel bust rig. Species share motion and anchors; each sets its
|
|
35
|
+
* own ears, face details and suggested body colors. A recipe with a species is asset version 2.
|
|
36
|
+
*/
|
|
37
|
+
declare const AVATAR_SPECIES: readonly ["human", "goblin", "elf", "dwarf", "orc", "flower"];
|
|
38
|
+
type AvatarSpecies = (typeof AVATAR_SPECIES)[number];
|
|
39
|
+
/** Optional per-piece hair colors (asset version 2); an absent piece uses `hairColor`. */
|
|
40
|
+
declare const AVATAR_PIECE_COLORS: readonly ["leftSideHairColor", "rightSideHairColor"];
|
|
41
|
+
type AvatarPieceColor = (typeof AVATAR_PIECE_COLORS)[number];
|
|
42
|
+
/** Part choices that exist only in asset version 2, added after every version 1 choice. */
|
|
43
|
+
declare const AVATAR_PARTS_V2: {
|
|
44
|
+
readonly outfit: readonly ["tee", "shirttie", "hoodie", "turtleneck", "sailor", "blazer", "overalls", "dress", "kimono", "cardigan", "maid", "jacket", "armor", "robe", "tunic", "cloak"];
|
|
45
|
+
readonly accessory: readonly ["none", "beanie", "cap", "headphones", "flower", "bow", "earring", "crown", "halo", "catears", "hairclip", "horns", "beret", "ribbon", "headband", "bunnyears", "horseears", "flowercrown", "witch", "pins", "helmet", "hood"];
|
|
46
|
+
readonly head: readonly ["round", "oval", "square", "long", "heart", "vchin", "chubby", "diamond"];
|
|
47
|
+
readonly pose: readonly ["front", "left", "right"];
|
|
48
|
+
readonly hair: readonly ["crop", "sweep", "spiky", "buzz", "curly", "mohawk", "bob", "long", "bun", "pigtails", "afro", "twintails", "drills", "ponytail", "sidetail", "hime", "odango", "messy", "wavy", "braids", "wolf", "ahoge", "none"];
|
|
49
|
+
readonly eyes: readonly ["round", "dot", "sparkle", "lashes", "sleepy", "happy", "wink", "sharp"];
|
|
50
|
+
readonly brows: readonly ["soft", "thick", "raised", "angry", "worried", "none"];
|
|
51
|
+
readonly nose: readonly ["button", "dot", "line", "none"];
|
|
52
|
+
readonly mouth: readonly ["smile", "grin", "open", "flat", "smirk", "cat", "tongue", "o"];
|
|
53
|
+
readonly cheeks: readonly ["blush", "freckles", "none"];
|
|
54
|
+
readonly glasses: readonly ["none", "round", "square", "shades", "monocle"];
|
|
55
|
+
readonly backdrop: readonly ["sparkles", "hearts", "stars", "dots", "none"];
|
|
56
|
+
};
|
|
57
|
+
/** Optional asset version 2 parts; an absent part is not drawn (or uses the first choice). */
|
|
58
|
+
declare const AVATAR_EXTRA_PARTS: {
|
|
59
|
+
readonly beard: readonly ["short", "full", "braided"];
|
|
60
|
+
readonly petals: readonly ["trumpet", "daisy", "sunflower", "tulip", "sakura"];
|
|
61
|
+
readonly flowerBase: readonly ["leaves", "pot"];
|
|
62
|
+
};
|
|
63
|
+
type AvatarExtraPart = keyof typeof AVATAR_EXTRA_PARTS;
|
|
64
|
+
type Meta = {
|
|
34
65
|
schemaVersion: 1;
|
|
35
66
|
family: 'illustrated';
|
|
36
|
-
assetVersion: 1;
|
|
37
67
|
rigVersion: 1;
|
|
38
|
-
} &
|
|
39
|
-
|
|
68
|
+
} & Record<AvatarColor, string>;
|
|
69
|
+
/** Asset version 1: optional split hair and geometry, all six or none. */
|
|
70
|
+
type PixelAvatarRecipeV1 = Meta & {
|
|
71
|
+
assetVersion: 1;
|
|
72
|
+
} & { [P in AvatarPart]: (typeof AVATAR_PARTS)[P][number] } & { [P in AvatarHairPart]?: (typeof AVATAR_PARTS)['hair'][number] } & { [P in AvatarRange]?: number } & {
|
|
73
|
+
species?: never;
|
|
74
|
+
rightSideHair?: never;
|
|
75
|
+
} & { [P in AvatarPieceColor | AvatarExtraPart]?: never };
|
|
76
|
+
/**
|
|
77
|
+
* Asset version 2: a species, the full split hair and geometry, a separate right side hair
|
|
78
|
+
* (`sideHair` is then the left side) and optional per-side hair colors.
|
|
79
|
+
*/
|
|
80
|
+
type PixelAvatarRecipeV2 = Meta & {
|
|
81
|
+
assetVersion: 2;
|
|
82
|
+
} & { [P in AvatarPart]: (typeof AVATAR_PARTS_V2)[P][number] } & { [P in AvatarHairPart]: (typeof AVATAR_PARTS)['hair'][number] } & { [P in AvatarRange]: number } & {
|
|
83
|
+
species: AvatarSpecies;
|
|
84
|
+
rightSideHair: (typeof AVATAR_HAIR_PARTS)['sideHair'][number];
|
|
85
|
+
} & { [P in AvatarPieceColor]?: string } & { [P in AvatarExtraPart]?: (typeof AVATAR_EXTRA_PARTS)[P][number] };
|
|
86
|
+
type PixelAvatarRecipe = PixelAvatarRecipeV1 | PixelAvatarRecipeV2;
|
|
87
|
+
declare const DEFAULT_RECIPE: PixelAvatarRecipeV1;
|
|
40
88
|
declare function isPixelAvatarRecipe(value: unknown): value is PixelAvatarRecipe;
|
|
41
89
|
declare function canonicalRecipe(recipe: PixelAvatarRecipe): PixelAvatarRecipe;
|
|
90
|
+
/**
|
|
91
|
+
* Saved choices the recipe keeps but does not draw: a flower shows petals and a stem instead of
|
|
92
|
+
* hair, outfit, beard and headwear, and a helmet or hood covers the hair. The choices return when
|
|
93
|
+
* the species or headwear changes back.
|
|
94
|
+
*/
|
|
95
|
+
declare function hiddenChoices(recipe: PixelAvatarRecipe): readonly string[];
|
|
96
|
+
/**
|
|
97
|
+
* Returns the recipe as asset version 2 with the given species, keeping every other choice.
|
|
98
|
+
* Side hair splits into left (`sideHair`) and right (`rightSideHair`) pieces that start equal.
|
|
99
|
+
* When the skin color is one of the previous species' suggested colors, it moves to the new
|
|
100
|
+
* species' first suggestion; a custom color is kept.
|
|
101
|
+
*/
|
|
102
|
+
declare function withSpecies(recipe: PixelAvatarRecipe, species: AvatarSpecies): PixelAvatarRecipeV2;
|
|
42
103
|
declare function detailedRecipe(recipe: PixelAvatarRecipe): PixelAvatarRecipe;
|
|
43
104
|
declare const AVATAR_SWATCHES: Record<AvatarColor, readonly string[]>;
|
|
44
105
|
/**
|
|
@@ -46,8 +107,19 @@ declare const AVATAR_SWATCHES: Record<AvatarColor, readonly string[]>;
|
|
|
46
107
|
* name; the factory takes the name only, so it is safe to pass straight to `Array.map`.
|
|
47
108
|
*/
|
|
48
109
|
declare function createSeededRecipe(namespace: string): (seed: string) => PixelAvatarRecipe;
|
|
110
|
+
/**
|
|
111
|
+
* A version 2 name-seeded recipe factory over every species. Species are equally likely; a
|
|
112
|
+
* person may get a beard or a version 2 outfit, and a flower gets petals and a base. Version 1
|
|
113
|
+
* factories (`createSeededRecipe`) keep their faces, so a consumer chooses per identity which
|
|
114
|
+
* seed version it was created with.
|
|
115
|
+
*/
|
|
116
|
+
declare function createSeededRecipeV2(namespace: string): (seed: string) => PixelAvatarRecipeV2;
|
|
117
|
+
/** Version 2 counterpart of `seededRecipe` (BotHarness's namespace). */
|
|
118
|
+
declare const seededRecipeV2: (seed: string) => PixelAvatarRecipeV2;
|
|
49
119
|
/** The same name always gives the same face (BotHarness's namespace). */
|
|
50
120
|
declare const seededRecipe: (seed: string) => PixelAvatarRecipe;
|
|
121
|
+
/** Suggested body colors per species; any color remains allowed. */
|
|
122
|
+
declare const AVATAR_SPECIES_SWATCHES: Record<AvatarSpecies, readonly string[]>;
|
|
51
123
|
declare const AVATAR_PRESETS: readonly PixelAvatarRecipe[];
|
|
52
124
|
//#endregion
|
|
53
125
|
//#region src/figure.d.ts
|
|
@@ -115,5 +187,5 @@ declare function pixelSymbolCells(symbol: PixelSymbol, color: string): PixelCell
|
|
|
115
187
|
*/
|
|
116
188
|
declare function symbolArtCells(rows: readonly string[], color: string): PixelCell$1[];
|
|
117
189
|
//#endregion
|
|
118
|
-
export { AVATAR_COLORS, AVATAR_HAIR_PARTS, AVATAR_PARTS, AVATAR_PRESETS, AVATAR_RANGES, AVATAR_SWATCHES, AVATAR_TURNS, type AvatarColor, type AvatarHairPart, type AvatarPart, type AvatarRange, DEFAULT_RECIPE, PIXEL_SYMBOLS, type PixelAvatarRecipe, type PixelAvatarSvgOptions, type PixelCell, type PixelFigureOptions, type PixelGrid, type PixelMouthState, type PixelSymbol, canonicalRecipe, createSeededRecipe, detailedRecipe, faceCells, isPixelAvatarRecipe, pixelAvatarSvg, pixelFigure, pixelSymbolCells, pixelTileColor, seededRandom, seededRecipe, symbolArtCells };
|
|
190
|
+
export { AVATAR_COLORS, AVATAR_EXTRA_PARTS, AVATAR_HAIR_PARTS, AVATAR_PARTS, AVATAR_PARTS_V2, AVATAR_PIECE_COLORS, AVATAR_PRESETS, AVATAR_RANGES, AVATAR_SPECIES, AVATAR_SPECIES_SWATCHES, AVATAR_SWATCHES, AVATAR_TURNS, type AvatarColor, type AvatarExtraPart, type AvatarHairPart, type AvatarPart, type AvatarPieceColor, type AvatarRange, type AvatarSpecies, DEFAULT_RECIPE, PIXEL_SYMBOLS, type PixelAvatarRecipe, type PixelAvatarRecipeV1, type PixelAvatarRecipeV2, type PixelAvatarSvgOptions, type PixelCell, type PixelFigureOptions, type PixelGrid, type PixelMouthState, type PixelSymbol, canonicalRecipe, createSeededRecipe, createSeededRecipeV2, detailedRecipe, faceCells, hiddenChoices, isPixelAvatarRecipe, pixelAvatarSvg, pixelFigure, pixelSymbolCells, pixelTileColor, seededRandom, seededRecipe, seededRecipeV2, symbolArtCells, withSpecies };
|
|
119
191
|
//# sourceMappingURL=index.d.ts.map
|