dsh-game-material-master 0.7.0 → 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.
package/lib/maprender.js CHANGED
@@ -32,7 +32,7 @@ import { encodePng } from "./png.js";
32
32
  import { cellIndex } from "./mapdoc.js";
33
33
  import { cellCenter, cellTopLeft, chunkKey, chunkOf, layoutOf, parseChunkKey, wrapCell } from "./mapgeom.js";
34
34
  import { a2QuadrantShapes, corner16Mask, nearestMask } from "./mapauto.js";
35
- import { flatTiles } from "./maptiles.js";
35
+ import { applyLoop, flatTiles, stampSpan } from "./maptiles.js";
36
36
  /** 单张导出图的最大像素数(超过就明确拒绝,而不是把进程 OOM 掉)。 */
37
37
  export const MAX_RENDER_PIXELS = 64_000_000;
38
38
  /** 动画帧率:AsLib 的 60 帧 ≈ 1 秒切一次。 */
@@ -176,14 +176,18 @@ function wholeCellOps(env, layerIndex, tileset, base, local, at, w, rr, cc) {
176
176
  break;
177
177
  frames.push(base + index);
178
178
  }
179
+ // 「一遍」的帧序 → 实际循环(正放 / 倒放 / 来回);只展开帧序,客户端不用改。
179
180
  if (frames.length > 1)
180
- cycle = frames;
181
+ cycle = applyLoop(frames, tileset.loop ?? "forward");
181
182
  }
182
183
  const index = cycle === undefined ? base + position : cycle[0];
183
184
  const topLeft = cellTopLeft(env.layout, rr, cc, tileset.cell.width, tileset.cell.height);
184
185
  const op = { l: layerIndex, r: w.r, c: w.c, t: index, x: Math.round(topLeft.x), y: Math.round(topLeft.y), a: 1 };
185
- if (cycle !== undefined)
186
+ if (cycle !== undefined) {
186
187
  op.cycle = cycle;
188
+ if (tileset.fps !== undefined)
189
+ op.fps = tileset.fps;
190
+ }
187
191
  return [op];
188
192
  }
189
193
  /** A2 拼块:一格 4 条 op(TL/TR/BL/BR),各自指向「该象限形状 + 变体」的那个小格。 */
@@ -230,8 +234,12 @@ function a2Ops(env, layerIndex, tileset, base, at, w, rr, cc) {
230
234
  a: 1
231
235
  };
232
236
  // 变体差异就是动画:四个象限各带一条**等长**的 cycle,帧号因此是全局同一个。
233
- if (cycle.length > 1)
234
- op.cycle = cycle;
237
+ if (cycle.length > 1) {
238
+ // 四个象限各带一条**等长**的展开后帧序 —— 同一条循环方式,帧号因此仍然是全局同一个。
239
+ op.cycle = applyLoop(cycle, tileset.loop ?? "forward");
240
+ if (tileset.fps !== undefined)
241
+ op.fps = tileset.fps;
242
+ }
235
243
  ops.push(op);
236
244
  }
237
245
  return ops;
