@ragtechdev/pixel-sprites 0.0.1 → 0.9.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.
@@ -0,0 +1,367 @@
1
+ import { T as TileId, a as TileColors, O as ObjectId, C as ColorName, H as HexColor, b as TileSet } from './variant-B_rXsTar.js';
2
+ export { A as ArmPose, c as AvatarConfig, B as BackHairStyle, d as Block, e as BottomStyle, f as CellInfo, g as ClothesColor, h as ColorDepth, E as EyeColor, F as FrontHairStyle, G as GarmentDefinition, i as GarmentLayer, j as GarmentPlacement, k as GarmentSlot, l as HairAccessory, m as HairColor, n as HairDrape, o as HairLayer, p as HairLength, q as HairTexture, r as HeadOrientation, I as ICON_SIZE, s as IconCategory, t as IconColor, u as IconId, v as IconOptions, L as LegPose, P as PalettePreset, w as PieceColorField, x as PlacedObject, R as Ramp, y as ResolvedAvatarConfig, z as RoadTileId, S as ShoeStyle, D as SkinTone, J as TileColor, K as TileColorGroup, M as TileMap, N as TileSetDefinition, Q as TileTheme, U as TiltedMask, V as TopStyle, W as TownTileId, X as VariantOptions, Y as VariantSize, Z as accessoryParts, _ as avatarKey, $ as backHairStyles, a0 as backHairStylesByLength, a1 as backHairStylesFor, a2 as bottomStyles, a3 as buildAvatar, a4 as buildIcon, a5 as buildMap, a6 as clothesPalettes, a7 as colorDepths, a8 as colorRamps, a9 as colorableIconIds, aa as defaultAvatarConfig, ab as defaultTileTheme, ac as defineMap, ad as defineTileSet, ae as eyePalettes, af as frontHairStyles, ag as hairAccessories, ah as hairAccessoryApplies, ai as hairDrapeApplies, aj as hairDrapes, ak as hairLengths, al as hairPalettes, am as hairTextures, an as iconCategories, ao as iconColors, ap as iconIds, aq as idleIconIds, ar as isLooseHair, as as isMiddlePonytail, at as mapTileSize, au as paletteNames, av as palettePresets, aw as parseHex, ax as pieceColorFields, ay as queryCell, az as resolveAvatarConfig, aA as resolveHairLayers, aB as shoeStyles, aC as skinPalettes, aD as textureMask, aE as texturePad, aF as tileAt, aG as tileColorGroups, aH as tilePalettes, aI as tileThemes, aJ as toMapVariant, aK as toVariant, aL as topStyles, aM as variantSizes } from './variant-B_rXsTar.js';
3
+ import { R as Raster } from './compose-BKsBg6Z_.js';
4
+
5
+ declare const tileIds: TileId[];
6
+ /**
7
+ * Returns the (memoised) raster for a built-in tile in a fixed palette
8
+ * (`tileThemes`). Unknown palettes fall back to the default. `colors` recolours
9
+ * groups of that palette with hex colours (`tileColorGroups`).
10
+ */
11
+ declare function buildTile(id: TileId, theme?: string, colors?: TileColors): Raster;
12
+
13
+ /** Pixels per tile side. */
14
+ declare const TILE_SIZE = 16;
15
+
16
+ interface ObjectInfo {
17
+ /** Footprint width in tiles. */
18
+ readonly width: number;
19
+ /** Footprint height in tiles. */
20
+ readonly height: number;
21
+ /** "ground" objects (rugs, flowers) sit under "standing" ones and are drawn first. */
22
+ readonly layer: "ground" | "standing";
23
+ /** One string per tile row. `#` blocks movement, `.` is open. */
24
+ readonly footprint: readonly string[];
25
+ /** A warp, such as a door. */
26
+ readonly door?: true;
27
+ /** Something you can interact across, such as a shop counter. */
28
+ readonly counter?: true;
29
+ }
30
+ declare const objectInfo: Record<ObjectId, ObjectInfo>;
31
+ declare const objectIds: ObjectId[];
32
+ /** The common colours each object can be shown in, replacing its main colour (the paint, leaves, cloth or petals). */
33
+ declare const objectColors: Partial<Record<ObjectId, readonly ColorName[]>>;
34
+ /** The objects with a main colour you can change with `color`. */
35
+ declare const colorableObjectIds: ObjectId[];
36
+ /** The objects whose colours change with the season (the others look the same all year). */
37
+ declare const seasonalObjectIds: ObjectId[];
38
+ /**
39
+ * Returns the (memoised) raster for an object, sized to its tile footprint. Trees and flowers
40
+ * change with the season (`seasonalObjectIds`); `theme` is a season as in `tileThemes`, and
41
+ * unknown values fall back to summer. `color` is one of the object's common colours
42
+ * (`objectColors`) or any hex colour such as `"#e8873a"`; anything else is ignored.
43
+ */
44
+ declare function buildObject(id: ObjectId, theme?: string, color?: ColorName | HexColor): Raster;
45
+
46
+ /** Fixed colour ramps for world objects. Objects can only use these. */
47
+ declare const objectRamps: {
48
+ readonly wood: {
49
+ readonly outline: "#4A2F1D";
50
+ readonly base: "#A8794E";
51
+ readonly shadow: "#7A5434";
52
+ readonly highlight: "#C79A6B";
53
+ };
54
+ readonly wood_light: {
55
+ readonly outline: "#6B4528";
56
+ readonly base: "#C79A6B";
57
+ readonly shadow: "#A8794E";
58
+ readonly highlight: "#E0BC91";
59
+ };
60
+ readonly bark: {
61
+ readonly outline: "#3B2616";
62
+ readonly base: "#7A5434";
63
+ readonly shadow: "#5A3C24";
64
+ readonly highlight: "#9A7048";
65
+ };
66
+ readonly leaf: {
67
+ readonly outline: "#2F4D26";
68
+ readonly base: "#6E9450";
69
+ readonly shadow: "#4F7A3E";
70
+ readonly highlight: "#A8C682";
71
+ };
72
+ readonly glass: {
73
+ readonly outline: "#3F5F70";
74
+ readonly base: "#9CC7DB";
75
+ readonly shadow: "#7FAFC6";
76
+ readonly highlight: "#D6EBF5";
77
+ };
78
+ readonly gold: {
79
+ readonly outline: "#6E5420";
80
+ readonly base: "#E8C557";
81
+ readonly shadow: "#C4A23F";
82
+ readonly highlight: "#F6E39A";
83
+ };
84
+ readonly cloth_red: {
85
+ readonly outline: "#4F1D22";
86
+ readonly base: "#A8474D";
87
+ readonly shadow: "#7F3238";
88
+ readonly highlight: "#C86A70";
89
+ };
90
+ readonly book_blue: {
91
+ readonly outline: "#243A5C";
92
+ readonly base: "#4A6FA5";
93
+ readonly shadow: "#375684";
94
+ readonly highlight: "#7596C8";
95
+ };
96
+ readonly book_red: {
97
+ readonly outline: "#5A2B30";
98
+ readonly base: "#B2555B";
99
+ readonly shadow: "#8A3A40";
100
+ readonly highlight: "#D07A80";
101
+ };
102
+ readonly book_green: {
103
+ readonly outline: "#26402B";
104
+ readonly base: "#5E8B5A";
105
+ readonly shadow: "#456B42";
106
+ readonly highlight: "#85B081";
107
+ };
108
+ readonly flower_red: {
109
+ readonly outline: "#7A2E2A";
110
+ readonly base: "#D9645B";
111
+ readonly shadow: "#B54A44";
112
+ readonly highlight: "#EE8D86";
113
+ };
114
+ readonly flower_yellow: {
115
+ readonly outline: "#7A5E18";
116
+ readonly base: "#E8C557";
117
+ readonly shadow: "#C4A23F";
118
+ readonly highlight: "#F6E39A";
119
+ };
120
+ /** Seasonal ramps: leaf and flower colours for the seasons other than summer. */
121
+ readonly leaf_spring: {
122
+ readonly outline: "#3A5E2C";
123
+ readonly base: "#8DC25B";
124
+ readonly shadow: "#6BA444";
125
+ readonly highlight: "#BEE58A";
126
+ };
127
+ readonly leaf_autumn: {
128
+ readonly outline: "#6B2E14";
129
+ readonly base: "#D2762F";
130
+ readonly shadow: "#A9561F";
131
+ readonly highlight: "#EDA45C";
132
+ };
133
+ readonly leaf_snow: {
134
+ readonly outline: "#5F7280";
135
+ readonly base: "#E3ECEE";
136
+ readonly shadow: "#B9CAD2";
137
+ readonly highlight: "#FFFFFF";
138
+ };
139
+ readonly flower_pink: {
140
+ readonly outline: "#8A3A5E";
141
+ readonly base: "#EE8FB5";
142
+ readonly shadow: "#CC6A93";
143
+ readonly highlight: "#F8BED5";
144
+ };
145
+ readonly flower_white: {
146
+ readonly outline: "#8A8478";
147
+ readonly base: "#FFFFFF";
148
+ readonly shadow: "#E3DCCB";
149
+ readonly highlight: "#FFFFFF";
150
+ };
151
+ readonly flower_orange: {
152
+ readonly outline: "#7A3A12";
153
+ readonly base: "#E58A3C";
154
+ readonly shadow: "#C06A28";
155
+ readonly highlight: "#F4B070";
156
+ };
157
+ readonly flower_rust: {
158
+ readonly outline: "#5A2B18";
159
+ readonly base: "#A8553A";
160
+ readonly shadow: "#84402A";
161
+ readonly highlight: "#C77A5E";
162
+ };
163
+ readonly flower_frost: {
164
+ readonly outline: "#5F7280";
165
+ readonly base: "#EEF4F6";
166
+ readonly shadow: "#C5D6DD";
167
+ readonly highlight: "#FFFFFF";
168
+ };
169
+ readonly flower_ice: {
170
+ readonly outline: "#4F6E86";
171
+ readonly base: "#B7D3E4";
172
+ readonly shadow: "#93B6CD";
173
+ readonly highlight: "#DCEBF4";
174
+ };
175
+ };
176
+ type ObjectRampId = keyof typeof objectRamps;
177
+
178
+ /**
179
+ * Outdoor tileset: grass, paths, water, pavement, building walls and roofs.
180
+ *
181
+ * Block keys:
182
+ * - `g` grass, `t` tall grass, `p` path, `w` water, `s` shore (shore row over a water row), `k` sky
183
+ * - `1`-`9` roof, laid out like a phone keypad:
184
+ * 1 2 3 ridge, with corners
185
+ * 4 5 6 middle
186
+ * 7 8 9 eave, with corners
187
+ * - `<` `=` `>` a roof one block high (ridge over eave: left, middle, right), for small houses
188
+ * - `A`-`I` beige pavement, in the same keypad layout (`E` is the middle,
189
+ * the rest are edges and corners against grass)
190
+ * - `l` `h` `r` wall (left edge, middle, right edge)
191
+ * - `[` `_` `]` wall one block high with its foundation row (left corner, middle, right corner)
192
+ *
193
+ * Trees, fences, flowers, doors and windows are objects placed on top.
194
+ */
195
+ declare const townTileset: TileSet;
196
+
197
+ /**
198
+ * Interior tileset: floor and walls. Block keys: f floor, h wall.
199
+ * Doors, windows, counters, rugs and bookshelves are objects placed on top.
200
+ */
201
+ declare const houseTileset: TileSet;
202
+
203
+ /** Canonical, collision-free cache key for a flat config (key order and undefined values ignored). */
204
+ declare function configKey(config: Readonly<Record<string, string | number | boolean | undefined>>): string;
205
+ interface Cache<T> {
206
+ get(key: string, build: () => T): T;
207
+ clear(): void;
208
+ readonly size: number;
209
+ }
210
+ /** Small LRU cache: build each unique key once, reuse it afterwards. */
211
+ declare function createCache<T>(max?: number): Cache<T>;
212
+
213
+ /** One `<path>` per colour, with horizontal runs merged. Coordinates are in raster pixels. */
214
+ declare function toSvgPaths(raster: Raster): Array<{
215
+ fill: string;
216
+ d: string;
217
+ }>;
218
+ /** Standalone SVG markup, scaled by `scale` CSS pixels per raster pixel. */
219
+ declare function toSvg(raster: Raster, scale?: number): string;
220
+ declare function toSvgDataUrl(raster: Raster, scale?: number): string;
221
+
222
+ /** Fixed colour ramps for icons. Icons can only use these. */
223
+ declare const iconRamps: {
224
+ readonly heart: {
225
+ readonly outline: "#7A2E3A";
226
+ readonly base: "#E0525F";
227
+ readonly shadow: "#B53A4A";
228
+ readonly highlight: "#F4909A";
229
+ };
230
+ readonly cream: {
231
+ readonly outline: "#6B5A48";
232
+ readonly base: "#F7F1E1";
233
+ readonly shadow: "#DDD2BC";
234
+ readonly highlight: "#FFFFFF";
235
+ };
236
+ readonly bread: {
237
+ readonly outline: "#6E4A1E";
238
+ readonly base: "#D79A4A";
239
+ readonly shadow: "#B57A33";
240
+ readonly highlight: "#EDBB78";
241
+ };
242
+ readonly wicker: {
243
+ readonly outline: "#5A3B22";
244
+ readonly base: "#B98A57";
245
+ readonly shadow: "#946A3E";
246
+ readonly highlight: "#D6AB78";
247
+ };
248
+ readonly dove: {
249
+ readonly outline: "#5E6470";
250
+ readonly base: "#EEF0F3";
251
+ readonly shadow: "#C9CED8";
252
+ readonly highlight: "#FFFFFF";
253
+ };
254
+ readonly dove_wing: {
255
+ readonly outline: "#4F5666";
256
+ readonly base: "#A9B2C2";
257
+ readonly shadow: "#8993A6";
258
+ readonly highlight: "#C9D0DB";
259
+ };
260
+ /** Faded versions for a state that is switched off. */
261
+ readonly dove_idle: {
262
+ readonly outline: "#8A8478";
263
+ readonly base: "#E6E2D6";
264
+ readonly shadow: "#D1CBBC";
265
+ readonly highlight: "#F4F1E8";
266
+ };
267
+ readonly dove_wing_idle: {
268
+ readonly outline: "#8A8478";
269
+ readonly base: "#BDB7A8";
270
+ readonly shadow: "#A8A294";
271
+ readonly highlight: "#D0CBBE";
272
+ };
273
+ /** Cream with the same soft outline as the idle bird, for icons that are off or outline-only. */
274
+ readonly cream_soft: {
275
+ readonly outline: "#8A8478";
276
+ readonly base: "#F7F1E1";
277
+ readonly shadow: "#DDD2BC";
278
+ readonly highlight: "#FFFFFF";
279
+ };
280
+ readonly mailbox: {
281
+ readonly outline: "#243A5C";
282
+ readonly base: "#4A6FA5";
283
+ readonly shadow: "#375684";
284
+ readonly highlight: "#7596C8";
285
+ };
286
+ readonly coral: {
287
+ readonly outline: "#7A3E30";
288
+ readonly base: "#E59A82";
289
+ readonly shadow: "#C97C65";
290
+ readonly highlight: "#F2BBA8";
291
+ };
292
+ readonly glass: {
293
+ readonly outline: "#3F5F70";
294
+ readonly base: "#9CC7DB";
295
+ readonly shadow: "#7FAFC6";
296
+ readonly highlight: "#D6EBF5";
297
+ };
298
+ readonly gold: {
299
+ readonly outline: "#6E5420";
300
+ readonly base: "#E8C557";
301
+ readonly shadow: "#C4A23F";
302
+ readonly highlight: "#F6E39A";
303
+ };
304
+ readonly roof: {
305
+ readonly outline: "#5E2F28";
306
+ readonly base: "#B0604A";
307
+ readonly shadow: "#864637";
308
+ readonly highlight: "#CC7E64";
309
+ };
310
+ readonly brick: {
311
+ readonly outline: "#3E2830";
312
+ readonly base: "#8C5A5E";
313
+ readonly shadow: "#6B4548";
314
+ readonly highlight: "#A9787C";
315
+ };
316
+ readonly skin: {
317
+ readonly outline: "#6B4528";
318
+ readonly base: "#E0B08A";
319
+ readonly shadow: "#C2906A";
320
+ readonly highlight: "#F0C9A8";
321
+ };
322
+ readonly cloth_green: {
323
+ readonly outline: "#26402B";
324
+ readonly base: "#5E8B5A";
325
+ readonly shadow: "#456B42";
326
+ readonly highlight: "#85B081";
327
+ };
328
+ readonly ink_blue: {
329
+ readonly outline: "#1F2A44";
330
+ readonly base: "#34507F";
331
+ readonly shadow: "#263B60";
332
+ readonly highlight: "#5A78A8";
333
+ };
334
+ readonly grass: {
335
+ readonly outline: "#2F4D26";
336
+ readonly base: "#6E9450";
337
+ readonly shadow: "#4F7A3E";
338
+ readonly highlight: "#A8C682";
339
+ };
340
+ readonly map_paper: {
341
+ readonly outline: "#6B4528";
342
+ readonly base: "#EAD9B0";
343
+ readonly shadow: "#D2BF93";
344
+ readonly highlight: "#F6EBCB";
345
+ };
346
+ readonly cream_idle: {
347
+ readonly outline: "#8A8478";
348
+ readonly base: "#EFEBDD";
349
+ readonly shadow: "#DCD6C4";
350
+ readonly highlight: "#FAF8F1";
351
+ };
352
+ };
353
+ /** Flat (unshaded) details drawn over a shaded part. */
354
+ declare const iconInk: {
355
+ readonly dark: "#5A3B22";
356
+ readonly eye: "#2B2A26";
357
+ readonly beak: "#E8B04A";
358
+ readonly legs: "#5E6470";
359
+ readonly legs_idle: "#8A8478";
360
+ readonly flap: "#B5A58A";
361
+ readonly flap_idle: "#CFC8B6";
362
+ readonly seal: "#C8505A";
363
+ readonly river: "#6FA3C7";
364
+ readonly path: "#B8996D";
365
+ };
366
+
367
+ export { type Cache, ColorName, HexColor, ObjectId, type ObjectInfo, type ObjectRampId, Raster, TILE_SIZE, TileColors, TileId, TileSet, buildObject, buildTile, colorableObjectIds, configKey, createCache, houseTileset, iconInk, iconRamps, objectColors, objectIds, objectInfo, objectRamps, seasonalObjectIds, tileIds, toSvg, toSvgDataUrl, toSvgPaths, townTileset };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export{fa as ICON_SIZE,E as TILE_SIZE,s as accessoryParts,C as avatarKey,j as backHairStyles,f as backHairStylesByLength,b as backHairStylesFor,m as bottomStyles,D as buildAvatar,la as buildIcon,Z as buildMap,U as buildObject,L as buildTile,w as clothesPalettes,na as colorDepths,N as colorRamps,ia as colorableIconIds,S as colorableObjectIds,x as configKey,y as createCache,A as defaultAvatarConfig,I as defaultTileTheme,V as defineMap,M as defineTileSet,v as eyePalettes,e as frontHairStyles,r as hairAccessories,g as hairAccessoryApplies,d as hairDrapeApplies,c as hairDrapes,a as hairLengths,u as hairPalettes,o as hairTextures,$ as houseTileset,ka as iconCategories,ga as iconColors,ha as iconIds,ea as iconInk,da as iconRamps,ja as idleIconIds,i as isLooseHair,h as isMiddlePonytail,W as mapTileSize,R as objectColors,Q as objectIds,P as objectInfo,O as objectRamps,pa as paletteNames,oa as palettePresets,F as parseHex,z as pieceColorFields,Y as queryCell,B as resolveAvatarConfig,k as resolveHairLayers,T as seasonalObjectIds,n as shoeStyles,t as skinPalettes,q as textureMask,p as texturePad,X as tileAt,J as tileColorGroups,K as tileIds,G as tilePalettes,H as tileThemes,ra as toMapVariant,ba as toSvg,ca as toSvgDataUrl,aa as toSvgPaths,qa as toVariant,l as topStyles,_ as townTileset,ma as variantSizes}from'./chunk-EBLUZDCC.js';
@@ -0,0 +1,39 @@
1
+ import * as react from 'react';
2
+ import { c as AvatarConfig, X as VariantOptions, v as IconOptions, u as IconId, T as TileId, Q as TileTheme, a as TileColors, M as TileMap, O as ObjectId, C as ColorName, H as HexColor } from './variant-B_rXsTar.js';
3
+ import { R as Raster } from './compose-BKsBg6Z_.js';
4
+
5
+ type ImageProps = VariantOptions & {
6
+ pixelSize?: number;
7
+ className?: string;
8
+ title?: string;
9
+ };
10
+ /** Renders a raster as SVG (one path per colour). */
11
+ declare function PixelImage({ raster: source, pixelSize, className, title, size, bits, palette }: ImageProps & {
12
+ raster: Raster;
13
+ }): react.JSX.Element;
14
+ type AvatarProps = AvatarConfig & ImageProps;
15
+ declare function Avatar({ pixelSize, className, title, size, bits, palette, ...config }: AvatarProps): react.JSX.Element;
16
+ declare function Tile({ id, theme, colors, ...rest }: ImageProps & {
17
+ id: TileId;
18
+ theme?: TileTheme;
19
+ colors?: TileColors;
20
+ }): react.JSX.Element;
21
+ declare function Icon({ id, idle, color, ...rest }: ImageProps & IconOptions & {
22
+ id: IconId;
23
+ }): react.JSX.Element;
24
+ declare function WorldObject({ id, theme, color, ...rest }: ImageProps & {
25
+ id: ObjectId;
26
+ theme?: TileTheme;
27
+ color?: ColorName | HexColor;
28
+ }): react.JSX.Element;
29
+ /**
30
+ * A whole map. `buildMap` memoises per map object, so keep the `map` reference stable.
31
+ * `size` is the pixels per tile (8 or 16), not the size of the whole map.
32
+ */
33
+ declare function World({ map, theme, colors, size, bits, palette, ...rest }: ImageProps & {
34
+ map: TileMap;
35
+ theme?: TileTheme;
36
+ colors?: TileColors;
37
+ }): react.JSX.Element;
38
+
39
+ export { Avatar, type AvatarProps, Icon, PixelImage, Tile, World, WorldObject };
package/dist/react.js ADDED
@@ -0,0 +1 @@
1
+ import {y,qa,aa,C,D,L,la,U,ra,Z}from'./chunk-EBLUZDCC.js';import {useMemo}from'react';import {jsx}from'react/jsx-runtime';var P=y(512);function p({raster:t,pixelSize:r=4,className:a,title:e,size:l,bits:n,palette:s}){let o=qa(t,{size:l,bits:n,palette:s}),v=useMemo(()=>aa(o),[o]);return jsx("svg",{className:a,width:o.width*r,height:o.height*r,viewBox:`0 0 ${o.width} ${o.height}`,shapeRendering:"crispEdges",style:{display:"block",imageRendering:"pixelated"},role:e?"img":void 0,"aria-label":e,"aria-hidden":e?void 0:true,children:v.map(d=>jsx("path",{fill:d.fill,d:d.d},d.fill))})}function A({pixelSize:t,className:r,title:a,size:e,bits:l,palette:n,...s}){let o=P.get(C(s),()=>D(s));return jsx(p,{raster:o,pixelSize:t,className:r,title:a,size:e,bits:l,palette:n})}function M({id:t,theme:r,colors:a,...e}){return jsx(p,{raster:L(t,r,a),...e})}function N({id:t,idle:r,color:a,...e}){return jsx(p,{raster:la(t,{idle:r,color:a}),...e})}function R({id:t,theme:r,color:a,...e}){return jsx(p,{raster:U(t,r,a),...e})}function w({map:t,theme:r,colors:a,size:e,bits:l,palette:n,...s}){return jsx(p,{raster:ra(Z(t,r,a),{size:e,bits:l,palette:n}),...s})}export{A as Avatar,N as Icon,p as PixelImage,M as Tile,w as World,R as WorldObject};