invadrs 0.1.0 → 0.2.1
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/{chunk-5SOVCTHT.js → chunk-PFORKP7K.js} +229 -41
- package/dist/index.cjs +229 -41
- package/dist/index.d.cts +6 -4
- package/dist/index.d.ts +6 -4
- package/dist/index.js +1 -1
- package/dist/react/index.cjs +229 -41
- package/dist/react/index.js +1 -1
- package/package.json +22 -5
package/README.md
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
Deterministic space-invaders-style pixel avatars from any string. Zero
|
|
4
4
|
dependencies. Same id in, same avatar out, forever.
|
|
5
5
|
|
|
6
|
+
**[🕹 Live demo & Storybook →](https://invadrs.pages.dev)**
|
|
7
|
+
|
|
6
8
|

|
|
7
9
|
|
|
8
10
|
```ts
|
|
@@ -20,8 +20,8 @@ var palettes = {
|
|
|
20
20
|
ocean: { colors: ["#1d3557", "#2a9d8f", "#48cae4", "#56e39f", "#4361ee", "#7bdff2"] },
|
|
21
21
|
// greens and earth — pine, leaf, lime-olive, fern, bark, tan
|
|
22
22
|
forest: { colors: ["#386641", "#6a994e", "#a7c957", "#588157", "#b08968", "#dda15e"] },
|
|
23
|
-
// grayscale
|
|
24
|
-
mono: { colors: ["#
|
|
23
|
+
// grayscale — mid greys, 6 distinct, legible on both light and dark backgrounds
|
|
24
|
+
mono: { colors: ["#a8a8a8", "#969696", "#848484", "#727272", "#606060", "#545454"] }
|
|
25
25
|
};
|
|
26
26
|
var CSS_VARS = {
|
|
27
27
|
colors: ["var(--accent)", "var(--green)", "var(--amber)", "var(--purple)", "var(--cyan)", "var(--red)"]
|
|
@@ -76,48 +76,236 @@ function dataUri(svg) {
|
|
|
76
76
|
|
|
77
77
|
// src/invadr.ts
|
|
78
78
|
var INVADR_SPRITES = [
|
|
79
|
-
[
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
[
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
[
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
79
|
+
[
|
|
80
|
+
// squid
|
|
81
|
+
"...#...#...",
|
|
82
|
+
"....#.#....",
|
|
83
|
+
"...#####...",
|
|
84
|
+
"..#######..",
|
|
85
|
+
".##.###.##.",
|
|
86
|
+
"###########",
|
|
87
|
+
"###########",
|
|
88
|
+
".#.#####.#.",
|
|
89
|
+
"..#.....#..",
|
|
90
|
+
".#..#.#..#.",
|
|
91
|
+
"#...#.#...#"
|
|
92
|
+
],
|
|
93
|
+
[
|
|
94
|
+
// crab
|
|
95
|
+
"#....#....#",
|
|
96
|
+
".#...#...#.",
|
|
97
|
+
"..#######..",
|
|
98
|
+
".#########.",
|
|
99
|
+
"###.###.###",
|
|
100
|
+
"###########",
|
|
101
|
+
"###########",
|
|
102
|
+
"#.#######.#",
|
|
103
|
+
"#.#.....#.#",
|
|
104
|
+
"...#...#...",
|
|
105
|
+
"..##...##.."
|
|
106
|
+
],
|
|
107
|
+
[
|
|
108
|
+
// octopus
|
|
109
|
+
"..#######..",
|
|
110
|
+
".#########.",
|
|
111
|
+
"###########",
|
|
112
|
+
"##.#####.##",
|
|
113
|
+
"##.#####.##",
|
|
114
|
+
"###########",
|
|
115
|
+
".#.#.#.#.#.",
|
|
116
|
+
".#.#.#.#.#.",
|
|
117
|
+
".#.#.#.#.#.",
|
|
118
|
+
"#..#.#.#..#",
|
|
119
|
+
"#..#.#.#..#"
|
|
120
|
+
],
|
|
121
|
+
[
|
|
122
|
+
// beetle
|
|
123
|
+
"#..#...#..#",
|
|
124
|
+
".#.#...#.#.",
|
|
125
|
+
"..#######..",
|
|
126
|
+
".####.####.",
|
|
127
|
+
"###########",
|
|
128
|
+
"###.###.###",
|
|
129
|
+
"###########",
|
|
130
|
+
"###########",
|
|
131
|
+
".#########.",
|
|
132
|
+
"..#.....#..",
|
|
133
|
+
".#.......#."
|
|
134
|
+
],
|
|
135
|
+
[
|
|
136
|
+
// bunny
|
|
137
|
+
"..#.....#..",
|
|
138
|
+
"..#.....#..",
|
|
139
|
+
"..#.#.#.#..",
|
|
140
|
+
"..#######..",
|
|
141
|
+
".#########.",
|
|
142
|
+
".##.###.##.",
|
|
143
|
+
".#########.",
|
|
144
|
+
".#########.",
|
|
145
|
+
"..#######..",
|
|
146
|
+
"..#.....#..",
|
|
147
|
+
".##.....##."
|
|
148
|
+
],
|
|
149
|
+
[
|
|
150
|
+
// cat
|
|
151
|
+
".#.......#.",
|
|
152
|
+
".##.....##.",
|
|
153
|
+
".#########.",
|
|
154
|
+
"###.###.###",
|
|
155
|
+
"#####.#####",
|
|
156
|
+
"###########",
|
|
157
|
+
"###########",
|
|
158
|
+
"#.#######.#",
|
|
159
|
+
"..#######..",
|
|
160
|
+
"...#...#...",
|
|
161
|
+
"..#.....#.."
|
|
162
|
+
],
|
|
163
|
+
[
|
|
164
|
+
// ghost
|
|
165
|
+
"...#####...",
|
|
166
|
+
"..#######..",
|
|
167
|
+
".#########.",
|
|
168
|
+
".##.###.##.",
|
|
169
|
+
"###########",
|
|
170
|
+
"###########",
|
|
171
|
+
"###########",
|
|
172
|
+
"###########",
|
|
173
|
+
"###########",
|
|
174
|
+
"#.##.#.##.#",
|
|
175
|
+
"#..#.#.#..#"
|
|
176
|
+
],
|
|
177
|
+
[
|
|
178
|
+
// skull
|
|
179
|
+
"...#####...",
|
|
180
|
+
"..#######..",
|
|
181
|
+
".#########.",
|
|
182
|
+
"###########",
|
|
183
|
+
"##..###..##",
|
|
184
|
+
"##..###..##",
|
|
185
|
+
"###########",
|
|
186
|
+
".#########.",
|
|
187
|
+
".#.#.#.#.#.",
|
|
188
|
+
".#########.",
|
|
189
|
+
"..#.....#.."
|
|
190
|
+
],
|
|
191
|
+
[
|
|
192
|
+
// robot
|
|
193
|
+
"....#.#....",
|
|
194
|
+
"...#####...",
|
|
195
|
+
"..#######..",
|
|
196
|
+
".##.###.##.",
|
|
197
|
+
".#########.",
|
|
198
|
+
".#.#.#.#.#.",
|
|
199
|
+
".#########.",
|
|
200
|
+
"..#######..",
|
|
201
|
+
"..#.....#..",
|
|
202
|
+
"..#.....#..",
|
|
203
|
+
".##.....##."
|
|
204
|
+
],
|
|
205
|
+
[
|
|
206
|
+
// horned
|
|
207
|
+
"#.........#",
|
|
208
|
+
"##.......##",
|
|
209
|
+
".##.....##.",
|
|
210
|
+
"..#######..",
|
|
211
|
+
".##.###.##.",
|
|
212
|
+
".#########.",
|
|
213
|
+
"..#######..",
|
|
214
|
+
"..#######..",
|
|
215
|
+
"...#...#...",
|
|
216
|
+
"..#.....#..",
|
|
217
|
+
".##.....##."
|
|
218
|
+
],
|
|
219
|
+
[
|
|
220
|
+
// smiley
|
|
221
|
+
"..#######..",
|
|
222
|
+
".#########.",
|
|
223
|
+
"###########",
|
|
224
|
+
"##.#####.##",
|
|
225
|
+
"###########",
|
|
226
|
+
"###########",
|
|
227
|
+
"#.#.###.#.#",
|
|
228
|
+
"##.#####.##",
|
|
229
|
+
".#########.",
|
|
230
|
+
"..#######..",
|
|
231
|
+
"..##...##.."
|
|
232
|
+
],
|
|
233
|
+
[
|
|
234
|
+
// owl
|
|
235
|
+
"##.......##",
|
|
236
|
+
".#########.",
|
|
237
|
+
".#########.",
|
|
238
|
+
"#...###...#",
|
|
239
|
+
"#.#.###.#.#",
|
|
240
|
+
"#...###...#",
|
|
241
|
+
".#########.",
|
|
242
|
+
".#########.",
|
|
243
|
+
"..#######..",
|
|
244
|
+
"...#...#...",
|
|
245
|
+
"..#.....#.."
|
|
246
|
+
],
|
|
247
|
+
[
|
|
248
|
+
// alien
|
|
249
|
+
".#.......#.",
|
|
250
|
+
"..#.....#..",
|
|
251
|
+
"...#####...",
|
|
252
|
+
"..#######..",
|
|
253
|
+
".##.###.##.",
|
|
254
|
+
"..#######..",
|
|
255
|
+
".#.#####.#.",
|
|
256
|
+
"#.#######.#",
|
|
257
|
+
"#.#.....#.#",
|
|
258
|
+
".#.......#.",
|
|
259
|
+
"#..#...#..#"
|
|
260
|
+
],
|
|
261
|
+
[
|
|
262
|
+
// mushroom
|
|
263
|
+
"...#####...",
|
|
264
|
+
"..#######..",
|
|
265
|
+
".#########.",
|
|
266
|
+
"###########",
|
|
267
|
+
"###########",
|
|
268
|
+
".##.###.##.",
|
|
269
|
+
"...#####...",
|
|
270
|
+
"...#...#...",
|
|
271
|
+
"...#...#...",
|
|
272
|
+
"...#####...",
|
|
273
|
+
"..#######.."
|
|
274
|
+
],
|
|
275
|
+
[
|
|
276
|
+
// jellyfish
|
|
277
|
+
"...#####...",
|
|
278
|
+
"..#######..",
|
|
279
|
+
".#########.",
|
|
280
|
+
".##.###.##.",
|
|
281
|
+
"###########",
|
|
282
|
+
".#########.",
|
|
283
|
+
"..#.#.#.#..",
|
|
284
|
+
".#.#.#.#.#.",
|
|
285
|
+
".#..#.#..#.",
|
|
286
|
+
"#...#.#...#",
|
|
287
|
+
"#....#....#"
|
|
288
|
+
],
|
|
289
|
+
[
|
|
290
|
+
// slime
|
|
291
|
+
"...#####...",
|
|
292
|
+
"..#######..",
|
|
293
|
+
".#########.",
|
|
294
|
+
"####...####",
|
|
295
|
+
"####.#.####",
|
|
296
|
+
"####...####",
|
|
297
|
+
".#########.",
|
|
298
|
+
".#########.",
|
|
299
|
+
"..#######..",
|
|
300
|
+
".#.#.#.#.#.",
|
|
301
|
+
"#...#.#...#"
|
|
302
|
+
]
|
|
111
303
|
];
|
|
112
|
-
function
|
|
113
|
-
return rows.map((row) =>
|
|
114
|
-
const cells = [];
|
|
115
|
-
for (let x = 0; x < 8; x++) cells.push((row & 128 >> x) !== 0);
|
|
116
|
-
return cells;
|
|
117
|
-
});
|
|
304
|
+
function spriteToGrid(rows) {
|
|
305
|
+
return rows.map((row) => [...row].map((c) => c === "#"));
|
|
118
306
|
}
|
|
119
307
|
function invadrGrid(seed) {
|
|
120
|
-
return
|
|
308
|
+
return spriteToGrid(INVADR_SPRITES[seed % INVADR_SPRITES.length]);
|
|
121
309
|
}
|
|
122
310
|
function resolveInvadr(id, options) {
|
|
123
311
|
const seed = hashStr(id);
|
package/dist/index.cjs
CHANGED
|
@@ -22,8 +22,8 @@ var palettes = {
|
|
|
22
22
|
ocean: { colors: ["#1d3557", "#2a9d8f", "#48cae4", "#56e39f", "#4361ee", "#7bdff2"] },
|
|
23
23
|
// greens and earth — pine, leaf, lime-olive, fern, bark, tan
|
|
24
24
|
forest: { colors: ["#386641", "#6a994e", "#a7c957", "#588157", "#b08968", "#dda15e"] },
|
|
25
|
-
// grayscale
|
|
26
|
-
mono: { colors: ["#
|
|
25
|
+
// grayscale — mid greys, 6 distinct, legible on both light and dark backgrounds
|
|
26
|
+
mono: { colors: ["#a8a8a8", "#969696", "#848484", "#727272", "#606060", "#545454"] }
|
|
27
27
|
};
|
|
28
28
|
var CSS_VARS = {
|
|
29
29
|
colors: ["var(--accent)", "var(--green)", "var(--amber)", "var(--purple)", "var(--cyan)", "var(--red)"]
|
|
@@ -78,48 +78,236 @@ function dataUri(svg) {
|
|
|
78
78
|
|
|
79
79
|
// src/invadr.ts
|
|
80
80
|
var INVADR_SPRITES = [
|
|
81
|
-
[
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
[
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
[
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
81
|
+
[
|
|
82
|
+
// squid
|
|
83
|
+
"...#...#...",
|
|
84
|
+
"....#.#....",
|
|
85
|
+
"...#####...",
|
|
86
|
+
"..#######..",
|
|
87
|
+
".##.###.##.",
|
|
88
|
+
"###########",
|
|
89
|
+
"###########",
|
|
90
|
+
".#.#####.#.",
|
|
91
|
+
"..#.....#..",
|
|
92
|
+
".#..#.#..#.",
|
|
93
|
+
"#...#.#...#"
|
|
94
|
+
],
|
|
95
|
+
[
|
|
96
|
+
// crab
|
|
97
|
+
"#....#....#",
|
|
98
|
+
".#...#...#.",
|
|
99
|
+
"..#######..",
|
|
100
|
+
".#########.",
|
|
101
|
+
"###.###.###",
|
|
102
|
+
"###########",
|
|
103
|
+
"###########",
|
|
104
|
+
"#.#######.#",
|
|
105
|
+
"#.#.....#.#",
|
|
106
|
+
"...#...#...",
|
|
107
|
+
"..##...##.."
|
|
108
|
+
],
|
|
109
|
+
[
|
|
110
|
+
// octopus
|
|
111
|
+
"..#######..",
|
|
112
|
+
".#########.",
|
|
113
|
+
"###########",
|
|
114
|
+
"##.#####.##",
|
|
115
|
+
"##.#####.##",
|
|
116
|
+
"###########",
|
|
117
|
+
".#.#.#.#.#.",
|
|
118
|
+
".#.#.#.#.#.",
|
|
119
|
+
".#.#.#.#.#.",
|
|
120
|
+
"#..#.#.#..#",
|
|
121
|
+
"#..#.#.#..#"
|
|
122
|
+
],
|
|
123
|
+
[
|
|
124
|
+
// beetle
|
|
125
|
+
"#..#...#..#",
|
|
126
|
+
".#.#...#.#.",
|
|
127
|
+
"..#######..",
|
|
128
|
+
".####.####.",
|
|
129
|
+
"###########",
|
|
130
|
+
"###.###.###",
|
|
131
|
+
"###########",
|
|
132
|
+
"###########",
|
|
133
|
+
".#########.",
|
|
134
|
+
"..#.....#..",
|
|
135
|
+
".#.......#."
|
|
136
|
+
],
|
|
137
|
+
[
|
|
138
|
+
// bunny
|
|
139
|
+
"..#.....#..",
|
|
140
|
+
"..#.....#..",
|
|
141
|
+
"..#.#.#.#..",
|
|
142
|
+
"..#######..",
|
|
143
|
+
".#########.",
|
|
144
|
+
".##.###.##.",
|
|
145
|
+
".#########.",
|
|
146
|
+
".#########.",
|
|
147
|
+
"..#######..",
|
|
148
|
+
"..#.....#..",
|
|
149
|
+
".##.....##."
|
|
150
|
+
],
|
|
151
|
+
[
|
|
152
|
+
// cat
|
|
153
|
+
".#.......#.",
|
|
154
|
+
".##.....##.",
|
|
155
|
+
".#########.",
|
|
156
|
+
"###.###.###",
|
|
157
|
+
"#####.#####",
|
|
158
|
+
"###########",
|
|
159
|
+
"###########",
|
|
160
|
+
"#.#######.#",
|
|
161
|
+
"..#######..",
|
|
162
|
+
"...#...#...",
|
|
163
|
+
"..#.....#.."
|
|
164
|
+
],
|
|
165
|
+
[
|
|
166
|
+
// ghost
|
|
167
|
+
"...#####...",
|
|
168
|
+
"..#######..",
|
|
169
|
+
".#########.",
|
|
170
|
+
".##.###.##.",
|
|
171
|
+
"###########",
|
|
172
|
+
"###########",
|
|
173
|
+
"###########",
|
|
174
|
+
"###########",
|
|
175
|
+
"###########",
|
|
176
|
+
"#.##.#.##.#",
|
|
177
|
+
"#..#.#.#..#"
|
|
178
|
+
],
|
|
179
|
+
[
|
|
180
|
+
// skull
|
|
181
|
+
"...#####...",
|
|
182
|
+
"..#######..",
|
|
183
|
+
".#########.",
|
|
184
|
+
"###########",
|
|
185
|
+
"##..###..##",
|
|
186
|
+
"##..###..##",
|
|
187
|
+
"###########",
|
|
188
|
+
".#########.",
|
|
189
|
+
".#.#.#.#.#.",
|
|
190
|
+
".#########.",
|
|
191
|
+
"..#.....#.."
|
|
192
|
+
],
|
|
193
|
+
[
|
|
194
|
+
// robot
|
|
195
|
+
"....#.#....",
|
|
196
|
+
"...#####...",
|
|
197
|
+
"..#######..",
|
|
198
|
+
".##.###.##.",
|
|
199
|
+
".#########.",
|
|
200
|
+
".#.#.#.#.#.",
|
|
201
|
+
".#########.",
|
|
202
|
+
"..#######..",
|
|
203
|
+
"..#.....#..",
|
|
204
|
+
"..#.....#..",
|
|
205
|
+
".##.....##."
|
|
206
|
+
],
|
|
207
|
+
[
|
|
208
|
+
// horned
|
|
209
|
+
"#.........#",
|
|
210
|
+
"##.......##",
|
|
211
|
+
".##.....##.",
|
|
212
|
+
"..#######..",
|
|
213
|
+
".##.###.##.",
|
|
214
|
+
".#########.",
|
|
215
|
+
"..#######..",
|
|
216
|
+
"..#######..",
|
|
217
|
+
"...#...#...",
|
|
218
|
+
"..#.....#..",
|
|
219
|
+
".##.....##."
|
|
220
|
+
],
|
|
221
|
+
[
|
|
222
|
+
// smiley
|
|
223
|
+
"..#######..",
|
|
224
|
+
".#########.",
|
|
225
|
+
"###########",
|
|
226
|
+
"##.#####.##",
|
|
227
|
+
"###########",
|
|
228
|
+
"###########",
|
|
229
|
+
"#.#.###.#.#",
|
|
230
|
+
"##.#####.##",
|
|
231
|
+
".#########.",
|
|
232
|
+
"..#######..",
|
|
233
|
+
"..##...##.."
|
|
234
|
+
],
|
|
235
|
+
[
|
|
236
|
+
// owl
|
|
237
|
+
"##.......##",
|
|
238
|
+
".#########.",
|
|
239
|
+
".#########.",
|
|
240
|
+
"#...###...#",
|
|
241
|
+
"#.#.###.#.#",
|
|
242
|
+
"#...###...#",
|
|
243
|
+
".#########.",
|
|
244
|
+
".#########.",
|
|
245
|
+
"..#######..",
|
|
246
|
+
"...#...#...",
|
|
247
|
+
"..#.....#.."
|
|
248
|
+
],
|
|
249
|
+
[
|
|
250
|
+
// alien
|
|
251
|
+
".#.......#.",
|
|
252
|
+
"..#.....#..",
|
|
253
|
+
"...#####...",
|
|
254
|
+
"..#######..",
|
|
255
|
+
".##.###.##.",
|
|
256
|
+
"..#######..",
|
|
257
|
+
".#.#####.#.",
|
|
258
|
+
"#.#######.#",
|
|
259
|
+
"#.#.....#.#",
|
|
260
|
+
".#.......#.",
|
|
261
|
+
"#..#...#..#"
|
|
262
|
+
],
|
|
263
|
+
[
|
|
264
|
+
// mushroom
|
|
265
|
+
"...#####...",
|
|
266
|
+
"..#######..",
|
|
267
|
+
".#########.",
|
|
268
|
+
"###########",
|
|
269
|
+
"###########",
|
|
270
|
+
".##.###.##.",
|
|
271
|
+
"...#####...",
|
|
272
|
+
"...#...#...",
|
|
273
|
+
"...#...#...",
|
|
274
|
+
"...#####...",
|
|
275
|
+
"..#######.."
|
|
276
|
+
],
|
|
277
|
+
[
|
|
278
|
+
// jellyfish
|
|
279
|
+
"...#####...",
|
|
280
|
+
"..#######..",
|
|
281
|
+
".#########.",
|
|
282
|
+
".##.###.##.",
|
|
283
|
+
"###########",
|
|
284
|
+
".#########.",
|
|
285
|
+
"..#.#.#.#..",
|
|
286
|
+
".#.#.#.#.#.",
|
|
287
|
+
".#..#.#..#.",
|
|
288
|
+
"#...#.#...#",
|
|
289
|
+
"#....#....#"
|
|
290
|
+
],
|
|
291
|
+
[
|
|
292
|
+
// slime
|
|
293
|
+
"...#####...",
|
|
294
|
+
"..#######..",
|
|
295
|
+
".#########.",
|
|
296
|
+
"####...####",
|
|
297
|
+
"####.#.####",
|
|
298
|
+
"####...####",
|
|
299
|
+
".#########.",
|
|
300
|
+
".#########.",
|
|
301
|
+
"..#######..",
|
|
302
|
+
".#.#.#.#.#.",
|
|
303
|
+
"#...#.#...#"
|
|
304
|
+
]
|
|
113
305
|
];
|
|
114
|
-
function
|
|
115
|
-
return rows.map((row) =>
|
|
116
|
-
const cells = [];
|
|
117
|
-
for (let x = 0; x < 8; x++) cells.push((row & 128 >> x) !== 0);
|
|
118
|
-
return cells;
|
|
119
|
-
});
|
|
306
|
+
function spriteToGrid(rows) {
|
|
307
|
+
return rows.map((row) => [...row].map((c) => c === "#"));
|
|
120
308
|
}
|
|
121
309
|
function invadrGrid(seed) {
|
|
122
|
-
return
|
|
310
|
+
return spriteToGrid(INVADR_SPRITES[seed % INVADR_SPRITES.length]);
|
|
123
311
|
}
|
|
124
312
|
function resolveInvadr(id, options) {
|
|
125
313
|
const seed = hashStr(id);
|
package/dist/index.d.cts
CHANGED
|
@@ -14,10 +14,12 @@ declare function renderSvg(s: ResolvedSprite): string;
|
|
|
14
14
|
/** Wrap an SVG string as a data: URI usable in `src`/`background-image`. */
|
|
15
15
|
declare function dataUri(svg: string): string;
|
|
16
16
|
|
|
17
|
-
/** Hand-designed
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
/** Hand-designed 11x11 creatures — `'#'` is a filled pixel, any other char is
|
|
18
|
+
empty — in the retro pixel-alien style: antennae/ears up top, eyes as
|
|
19
|
+
negative space, splayed legs below. Each is left-right symmetric. The set
|
|
20
|
+
and its order define the avatar mapping, so changing them changes existing
|
|
21
|
+
avatars: a versioned, semver-major change. */
|
|
22
|
+
declare const INVADR_SPRITES: string[][];
|
|
21
23
|
/** Resolve a hand-drawn creature for an id (structured form). */
|
|
22
24
|
declare function resolveInvadr(id: string, options?: SpriteOptions): ResolvedSprite;
|
|
23
25
|
/** A hand-drawn creature for an id, as an SVG string. */
|
package/dist/index.d.ts
CHANGED
|
@@ -14,10 +14,12 @@ declare function renderSvg(s: ResolvedSprite): string;
|
|
|
14
14
|
/** Wrap an SVG string as a data: URI usable in `src`/`background-image`. */
|
|
15
15
|
declare function dataUri(svg: string): string;
|
|
16
16
|
|
|
17
|
-
/** Hand-designed
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
/** Hand-designed 11x11 creatures — `'#'` is a filled pixel, any other char is
|
|
18
|
+
empty — in the retro pixel-alien style: antennae/ears up top, eyes as
|
|
19
|
+
negative space, splayed legs below. Each is left-right symmetric. The set
|
|
20
|
+
and its order define the avatar mapping, so changing them changes existing
|
|
21
|
+
avatars: a versioned, semver-major change. */
|
|
22
|
+
declare const INVADR_SPRITES: string[][];
|
|
21
23
|
/** Resolve a hand-drawn creature for an id (structured form). */
|
|
22
24
|
declare function resolveInvadr(id: string, options?: SpriteOptions): ResolvedSprite;
|
|
23
25
|
/** A hand-drawn creature for an id, as an SVG string. */
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { CSS_VARS, INVADR_SPRITES, dataUri, hashStr, invadr, palettes, pickColor, renderSvg, resolveInvadr, resolvePalette, resolveSpawn, spawn } from './chunk-
|
|
1
|
+
export { CSS_VARS, INVADR_SPRITES, dataUri, hashStr, invadr, palettes, pickColor, renderSvg, resolveInvadr, resolvePalette, resolveSpawn, spawn } from './chunk-PFORKP7K.js';
|
package/dist/react/index.cjs
CHANGED
|
@@ -27,8 +27,8 @@ var palettes = {
|
|
|
27
27
|
ocean: { colors: ["#1d3557", "#2a9d8f", "#48cae4", "#56e39f", "#4361ee", "#7bdff2"] },
|
|
28
28
|
// greens and earth — pine, leaf, lime-olive, fern, bark, tan
|
|
29
29
|
forest: { colors: ["#386641", "#6a994e", "#a7c957", "#588157", "#b08968", "#dda15e"] },
|
|
30
|
-
// grayscale
|
|
31
|
-
mono: { colors: ["#
|
|
30
|
+
// grayscale — mid greys, 6 distinct, legible on both light and dark backgrounds
|
|
31
|
+
mono: { colors: ["#a8a8a8", "#969696", "#848484", "#727272", "#606060", "#545454"] }
|
|
32
32
|
};
|
|
33
33
|
var CSS_VARS = {
|
|
34
34
|
colors: ["var(--accent)", "var(--green)", "var(--amber)", "var(--purple)", "var(--cyan)", "var(--red)"]
|
|
@@ -59,48 +59,236 @@ function resolveCommon(seed, grid, options) {
|
|
|
59
59
|
|
|
60
60
|
// src/invadr.ts
|
|
61
61
|
var INVADR_SPRITES = [
|
|
62
|
-
[
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
[
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
[
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
62
|
+
[
|
|
63
|
+
// squid
|
|
64
|
+
"...#...#...",
|
|
65
|
+
"....#.#....",
|
|
66
|
+
"...#####...",
|
|
67
|
+
"..#######..",
|
|
68
|
+
".##.###.##.",
|
|
69
|
+
"###########",
|
|
70
|
+
"###########",
|
|
71
|
+
".#.#####.#.",
|
|
72
|
+
"..#.....#..",
|
|
73
|
+
".#..#.#..#.",
|
|
74
|
+
"#...#.#...#"
|
|
75
|
+
],
|
|
76
|
+
[
|
|
77
|
+
// crab
|
|
78
|
+
"#....#....#",
|
|
79
|
+
".#...#...#.",
|
|
80
|
+
"..#######..",
|
|
81
|
+
".#########.",
|
|
82
|
+
"###.###.###",
|
|
83
|
+
"###########",
|
|
84
|
+
"###########",
|
|
85
|
+
"#.#######.#",
|
|
86
|
+
"#.#.....#.#",
|
|
87
|
+
"...#...#...",
|
|
88
|
+
"..##...##.."
|
|
89
|
+
],
|
|
90
|
+
[
|
|
91
|
+
// octopus
|
|
92
|
+
"..#######..",
|
|
93
|
+
".#########.",
|
|
94
|
+
"###########",
|
|
95
|
+
"##.#####.##",
|
|
96
|
+
"##.#####.##",
|
|
97
|
+
"###########",
|
|
98
|
+
".#.#.#.#.#.",
|
|
99
|
+
".#.#.#.#.#.",
|
|
100
|
+
".#.#.#.#.#.",
|
|
101
|
+
"#..#.#.#..#",
|
|
102
|
+
"#..#.#.#..#"
|
|
103
|
+
],
|
|
104
|
+
[
|
|
105
|
+
// beetle
|
|
106
|
+
"#..#...#..#",
|
|
107
|
+
".#.#...#.#.",
|
|
108
|
+
"..#######..",
|
|
109
|
+
".####.####.",
|
|
110
|
+
"###########",
|
|
111
|
+
"###.###.###",
|
|
112
|
+
"###########",
|
|
113
|
+
"###########",
|
|
114
|
+
".#########.",
|
|
115
|
+
"..#.....#..",
|
|
116
|
+
".#.......#."
|
|
117
|
+
],
|
|
118
|
+
[
|
|
119
|
+
// bunny
|
|
120
|
+
"..#.....#..",
|
|
121
|
+
"..#.....#..",
|
|
122
|
+
"..#.#.#.#..",
|
|
123
|
+
"..#######..",
|
|
124
|
+
".#########.",
|
|
125
|
+
".##.###.##.",
|
|
126
|
+
".#########.",
|
|
127
|
+
".#########.",
|
|
128
|
+
"..#######..",
|
|
129
|
+
"..#.....#..",
|
|
130
|
+
".##.....##."
|
|
131
|
+
],
|
|
132
|
+
[
|
|
133
|
+
// cat
|
|
134
|
+
".#.......#.",
|
|
135
|
+
".##.....##.",
|
|
136
|
+
".#########.",
|
|
137
|
+
"###.###.###",
|
|
138
|
+
"#####.#####",
|
|
139
|
+
"###########",
|
|
140
|
+
"###########",
|
|
141
|
+
"#.#######.#",
|
|
142
|
+
"..#######..",
|
|
143
|
+
"...#...#...",
|
|
144
|
+
"..#.....#.."
|
|
145
|
+
],
|
|
146
|
+
[
|
|
147
|
+
// ghost
|
|
148
|
+
"...#####...",
|
|
149
|
+
"..#######..",
|
|
150
|
+
".#########.",
|
|
151
|
+
".##.###.##.",
|
|
152
|
+
"###########",
|
|
153
|
+
"###########",
|
|
154
|
+
"###########",
|
|
155
|
+
"###########",
|
|
156
|
+
"###########",
|
|
157
|
+
"#.##.#.##.#",
|
|
158
|
+
"#..#.#.#..#"
|
|
159
|
+
],
|
|
160
|
+
[
|
|
161
|
+
// skull
|
|
162
|
+
"...#####...",
|
|
163
|
+
"..#######..",
|
|
164
|
+
".#########.",
|
|
165
|
+
"###########",
|
|
166
|
+
"##..###..##",
|
|
167
|
+
"##..###..##",
|
|
168
|
+
"###########",
|
|
169
|
+
".#########.",
|
|
170
|
+
".#.#.#.#.#.",
|
|
171
|
+
".#########.",
|
|
172
|
+
"..#.....#.."
|
|
173
|
+
],
|
|
174
|
+
[
|
|
175
|
+
// robot
|
|
176
|
+
"....#.#....",
|
|
177
|
+
"...#####...",
|
|
178
|
+
"..#######..",
|
|
179
|
+
".##.###.##.",
|
|
180
|
+
".#########.",
|
|
181
|
+
".#.#.#.#.#.",
|
|
182
|
+
".#########.",
|
|
183
|
+
"..#######..",
|
|
184
|
+
"..#.....#..",
|
|
185
|
+
"..#.....#..",
|
|
186
|
+
".##.....##."
|
|
187
|
+
],
|
|
188
|
+
[
|
|
189
|
+
// horned
|
|
190
|
+
"#.........#",
|
|
191
|
+
"##.......##",
|
|
192
|
+
".##.....##.",
|
|
193
|
+
"..#######..",
|
|
194
|
+
".##.###.##.",
|
|
195
|
+
".#########.",
|
|
196
|
+
"..#######..",
|
|
197
|
+
"..#######..",
|
|
198
|
+
"...#...#...",
|
|
199
|
+
"..#.....#..",
|
|
200
|
+
".##.....##."
|
|
201
|
+
],
|
|
202
|
+
[
|
|
203
|
+
// smiley
|
|
204
|
+
"..#######..",
|
|
205
|
+
".#########.",
|
|
206
|
+
"###########",
|
|
207
|
+
"##.#####.##",
|
|
208
|
+
"###########",
|
|
209
|
+
"###########",
|
|
210
|
+
"#.#.###.#.#",
|
|
211
|
+
"##.#####.##",
|
|
212
|
+
".#########.",
|
|
213
|
+
"..#######..",
|
|
214
|
+
"..##...##.."
|
|
215
|
+
],
|
|
216
|
+
[
|
|
217
|
+
// owl
|
|
218
|
+
"##.......##",
|
|
219
|
+
".#########.",
|
|
220
|
+
".#########.",
|
|
221
|
+
"#...###...#",
|
|
222
|
+
"#.#.###.#.#",
|
|
223
|
+
"#...###...#",
|
|
224
|
+
".#########.",
|
|
225
|
+
".#########.",
|
|
226
|
+
"..#######..",
|
|
227
|
+
"...#...#...",
|
|
228
|
+
"..#.....#.."
|
|
229
|
+
],
|
|
230
|
+
[
|
|
231
|
+
// alien
|
|
232
|
+
".#.......#.",
|
|
233
|
+
"..#.....#..",
|
|
234
|
+
"...#####...",
|
|
235
|
+
"..#######..",
|
|
236
|
+
".##.###.##.",
|
|
237
|
+
"..#######..",
|
|
238
|
+
".#.#####.#.",
|
|
239
|
+
"#.#######.#",
|
|
240
|
+
"#.#.....#.#",
|
|
241
|
+
".#.......#.",
|
|
242
|
+
"#..#...#..#"
|
|
243
|
+
],
|
|
244
|
+
[
|
|
245
|
+
// mushroom
|
|
246
|
+
"...#####...",
|
|
247
|
+
"..#######..",
|
|
248
|
+
".#########.",
|
|
249
|
+
"###########",
|
|
250
|
+
"###########",
|
|
251
|
+
".##.###.##.",
|
|
252
|
+
"...#####...",
|
|
253
|
+
"...#...#...",
|
|
254
|
+
"...#...#...",
|
|
255
|
+
"...#####...",
|
|
256
|
+
"..#######.."
|
|
257
|
+
],
|
|
258
|
+
[
|
|
259
|
+
// jellyfish
|
|
260
|
+
"...#####...",
|
|
261
|
+
"..#######..",
|
|
262
|
+
".#########.",
|
|
263
|
+
".##.###.##.",
|
|
264
|
+
"###########",
|
|
265
|
+
".#########.",
|
|
266
|
+
"..#.#.#.#..",
|
|
267
|
+
".#.#.#.#.#.",
|
|
268
|
+
".#..#.#..#.",
|
|
269
|
+
"#...#.#...#",
|
|
270
|
+
"#....#....#"
|
|
271
|
+
],
|
|
272
|
+
[
|
|
273
|
+
// slime
|
|
274
|
+
"...#####...",
|
|
275
|
+
"..#######..",
|
|
276
|
+
".#########.",
|
|
277
|
+
"####...####",
|
|
278
|
+
"####.#.####",
|
|
279
|
+
"####...####",
|
|
280
|
+
".#########.",
|
|
281
|
+
".#########.",
|
|
282
|
+
"..#######..",
|
|
283
|
+
".#.#.#.#.#.",
|
|
284
|
+
"#...#.#...#"
|
|
285
|
+
]
|
|
94
286
|
];
|
|
95
|
-
function
|
|
96
|
-
return rows.map((row) =>
|
|
97
|
-
const cells = [];
|
|
98
|
-
for (let x = 0; x < 8; x++) cells.push((row & 128 >> x) !== 0);
|
|
99
|
-
return cells;
|
|
100
|
-
});
|
|
287
|
+
function spriteToGrid(rows) {
|
|
288
|
+
return rows.map((row) => [...row].map((c) => c === "#"));
|
|
101
289
|
}
|
|
102
290
|
function invadrGrid(seed) {
|
|
103
|
-
return
|
|
291
|
+
return spriteToGrid(INVADR_SPRITES[seed % INVADR_SPRITES.length]);
|
|
104
292
|
}
|
|
105
293
|
function resolveInvadr(id, options) {
|
|
106
294
|
const seed = hashStr(id);
|
package/dist/react/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "invadrs",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Deterministic space-invaders-style pixel avatars from any string.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,7 +24,9 @@
|
|
|
24
24
|
"react"
|
|
25
25
|
],
|
|
26
26
|
"sideEffects": false,
|
|
27
|
-
"files": [
|
|
27
|
+
"files": [
|
|
28
|
+
"dist"
|
|
29
|
+
],
|
|
28
30
|
"exports": {
|
|
29
31
|
".": {
|
|
30
32
|
"types": "./dist/index.d.ts",
|
|
@@ -40,13 +42,17 @@
|
|
|
40
42
|
"scripts": {
|
|
41
43
|
"build": "tsup",
|
|
42
44
|
"test": "bun test",
|
|
43
|
-
"prepare": "tsup"
|
|
45
|
+
"prepare": "tsup",
|
|
46
|
+
"storybook": "storybook dev -p 6006",
|
|
47
|
+
"build-storybook": "storybook build"
|
|
44
48
|
},
|
|
45
49
|
"peerDependencies": {
|
|
46
50
|
"react": ">=18"
|
|
47
51
|
},
|
|
48
52
|
"peerDependenciesMeta": {
|
|
49
|
-
"react": {
|
|
53
|
+
"react": {
|
|
54
|
+
"optional": true
|
|
55
|
+
}
|
|
50
56
|
},
|
|
51
57
|
"devDependencies": {
|
|
52
58
|
"@types/bun": "latest",
|
|
@@ -55,6 +61,17 @@
|
|
|
55
61
|
"react": "^19.0.0",
|
|
56
62
|
"react-dom": "^19.0.0",
|
|
57
63
|
"tsup": "^8.0.0",
|
|
58
|
-
"typescript": "^5.4.0"
|
|
64
|
+
"typescript": "^5.4.0",
|
|
65
|
+
"storybook": "^10.5.3",
|
|
66
|
+
"@storybook/react-vite": "^10.5.3",
|
|
67
|
+
"@chromatic-com/storybook": "^5.2.1",
|
|
68
|
+
"@storybook/addon-vitest": "^10.5.3",
|
|
69
|
+
"@storybook/addon-a11y": "^10.5.3",
|
|
70
|
+
"@storybook/addon-docs": "^10.5.3",
|
|
71
|
+
"@storybook/addon-mcp": "^0.7.0",
|
|
72
|
+
"vitest": "^4.1.10",
|
|
73
|
+
"playwright": "^1.61.1",
|
|
74
|
+
"@vitest/browser-playwright": "^4.1.10",
|
|
75
|
+
"@vitest/coverage-v8": "^4.1.10"
|
|
59
76
|
}
|
|
60
77
|
}
|