@@ -245,6 +253,65 @@ function a2Ops(env, layerIndex, tileset, base, at, w, rr, cc) {
245
253
  * - chunk 之间按行优先的 chunk 序拼接,chunk 内按 行 → 列 → 层 稳定排序:
246
254
  * 客户端照序 `drawImage` 即可与宿主逐像素同构。
247
255
  */
256
+ /** 整图图块表的键:第几帧 / 转几档 / 第几行第几列。 */
257
+ function stampKey(frame, rot, r, c) {
258
+ return `${frame}|${rot}|${r}|${c}`;
259
+ }
260
+ /** 一张整图素材的索引:`frame|rot|r|c` → **1-based 全局序号**(`base` = 该素材在 flatTiles 里的起点)。 */
261
+ function stampTileIndex(tileset, base) {
262
+ const index = new Map();
263
+ /**
264
+ * ⚠️ `base` 是这块素材**第 0 块的全局序号**(`tilesetBaseIndex`,已经是从 1 开始的),
265
+ * `local` 是块在素材里的 **0-based** 下标 —— 所以这里是 `base + local`,**不要再加 1**。
266
+ *
267
+ * 真机翻车(用户那张城门):写成 `base + local + 1` 之后每一格都画成了**下一块** ——
268
+ * 整张图整体左移一格(「左边少了一块」),最右一格则越过 rot0 的块边界、取到了 rot1 那个
269
+ * 「竖着的」块(「右边多了点东西」)。这类错位不报任何警告,只能靠黄金对照拦住:
270
+ * `verify-map-pipeline` 第 22 节会把计划里每条 op 的矩形取出来,逐格和素材图比像素。
271
+ */
272
+ tileset.tiles.forEach((tile, local) => {
273
+ const meta = tile.stamp;
274
+ if (meta === undefined)
275
+ return;
276
+ index.set(stampKey(meta.frame, meta.rot, meta.r, meta.c), base + local);
277
+ });
278
+ return index;
279
+ }
280
+ /**
281
+ * 一张整图**占到的每一格** + 每格通行性(导出与「区域叠加」共用同一份几何)。
282
+ *
283
+ * - 坐标**取模**落到地图内(与渲染一致:跨接缝的整图每格各自环绕);
284
+ * - 通行性取**转前**那一格(转的是图,角色站的位置跟着转);
285
+ * - 素材不见了 / 不是整图 → 空表(调用方给警告)。
286
+ */
287
+ export function stampCellsOf(context, doc, stamp) {
288
+ const tileset = context.tilesets.find((entry) => entry.id === stamp.tilesetId);
289
+ const spec = tileset?.stamp;
290
+ if (spec === undefined)
291
+ return [];
292
+ const span = stampSpan(spec, stamp.rot);
293
+ const out = [];
294
+ for (let dr = 0; dr < span.rows; dr++) {
295
+ for (let dc = 0; dc < span.cols; dc++) {
296
+ const r = ((stamp.r + dr) % doc.rows + doc.rows) % doc.rows;
297
+ const c = ((stamp.c + dc) % doc.cols + doc.cols) % doc.cols;
298
+ const source = stampSourceCell(spec, stamp.rot, dr, dc);
299
+ out.push({ r, c, pass: spec.pass[source.r * spec.cols + source.c] ?? 0 });
300
+ }
301
+ }
302
+ return out;
303
+ }
304
+ /** 旋转后 (r,c) 对应转前的哪一格(顺时针 90°)。 */
305
+ function stampSourceCell(spec, rot, r, c) {
306
+ const turn = ((Math.round(rot) % 4) + 4) % 4;
307
+ if (turn === 1)
308
+ return { r: spec.rows - 1 - c, c: r };
309
+ if (turn === 2)
310
+ return { r: spec.rows - 1 - r, c: spec.cols - 1 - c };
311
+ if (turn === 3)
312
+ return { r: c, c: spec.cols - 1 - r };
313
+ return { r, c };
314
+ }
248
315
  export function buildPlan(context, doc, opts = {}) {
249
316
  const layout = layoutOf(context.grid, doc.cols, doc.rows);
250
317
  const range = opts.range ?? { r0: 0, c0: 0, r1: doc.rows, c1: doc.cols };
@@ -258,11 +325,20 @@ export function buildPlan(context, doc, opts = {}) {
258
325
  layout,
259
326
  baseIndex: tilesetBaseIndex(context.tilesets),
260
327
  tilesetById: new Map(context.tilesets.map((tileset) => [tileset.id, tileset])),
261
- sink: { missing: new Set(), fallback: new Map(), unmasked: new Set(), a2Layout: new Set(), a2Range: new Set() }
328
+ sink: { missing: new Set(), fallback: new Map(), unmasked: new Set(), a2Layout: new Set(), a2Range: new Set(), missingStamp: new Set() }
262
329
  };
263
330
  // 每个 op 额外记下**未 wrap** 的 (rr,cc):op 上的 r/c 是规范坐标,用来排序的话
264
331
  // 环绕视口里会把地图的另一头排到前面(屏幕上的行序就乱了)。
265
332
  const buckets = new Map();
333
+ const push = (op, rr, cc) => {
334
+ const key = chunkKey(chunkOf(rr, cc));
335
+ let list = buckets.get(key);
336
+ if (list === undefined) {
337
+ list = [];
338
+ buckets.set(key, list);
339
+ }
340
+ list.push({ op, rr, cc });
341
+ };
266
342
  for (let layerIndex = 0; layerIndex < doc.layers.length; layerIndex++) {
267
343
  if (keepLayers !== undefined && !keepLayers.has(layerIndex))
268
344
  continue;
@@ -274,14 +350,73 @@ export function buildPlan(context, doc, opts = {}) {
274
350
  const ops = cellOpsAt(env, layer.id, layerIndex, rr, cc);
275
351
  if (ops.length === 0)
276
352
  continue;
277
- const key = chunkKey(chunkOf(rr, cc));
278
- let list = buckets.get(key);
279
- if (list === undefined) {
280
- list = [];
281
- buckets.set(key, list);
282
- }
283
353
  for (const op of ops)
284
- list.push({ op, rr, cc });
354
+ push(op, rr, cc);
355
+ }
356
+ }
357
+ /**
358
+ * 整图(多格印花):**同一层里画在图块之后**(它是立在格子上的物件)。
359
+ *
360
+ * 一格一条 op,`t` 指向「该帧 / 该旋转 / 第几行第几列」的那块图 —— 旋转已经烘在素材图里,
361
+ * 运行期不转任何东西;坐标与像素位置都由这里算好,客户端照旧只 drawImage。
362
+ */
363
+ for (const stamp of doc.stamps) {
364
+ if (stamp.layerId !== layer.id)
365
+ continue;
366
+ const tileset = env.tilesetById.get(stamp.tilesetId);
367
+ const spec = tileset?.stamp;
368
+ if (tileset === undefined || spec === undefined) {
369
+ env.sink.missingStamp.add(stamp.tilesetId);
370
+ continue;
371
+ }
372
+ const span = stampSpan(spec, stamp.rot);
373
+ const base = env.baseIndex.get(tileset.id) ?? 0;
374
+ const index = stampTileIndex(tileset, base);
375
+ /** 一格的帧序(frames > 1 时才展开)。 */
376
+ const cycleOf = (r, c) => {
377
+ if (spec.frames <= 1)
378
+ return undefined;
379
+ const frames = [];
380
+ for (let frame = 0; frame < spec.frames; frame++) {
381
+ const tile = index.get(stampKey(frame, stamp.rot, r, c));
382
+ if (tile === undefined)
383
+ break;
384
+ frames.push(tile);
385
+ }
386
+ return frames.length > 1 ? applyLoop(frames, tileset.loop ?? "forward") : undefined;
387
+ };
388
+ for (let dr = 0; dr < span.rows; dr++) {
389
+ for (let dc = 0; dc < span.cols; dc++) {
390
+ const rr = stamp.r + dr;
391
+ const cc = stamp.c + dc;
392
+ if (rr < range.r0 || rr >= range.r1 || cc < range.c0 || cc >= range.c1)
393
+ continue;
394
+ const cell = wrapCell(env.layout, rr, cc);
395
+ if (cell.r < 0 || cell.c < 0 || cell.r >= doc.rows || cell.c >= doc.cols)
396
+ continue;
397
+ const cycle = cycleOf(dr, dc);
398
+ const first = index.get(stampKey(0, stamp.rot, dr, dc));
399
+ if (first === undefined && cycle === undefined) {
400
+ env.sink.missingStamp.add(stamp.tilesetId);
401
+ continue;
402
+ }
403
+ const position = cellTopLeft(env.layout, rr, cc, env.layout.stepX, env.layout.stepY);
404
+ const op = {
405
+ l: layerIndex,
406
+ r: cell.r,
407
+ c: cell.c,
408
+ t: cycle === undefined ? first : cycle[0],
409
+ x: position.x,
410
+ y: position.y,
411
+ a: 1
412
+ };
413
+ if (cycle !== undefined) {
414
+ op.cycle = cycle;
415
+ if (tileset.fps !== undefined)
416
+ op.fps = tileset.fps;
417
+ }
418
+ push(op, rr, cc);
419
+ }
285
420
  }
286
421
  }
287
422
  }
@@ -301,6 +436,8 @@ export function buildPlan(context, doc, opts = {}) {
301
436
  warnings.push(`图集「${nameOf(id)}」的 A2 小格排列与预期(小格行优先)不一致,拼出来的地块可能错位。`);
302
437
  for (const id of env.sink.a2Range)
303
438
  warnings.push(`图集「${nameOf(id)}」的变体 / 形状数超过了素材里的小格,画不出来的帧被丢掉了。`);
439
+ for (const id of env.sink.missingStamp)
440
+ warnings.push(`地图里引用了「${nameOf(id)}」的整图,但那块素材不见了(或已经不是整图),这些整图没有画出来。`);
304
441
  const chunks = [];
305
442
  const cycles = [];
306
443
  const seenCycles = new Set();
@@ -310,6 +447,7 @@ export function buildPlan(context, doc, opts = {}) {
310
447
  const pb = parseChunkKey(b[0]) ?? { cx: 0, cy: 0 };
311
448
  return pa.cy - pb.cy || pa.cx - pb.cx;
312
449
  });
450
+ let fpsMax = DEFAULT_FPS;
313
451
  for (const [key, list] of ordered) {
314
452
  list.sort((a, b) => a.rr - b.rr || a.cc - b.cc || a.op.l - b.op.l);
315
453
  for (const item of list) {
@@ -318,6 +456,9 @@ export function buildPlan(context, doc, opts = {}) {
318
456
  continue;
319
457
  if (cycle.length > frameCount)
320
458
  frameCount = cycle.length;
459
+ // 客户端照 fpsMax 推时钟,慢速的那个不会拖住快速的那个。
460
+ if (typeof item.op.fps === "number" && item.op.fps > fpsMax)
461
+ fpsMax = item.op.fps;
321
462
  const id = cycle.join(",");
322
463
  if (seenCycles.has(id))
323
464
  continue;
@@ -331,6 +472,7 @@ export function buildPlan(context, doc, opts = {}) {
331
472
  bounds: planBounds(context, doc),
332
473
  legend,
333
474
  fps: DEFAULT_FPS,
475
+ fpsMax,
334
476
  frameCount,
335
477
  cycles,
336
478
  markers: buildMarkers(context, doc, range),
@@ -19,6 +19,10 @@
19
19
  * 形状 2 只压纵向外边、形状 3 只在朝对角那一角画 L 形内角带、形状 4 不压(纯本体)。
20
20
  * 过渡带靠内的 2px 用**有序抖动矩阵**做过渡(不用随机数发生器,任何调用顺序下都一样)。
21
21
  * - **1 张道具网格图**:`8×5` 个 32px 图块(树 / 花 / 石头 / 木箱 / 栅栏 / 蘑菇 / 断枝 / 石头堆)。
22
+ * - **3 张说明图**(`renderGuideSheets()`):界面里「素材说明」窗口用的示例图 ——
23
+ * 普通图块 `128×64`(4×2 个道具)、整格自动连接 `128×128`(4×4 的墙,行优先第 i 块
24
+ * 就是方向位序 i)、拼块自动连接直接取内置草地 `64×160`。前两张是本机现画的,
25
+ * 拼块那张就是用户点「恢复默认素材」真会拿到的那张图。
22
26
  * - **变体 = 帧**:变体 1 是噪声种子 + 1(水再错开 90° 波纹相位)的同一地貌,
23
27
  * 两帧逐像素不同 —— 这是内置素材里唯一的动画来源(水最明显)。
24
28
  *
@@ -93,8 +97,18 @@ export const SAMPLE_PROP_NAMES = [
93
97
  "断枝",
94
98
  "石头堆"
95
99
  ];
96
- /** 道具网格图的行数(每一行是同一组道具的一帧,界面上按行切)。 */
97
- export const SAMPLE_PROP_ROWS = 5;
100
+ /**
101
+ * 道具摆动的相位(像素):0 / +1 / 0 / −1 / 0 —— **首尾相接**,循环播放时不跳帧。
102
+ *
103
+ * 长度就是帧数(见 `SAMPLE_PROP_ROWS`)。它是「行 = 帧」这件事的落地:
104
+ * 每一行的图必须**真的不一样**,否则 8×5 的帧表就退化成 5 份一模一样的拷贝
105
+ * (调色板里会冒出 40 个笔刷、其中 32 个逐像素重复)。
106
+ */
107
+ const SAMPLE_PROP_SWAY = [0, 1, 0, -1, 0];
108
+ /** 道具网格图的行数 = 帧数(`SAMPLE_PROP_SWAY` 的长度,界面上按行切)。 */
109
+ export const SAMPLE_PROP_ROWS = SAMPLE_PROP_SWAY.length;
110
+ /** 会长在风里的道具才摆;木箱 / 栅栏 / 石头 / 石头堆是硬物,每一帧逐像素一样。 */
111
+ export const SAMPLE_PROP_SWAYING = ["树", "花", "蘑菇", "断枝"];
98
112
  /** 道具网格图的文件名。 */
99
113
  export const SAMPLE_PROP_FILE = "sample-props.png";
100
114
  /** 道具网格图的中文名。 */
@@ -631,8 +645,25 @@ const P = {
631
645
  capDark: [150, 40, 36, 255],
632
646
  cream: [238, 226, 198, 255]
633
647
  };
634
- /** 画一个道具(32×32,透明底)。`name` 用中文名,见 `SAMPLE_PROP_NAMES`。 */
635
- function drawProp(bitmap, name) {
648
+ /**
649
+ * 画一个道具(32×32,透明底)。`name` 用中文名,见 `SAMPLE_PROP_NAMES`;
650
+ * `frame` 是帧号(= 道具网格图的行号,见 `SAMPLE_PROP_ROWS`)。
651
+ *
652
+ * 接地的阴影**钉在原地**:摆的是本体,不是它脚下的影子。所以本体先画在临时图上,
653
+ * 再按相位整体平移贴过去(平移量见 `SAMPLE_PROP_SWAY`)。
654
+ */
655
+ function drawProp(bitmap, name, frame = 0) {
656
+ for (let x = 4; x < 28; x++) {
657
+ if (getPixel(bitmap, x, 30)[3] === 0)
658
+ setPixel(bitmap, x, 30, [0, 0, 0, 60]);
659
+ }
660
+ const body = createBitmap(SAMPLE_CELL, SAMPLE_CELL);
661
+ drawPropBody(body, name);
662
+ const sway = SAMPLE_PROP_SWAYING.includes(name) ? SAMPLE_PROP_SWAY[frame % SAMPLE_PROP_ROWS] ?? 0 : 0;
663
+ blit(bitmap, body, sway, 0);
664
+ }
665
+ /** 道具本体(不含接地阴影与摆动)。画进给定的 32×32 位图。 */
666
+ function drawPropBody(bitmap, name) {
636
667
  switch (name) {
637
668
  case "树": {
638
669
  fillRect(bitmap, 14, 18, 5, 12, P.trunk);
@@ -707,24 +738,117 @@ function drawProp(bitmap, name) {
707
738
  // 认不出的名字不静默画空图:那是自检夹具和实现脱节的信号。
708
739
  throw new Error(`未知道具名:${name}`);
709
740
  }
710
- // 底部一圈极浅的接地阴影,让道具不是「浮」在地块上。
711
- for (let x = 4; x < 28; x++) {
712
- if (getPixel(bitmap, x, 30)[3] === 0)
713
- setPixel(bitmap, x, 30, [0, 0, 0, 60]);
714
- }
715
741
  }
716
- /** 道具网格图:`8×5` 个 32px 图块(列 = 道具,行 = 帧)。 */
742
+ /** 道具网格图:`8 列 × 5 帧` 个 32px 图块(列 = 道具,**行 = 帧**)。 */
717
743
  export function renderPropSheet() {
718
744
  const bitmap = createBitmap(SAMPLE_CELL * SAMPLE_PROP_NAMES.length, SAMPLE_CELL * SAMPLE_PROP_ROWS);
719
745
  for (let row = 0; row < SAMPLE_PROP_ROWS; row++) {
720
746
  for (let col = 0; col < SAMPLE_PROP_NAMES.length; col++) {
721
747
  const tile = createBitmap(SAMPLE_CELL, SAMPLE_CELL);
722
- drawProp(tile, SAMPLE_PROP_NAMES[col]);
748
+ // ⚠️ 帧号必须传下去:早先这里写的是 `drawProp(tile, SAMPLE_PROP_NAMES[col])`,
749
+ // 5 行画出来逐像素一样 —— 那 5 行是「同一张图的 5 份拷贝」,不是 5 帧。
750
+ drawProp(tile, SAMPLE_PROP_NAMES[col], row);
751
+ blit(bitmap, tile, col * SAMPLE_CELL, row * SAMPLE_CELL);
752
+ }
753
+ }
754
+ return bitmap;
755
+ }
756
+ /** 说明图里墙的宽度(像素)—— 32px 的格子里留出 10px 的边,连接方向一眼能看出来。 */
757
+ const GUIDE_WALL = 12;
758
+ /** 墙的描边 / 受光面 / 背光面。 */
759
+ const GUIDE_EDGE = [34, 36, 42, 255];
760
+ const GUIDE_LIT = [206, 208, 216, 255];
761
+ const GUIDE_SHADE = [58, 58, 66, 255];
762
+ /**
763
+ * 「整格自动连接」的一块墙:朝**有邻居的那几个方向**伸出墙臂,中间永远有一块。
764
+ *
765
+ * 方向位与宿主 `mapauto` 的位序**必须一致**(上=1 / 右=2 / 下=4 / 左=8),
766
+ * 因为说明图里第 i 块就是「加起来等于 i」的那一种接法 —— 图画错了,
767
+ * 用户照着排出来的图也会错,而且不报任何错。
768
+ */
769
+ function renderGuideWallTile(mask, size) {
770
+ const bitmap = createBitmap(size, size);
771
+ const texture = renderLocalTexture("stone", size, 4004, 0, 0);
772
+ const from = Math.floor((size - GUIDE_WALL) / 2);
773
+ const to = from + GUIDE_WALL;
774
+ const inBand = (value) => value >= from && value < to;
775
+ /** 这一点是不是墙的一部分(往四个方向各伸一条臂,正中间那块永远在)。 */
776
+ const solid = (x, y) => {
777
+ if (x < 0 || y < 0 || x >= size || y >= size)
778
+ return false;
779
+ if (inBand(x) && inBand(y))
780
+ return true;
781
+ if ((mask & 1) !== 0 && inBand(x) && y < from)
782
+ return true;
783
+ if ((mask & 2) !== 0 && inBand(y) && x >= to)
784
+ return true;
785
+ if ((mask & 4) !== 0 && inBand(x) && y >= to)
786
+ return true;
787
+ if ((mask & 8) !== 0 && inBand(y) && x < from)
788
+ return true;
789
+ return false;
790
+ };
791
+ const bare = (x, y) => !solid(x - 1, y) || !solid(x + 1, y) || !solid(x, y - 1) || !solid(x, y + 1);
792
+ for (let y = 0; y < size; y++) {
793
+ for (let x = 0; x < size; x++) {
794
+ if (!solid(x, y))
795
+ continue;
796
+ if (bare(x, y)) {
797
+ setPixel(bitmap, x, y, GUIDE_EDGE);
798
+ continue;
799
+ }
800
+ if (bare(x, y - 1)) {
801
+ setPixel(bitmap, x, y, GUIDE_LIT);
802
+ continue;
803
+ }
804
+ if (bare(x, y + 1)) {
805
+ setPixel(bitmap, x, y, GUIDE_SHADE);
806
+ continue;
807
+ }
808
+ const offset = (y * size + x) * 4;
809
+ setPixel(bitmap, x, y, [texture.rgba[offset], texture.rgba[offset + 1], texture.rgba[offset + 2], 255]);
810
+ }
811
+ }
812
+ return bitmap;
813
+ }
814
+ /** 「普通图块」示例:4 列 × 2 行的道具(8 块各不相同,一眼看出「一格一块」)。 */
815
+ function renderGuidePlainSheet() {
816
+ const cols = 4;
817
+ const rows = 2;
818
+ const bitmap = createBitmap(SAMPLE_CELL * cols, SAMPLE_CELL * rows);
819
+ for (let row = 0; row < rows; row++) {
820
+ for (let col = 0; col < cols; col++) {
821
+ const tile = createBitmap(SAMPLE_CELL, SAMPLE_CELL);
822
+ drawProp(tile, SAMPLE_PROP_NAMES[row * cols + col]);
723
823
  blit(bitmap, tile, col * SAMPLE_CELL, row * SAMPLE_CELL);
724
824
  }
725
825
  }
726
826
  return bitmap;
727
827
  }
828
+ /** 「整格自动连接」示例:4×4 = 16 块,行优先第 i 块就是位序 i(与宿主认的同一种排法)。 */
829
+ function renderGuideCorner16Sheet() {
830
+ const bitmap = createBitmap(SAMPLE_CELL * 4, SAMPLE_CELL * 4);
831
+ for (let index = 0; index < 16; index++) {
832
+ blit(bitmap, renderGuideWallTile(index, SAMPLE_CELL), (index % 4) * SAMPLE_CELL, Math.floor(index / 4) * SAMPLE_CELL);
833
+ }
834
+ return bitmap;
835
+ }
836
+ /**
837
+ * 「素材说明」窗口用的三张示例图。
838
+ *
839
+ * 前两张是**本机现画**的(普通 / 整格),拼块那张直接取内置草地 —— 也就是用户点
840
+ * 「恢复默认素材」真会拿到的那张图,说明与实物完全一致。
841
+ */
842
+ export function renderGuideSheets() {
843
+ const plain = renderGuidePlainSheet();
844
+ const corner16 = renderGuideCorner16Sheet();
845
+ const a2 = renderA2Sheet(SAMPLE_KINDS[0]);
846
+ return [
847
+ { shape: "plain", width: plain.width, height: plain.height, cols: 4, rows: 2, sub: 0, png: encodePng(plain.rgba, plain.width, plain.height) },
848
+ { shape: "corner16", width: corner16.width, height: corner16.height, cols: 4, rows: 4, sub: 0, png: encodePng(corner16.rgba, corner16.width, corner16.height) },
849
+ { shape: "a2quad", width: a2.width, height: a2.height, cols: SAMPLE_VARIANTS, rows: SAMPLE_SHAPES, sub: 2, png: encodePng(a2.rgba, a2.width, a2.height) }
850
+ ];
851
+ }
728
852
  // ---------------------------------------------------------------------------
729
853
  // 对外入口
730
854
  // ---------------------------------------------------------------------------
@@ -754,7 +878,10 @@ export function renderSampleTilesets() {
754
878
  bytes: encodePng(props.rgba, props.width, props.height),
755
879
  shape: "plain",
756
880
  cell: { width: SAMPLE_CELL, height: SAMPLE_CELL },
757
- animRows: false
881
+ // **行 = 帧**:同一列的 5 行是同一个道具的 5 帧,宿主按全局帧号现推该画哪一行。
882
+ // 这里写 false 的话,40 个小格会被当成 40 个各自独立的图块 —— 调色板照单全收,
883
+ // 用户看到的就是「一堆一模一样的块」。
884
+ animRows: true
758
885
  });
759
886
  return out;
760
887
  }