@4bitlabs/sci0-renderer 0.1.1 → 1.0.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.
Files changed (85) hide show
  1. package/dist/filters/loop-padding-filter.d.ts +6 -3
  2. package/dist/filters/loop-padding-filter.d.ts.map +1 -1
  3. package/dist/filters/loop-padding-filter.js +25 -30
  4. package/dist/filters/loop-padding-filter.js.map +1 -1
  5. package/dist/filters/menu-text-filter.d.ts +10 -7
  6. package/dist/filters/menu-text-filter.d.ts.map +1 -1
  7. package/dist/filters/menu-text-filter.js +22 -35
  8. package/dist/filters/menu-text-filter.js.map +1 -1
  9. package/dist/index.d.ts +7 -8
  10. package/dist/index.js +5 -12
  11. package/dist/pic/default-palette.js +45 -9
  12. package/dist/pic/default-palette.js.map +1 -1
  13. package/dist/pic/default-palettes.js +9 -9
  14. package/dist/pic/default-palettes.js.map +1 -1
  15. package/dist/pic/generate-pic.d.ts +7 -4
  16. package/dist/pic/generate-pic.d.ts.map +1 -1
  17. package/dist/pic/generate-pic.js +22 -40
  18. package/dist/pic/generate-pic.js.map +1 -1
  19. package/dist/pic/pic-step.js +42 -43
  20. package/dist/pic/pic-step.js.map +1 -1
  21. package/dist/pic/render-pic-options.d.ts +18 -15
  22. package/dist/pic/render-pic-options.d.ts.map +1 -1
  23. package/dist/pic/render-pic.d.ts +7 -4
  24. package/dist/pic/render-pic.d.ts.map +1 -1
  25. package/dist/pic/render-pic.js +18 -40
  26. package/dist/pic/render-pic.js.map +1 -1
  27. package/dist/pic/render-result.d.ts +9 -6
  28. package/dist/pic/render-result.d.ts.map +1 -1
  29. package/dist/pic/screen-buffer.js +64 -67
  30. package/dist/pic/screen-buffer.js.map +1 -1
  31. package/dist/pic/tools/circles.js +82 -84
  32. package/dist/pic/tools/circles.js.map +1 -1
  33. package/dist/pic/tools/create-blitter.js +14 -19
  34. package/dist/pic/tools/create-blitter.js.map +1 -1
  35. package/dist/pic/tools/create-brush.js +22 -34
  36. package/dist/pic/tools/create-brush.js.map +1 -1
  37. package/dist/pic/tools/create-flood-fill.js +43 -60
  38. package/dist/pic/tools/create-flood-fill.js.map +1 -1
  39. package/dist/pic/tools/create-line.js +37 -43
  40. package/dist/pic/tools/create-line.js.map +1 -1
  41. package/dist/pic/tools/index.js +5 -14
  42. package/dist/pic/tools/noise.js +160 -22
  43. package/dist/pic/tools/noise.js.map +1 -1
  44. package/dist/utils/exhaustive.js +5 -4
  45. package/dist/utils/exhaustive.js.map +1 -1
  46. package/package.json +16 -15
  47. package/dist/index.d.ts.map +0 -1
  48. package/dist/index.js.map +0 -1
  49. package/dist/pic/default-palette.d.ts +0 -2
  50. package/dist/pic/default-palette.d.ts.map +0 -1
  51. package/dist/pic/default-palettes.d.ts +0 -3
  52. package/dist/pic/default-palettes.d.ts.map +0 -1
  53. package/dist/pic/pic-step.d.ts +0 -4
  54. package/dist/pic/pic-step.d.ts.map +0 -1
  55. package/dist/pic/render-pic-options.js +0 -3
  56. package/dist/pic/render-pic-options.js.map +0 -1
  57. package/dist/pic/render-result.js +0 -3
  58. package/dist/pic/render-result.js.map +0 -1
  59. package/dist/pic/screen-buffer.d.ts +0 -7
  60. package/dist/pic/screen-buffer.d.ts.map +0 -1
  61. package/dist/pic/tools/circles.d.ts +0 -3
  62. package/dist/pic/tools/circles.d.ts.map +0 -1
  63. package/dist/pic/tools/create-blitter.d.ts +0 -5
  64. package/dist/pic/tools/create-blitter.d.ts.map +0 -1
  65. package/dist/pic/tools/create-brush.d.ts +0 -4
  66. package/dist/pic/tools/create-brush.d.ts.map +0 -1
  67. package/dist/pic/tools/create-flood-fill.d.ts +0 -4
  68. package/dist/pic/tools/create-flood-fill.d.ts.map +0 -1
  69. package/dist/pic/tools/create-line.d.ts +0 -3
  70. package/dist/pic/tools/create-line.d.ts.map +0 -1
  71. package/dist/pic/tools/create-marker.d.ts +0 -3
  72. package/dist/pic/tools/create-marker.d.ts.map +0 -1
  73. package/dist/pic/tools/create-marker.js +0 -11
  74. package/dist/pic/tools/create-marker.js.map +0 -1
  75. package/dist/pic/tools/index.d.ts +0 -6
  76. package/dist/pic/tools/index.d.ts.map +0 -1
  77. package/dist/pic/tools/index.js.map +0 -1
  78. package/dist/pic/tools/noise.d.ts +0 -3
  79. package/dist/pic/tools/noise.d.ts.map +0 -1
  80. package/dist/pic/tools/screen.d.ts +0 -16
  81. package/dist/pic/tools/screen.d.ts.map +0 -1
  82. package/dist/pic/tools/screen.js +0 -3
  83. package/dist/pic/tools/screen.js.map +0 -1
  84. package/dist/utils/exhaustive.d.ts +0 -2
  85. package/dist/utils/exhaustive.d.ts.map +0 -1
@@ -1,4 +1,7 @@
1
- import type { Loop } from '@4bitlabs/sci0';
2
- import type { PixelFilter } from '@4bitlabs/image';
3
- export declare const loopPaddingFilter: (loop: Loop) => PixelFilter;
1
+ import { PixelFilter } from "@4bitlabs/image";
2
+ import { Loop } from "@4bitlabs/sci0";
3
+ //#region src/filters/loop-padding-filter.d.ts
4
+ declare const loopPaddingFilter: (loop: Loop) => PixelFilter;
5
+ //#endregion
6
+ export { loopPaddingFilter };
4
7
  //# sourceMappingURL=loop-padding-filter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"loop-padding-filter.d.ts","sourceRoot":"","sources":["../../src/filters/loop-padding-filter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAO,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAoB,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAGrE,eAAO,MAAM,iBAAiB,SAAU,IAAI,KAAG,WAiC9C,CAAC"}
1
+ {"version":3,"file":"loop-padding-filter.d.ts","names":[],"sources":["../../src/filters/loop-padding-filter.ts"],"mappings":";;;cAIa,oBAAqB,MAAM,SAAO"}
@@ -1,33 +1,28 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loopPaddingFilter = void 0;
4
- const image_1 = require("@4bitlabs/image");
1
+ import { createIndexedPixelData } from "@4bitlabs/image";
2
+ //#region src/filters/loop-padding-filter.ts
5
3
  const loopPaddingFilter = (loop) => {
6
- const { isMirrored, bounds } = loop;
7
- const { left, top, right, width: loopWidth, height: loopHeight } = bounds;
8
- return (source) => {
9
- if (!('dx' in source))
10
- return source;
11
- const dest = (0, image_1.createIndexedPixelData)(loopWidth, loopHeight, {
12
- keyColor: source.keyColor,
13
- });
14
- const sStride = source.width;
15
- const dStride = dest.width;
16
- for (let ySource = 0; ySource < source.height; ySource++) {
17
- const yDest = source.dy - top - source.height + ySource;
18
- for (let xSource = 0; xSource < source.width; xSource++) {
19
- const xActual = isMirrored ? source.width - xSource - 1 : xSource;
20
- const edge = isMirrored
21
- ? +right - source.dx - (source.width & 0b1)
22
- : -left + source.dx;
23
- const xDest = xSource - (source.width >>> 1) + edge;
24
- const destIdx = yDest * dStride + xDest;
25
- const sourceIdx = ySource * sStride + xActual;
26
- dest.pixels[destIdx] = source.pixels[sourceIdx];
27
- }
28
- }
29
- return dest;
30
- };
4
+ const { isMirrored, bounds } = loop;
5
+ const { left, top, right, width: loopWidth, height: loopHeight } = bounds;
6
+ return (source) => {
7
+ if (!("dx" in source)) return source;
8
+ const dest = createIndexedPixelData(loopWidth, loopHeight, { keyColor: source.keyColor });
9
+ const sStride = source.width;
10
+ const dStride = dest.width;
11
+ for (let ySource = 0; ySource < source.height; ySource++) {
12
+ const yDest = source.dy - top - source.height + ySource;
13
+ for (let xSource = 0; xSource < source.width; xSource++) {
14
+ const xActual = isMirrored ? source.width - xSource - 1 : xSource;
15
+ const edge = isMirrored ? +right - source.dx - (source.width & 1) : -left + source.dx;
16
+ const xDest = xSource - (source.width >>> 1) + edge;
17
+ const destIdx = yDest * dStride + xDest;
18
+ const sourceIdx = ySource * sStride + xActual;
19
+ dest.pixels[destIdx] = source.pixels[sourceIdx];
20
+ }
21
+ }
22
+ return dest;
23
+ };
31
24
  };
32
- exports.loopPaddingFilter = loopPaddingFilter;
25
+ //#endregion
26
+ export { loopPaddingFilter };
27
+
33
28
  //# sourceMappingURL=loop-padding-filter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"loop-padding-filter.js","sourceRoot":"","sources":["../../src/filters/loop-padding-filter.ts"],"names":[],"mappings":";;;AAEA,2CAAyD;AAElD,MAAM,iBAAiB,GAAG,CAAC,IAAU,EAAe,EAAE;IAC3D,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACpC,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IAE1E,OAAO,CAAC,MAA8B,EAAoB,EAAE;QAC1D,IAAI,CAAC,CAAC,IAAI,IAAI,MAAM,CAAC;YAAE,OAAO,MAAM,CAAC;QAErC,MAAM,IAAI,GAAG,IAAA,8BAAsB,EAAC,SAAS,EAAE,UAAU,EAAE;YACzD,QAAQ,EAAE,MAAM,CAAC,QAAQ;SAC1B,CAAC,CAAC;QAEH,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC;QAC7B,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC;QAE3B,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC;YACzD,MAAM,KAAK,GAAG,MAAM,CAAC,EAAE,GAAG,GAAG,GAAG,MAAM,CAAC,MAAM,GAAG,OAAO,CAAC;YAExD,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC;gBACxD,MAAM,OAAO,GAAG,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,GAAG,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;gBAElE,MAAM,IAAI,GAAG,UAAU;oBACrB,CAAC,CAAC,CAAC,KAAK,GAAG,MAAM,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK,GAAG,GAAG,CAAC;oBAC3C,CAAC,CAAC,CAAC,IAAI,GAAG,MAAM,CAAC,EAAE,CAAC;gBACtB,MAAM,KAAK,GAAG,OAAO,GAAG,CAAC,MAAM,CAAC,KAAK,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC;gBAEpD,MAAM,OAAO,GAAG,KAAK,GAAG,OAAO,GAAG,KAAK,CAAC;gBACxC,MAAM,SAAS,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;gBAC9C,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YAClD,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC,CAAC;AAjCW,QAAA,iBAAiB,qBAiC5B"}
1
+ {"version":3,"file":"loop-padding-filter.js","names":[],"sources":["../../src/filters/loop-padding-filter.ts"],"sourcesContent":["import type { Loop, Cel } from '@4bitlabs/sci0';\nimport type { IndexedPixelData, PixelFilter } from '@4bitlabs/image';\nimport { createIndexedPixelData } from '@4bitlabs/image';\n\nexport const loopPaddingFilter = (loop: Loop): PixelFilter => {\n const { isMirrored, bounds } = loop;\n const { left, top, right, width: loopWidth, height: loopHeight } = bounds;\n\n return (source: Cel | IndexedPixelData): IndexedPixelData => {\n if (!('dx' in source)) return source;\n\n const dest = createIndexedPixelData(loopWidth, loopHeight, {\n keyColor: source.keyColor,\n });\n\n const sStride = source.width;\n const dStride = dest.width;\n\n for (let ySource = 0; ySource < source.height; ySource++) {\n const yDest = source.dy - top - source.height + ySource;\n\n for (let xSource = 0; xSource < source.width; xSource++) {\n const xActual = isMirrored ? source.width - xSource - 1 : xSource;\n\n const edge = isMirrored\n ? +right - source.dx - (source.width & 0b1)\n : -left + source.dx;\n const xDest = xSource - (source.width >>> 1) + edge;\n\n const destIdx = yDest * dStride + xDest;\n const sourceIdx = ySource * sStride + xActual;\n dest.pixels[destIdx] = source.pixels[sourceIdx];\n }\n }\n\n return dest;\n };\n};\n"],"mappings":";;AAIA,MAAa,qBAAqB,SAA4B;CAC5D,MAAM,EAAE,YAAY,WAAW;CAC/B,MAAM,EAAE,MAAM,KAAK,OAAO,OAAO,WAAW,QAAQ,eAAe;CAEnE,QAAQ,WAAqD;EAC3D,IAAI,EAAE,QAAQ,SAAS,OAAO;EAE9B,MAAM,OAAO,uBAAuB,WAAW,YAAY,EACzD,UAAU,OAAO,SACnB,CAAC;EAED,MAAM,UAAU,OAAO;EACvB,MAAM,UAAU,KAAK;EAErB,KAAK,IAAI,UAAU,GAAG,UAAU,OAAO,QAAQ,WAAW;GACxD,MAAM,QAAQ,OAAO,KAAK,MAAM,OAAO,SAAS;GAEhD,KAAK,IAAI,UAAU,GAAG,UAAU,OAAO,OAAO,WAAW;IACvD,MAAM,UAAU,aAAa,OAAO,QAAQ,UAAU,IAAI;IAE1D,MAAM,OAAO,aACT,CAAC,QAAQ,OAAO,MAAM,OAAO,QAAQ,KACrC,CAAC,OAAO,OAAO;IACnB,MAAM,QAAQ,WAAW,OAAO,UAAU,KAAK;IAE/C,MAAM,UAAU,QAAQ,UAAU;IAClC,MAAM,YAAY,UAAU,UAAU;IACtC,KAAK,OAAO,WAAW,OAAO,OAAO;GACvC;EACF;EAEA,OAAO;CACT;AACF"}
@@ -1,9 +1,12 @@
1
- import type { FontFace } from '@4bitlabs/sci0';
2
- import { PixelFilter } from '@4bitlabs/image';
3
- export interface MenuTextFilterOptions {
4
- font: FontFace;
5
- left?: string;
6
- right?: string;
1
+ import { PixelFilter } from "@4bitlabs/image";
2
+ import { FontFace } from "@4bitlabs/sci0";
3
+ //#region src/filters/menu-text-filter.d.ts
4
+ interface MenuTextFilterOptions {
5
+ font: FontFace;
6
+ left?: string;
7
+ right?: string;
7
8
  }
8
- export declare const menuTextFilter: (ox: number, oy: number, options: MenuTextFilterOptions) => PixelFilter;
9
+ declare const menuTextFilter: (ox: number, oy: number, options: MenuTextFilterOptions) => PixelFilter;
10
+ //#endregion
11
+ export { MenuTextFilterOptions, menuTextFilter };
9
12
  //# sourceMappingURL=menu-text-filter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"menu-text-filter.d.ts","sourceRoot":"","sources":["../../src/filters/menu-text-filter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAA0B,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEtE,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,cAAc,OACrB,MAAM,MACN,MAAM,WACD,qBAAqB,KAC7B,WAoCF,CAAC"}
1
+ {"version":3,"file":"menu-text-filter.d.ts","names":[],"sources":["../../src/filters/menu-text-filter.ts"],"mappings":";;;UAGiB;EACf,MAAM;EACN;EACA;;cAGW,iBACX,YACA,YACA,SAAS,0BACR"}
@@ -1,38 +1,25 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.menuTextFilter = void 0;
4
- const image_1 = require("@4bitlabs/image");
1
+ import { createIndexedPixelData } from "@4bitlabs/image";
2
+ //#region src/filters/menu-text-filter.ts
5
3
  const menuTextFilter = (ox, oy, options) => {
6
- const { font, left = '', right = '' } = options;
7
- return (it) => {
8
- const output = (0, image_1.createIndexedPixelData)(it.width, it.height + 10);
9
- output.pixels.set(it.pixels, it.width * 10);
10
- for (let i = 0; i < it.width * 10; i++) {
11
- output.pixels[i] = 0xff;
12
- }
13
- left.split('').reduce(($x, ch) => {
14
- const glyph = font.characters[ch.charCodeAt(0)];
15
- for (let y = 0; y < glyph.height; y++)
16
- for (let x = 0; x < glyph.width; x++) {
17
- if (glyph.pixels[y * glyph.width + x])
18
- output.pixels[(y + oy) * it.width + ($x + x + ox)] = 0x00;
19
- }
20
- return $x + glyph.width;
21
- }, 0);
22
- `${right} \u0001`
23
- .split('')
24
- .reverse()
25
- .reduce(($x, ch) => {
26
- const glyph = font.characters[ch.charCodeAt(0)];
27
- for (let y = 0; y < glyph.height; y++)
28
- for (let x = 0; x < glyph.width; x++) {
29
- if (glyph.pixels[y * glyph.width + x])
30
- output.pixels[(y + oy) * it.width + (it.width - $x - glyph.width - ox + x)] = 0x00;
31
- }
32
- return $x + glyph.width;
33
- }, 0);
34
- return output;
35
- };
4
+ const { font, left = "", right = "" } = options;
5
+ return (it) => {
6
+ const output = createIndexedPixelData(it.width, it.height + 10);
7
+ output.pixels.set(it.pixels, it.width * 10);
8
+ for (let i = 0; i < it.width * 10; i++) output.pixels[i] = 255;
9
+ left.split("").reduce(($x, ch) => {
10
+ const glyph = font.characters[ch.charCodeAt(0)];
11
+ for (let y = 0; y < glyph.height; y++) for (let x = 0; x < glyph.width; x++) if (glyph.pixels[y * glyph.width + x]) output.pixels[(y + oy) * it.width + ($x + x + ox)] = 0;
12
+ return $x + glyph.width;
13
+ }, 0);
14
+ `${right} \u0001`.split("").reverse().reduce(($x, ch) => {
15
+ const glyph = font.characters[ch.charCodeAt(0)];
16
+ for (let y = 0; y < glyph.height; y++) for (let x = 0; x < glyph.width; x++) if (glyph.pixels[y * glyph.width + x]) output.pixels[(y + oy) * it.width + (it.width - $x - glyph.width - ox + x)] = 0;
17
+ return $x + glyph.width;
18
+ }, 0);
19
+ return output;
20
+ };
36
21
  };
37
- exports.menuTextFilter = menuTextFilter;
22
+ //#endregion
23
+ export { menuTextFilter };
24
+
38
25
  //# sourceMappingURL=menu-text-filter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"menu-text-filter.js","sourceRoot":"","sources":["../../src/filters/menu-text-filter.ts"],"names":[],"mappings":";;;AACA,2CAAsE;AAQ/D,MAAM,cAAc,GAAG,CAC5B,EAAU,EACV,EAAU,EACV,OAA8B,EACjB,EAAE;IACf,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,EAAE,EAAE,KAAK,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC;IAEhD,OAAO,CAAC,EAAE,EAAE,EAAE;QACZ,MAAM,MAAM,GAAG,IAAA,8BAAsB,EAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;QAChE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC;QAC5C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;YACvC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;QAC1B,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;YAC/B,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;YAChD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE;gBACnC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;oBACrC,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC;wBACnC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC;gBAC9D,CAAC;YACH,OAAO,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC;QAC1B,CAAC,EAAE,CAAC,CAAC,CAAC;QAEN,GAAG,KAAK,SAAS;aACd,KAAK,CAAC,EAAE,CAAC;aACT,OAAO,EAAE;aACT,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;YACjB,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;YAChD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE;gBACnC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;oBACrC,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC;wBACnC,MAAM,CAAC,MAAM,CACX,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC,KAAK,GAAG,EAAE,GAAG,KAAK,CAAC,KAAK,GAAG,EAAE,GAAG,CAAC,CAAC,CAC7D,GAAG,IAAI,CAAC;gBACb,CAAC;YACH,OAAO,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC;QAC1B,CAAC,EAAE,CAAC,CAAC,CAAC;QAER,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC,CAAC;AAxCW,QAAA,cAAc,kBAwCzB"}
1
+ {"version":3,"file":"menu-text-filter.js","names":[],"sources":["../../src/filters/menu-text-filter.ts"],"sourcesContent":["import type { FontFace } from '@4bitlabs/sci0';\nimport { createIndexedPixelData, type PixelFilter } from '@4bitlabs/image';\n\nexport interface MenuTextFilterOptions {\n font: FontFace;\n left?: string;\n right?: string;\n}\n\nexport const menuTextFilter = (\n ox: number,\n oy: number,\n options: MenuTextFilterOptions,\n): PixelFilter => {\n const { font, left = '', right = '' } = options;\n\n return (it) => {\n const output = createIndexedPixelData(it.width, it.height + 10);\n output.pixels.set(it.pixels, it.width * 10);\n for (let i = 0; i < it.width * 10; i++) {\n output.pixels[i] = 0xff;\n }\n left.split('').reduce(($x, ch) => {\n const glyph = font.characters[ch.charCodeAt(0)];\n for (let y = 0; y < glyph.height; y++)\n for (let x = 0; x < glyph.width; x++) {\n if (glyph.pixels[y * glyph.width + x])\n output.pixels[(y + oy) * it.width + ($x + x + ox)] = 0x00;\n }\n return $x + glyph.width;\n }, 0);\n\n `${right} \\u0001`\n .split('')\n .reverse()\n .reduce(($x, ch) => {\n const glyph = font.characters[ch.charCodeAt(0)];\n for (let y = 0; y < glyph.height; y++)\n for (let x = 0; x < glyph.width; x++) {\n if (glyph.pixels[y * glyph.width + x])\n output.pixels[\n (y + oy) * it.width + (it.width - $x - glyph.width - ox + x)\n ] = 0x00;\n }\n return $x + glyph.width;\n }, 0);\n\n return output;\n };\n};\n"],"mappings":";;AASA,MAAa,kBACX,IACA,IACA,YACgB;CAChB,MAAM,EAAE,MAAM,OAAO,IAAI,QAAQ,OAAO;CAExC,QAAQ,OAAO;EACb,MAAM,SAAS,uBAAuB,GAAG,OAAO,GAAG,SAAS,EAAE;EAC9D,OAAO,OAAO,IAAI,GAAG,QAAQ,GAAG,QAAQ,EAAE;EAC1C,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,QAAQ,IAAI,KACjC,OAAO,OAAO,KAAK;EAErB,KAAK,MAAM,EAAE,CAAC,CAAC,QAAQ,IAAI,OAAO;GAChC,MAAM,QAAQ,KAAK,WAAW,GAAG,WAAW,CAAC;GAC7C,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAChC,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,OAAO,KAC/B,IAAI,MAAM,OAAO,IAAI,MAAM,QAAQ,IACjC,OAAO,QAAQ,IAAI,MAAM,GAAG,SAAS,KAAK,IAAI,OAAO;GAE3D,OAAO,KAAK,MAAM;EACpB,GAAG,CAAC;EAEJ,GAAG,MAAM,SACN,MAAM,EAAE,CAAC,CACT,QAAQ,CAAC,CACT,QAAQ,IAAI,OAAO;GAClB,MAAM,QAAQ,KAAK,WAAW,GAAG,WAAW,CAAC;GAC7C,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAChC,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,OAAO,KAC/B,IAAI,MAAM,OAAO,IAAI,MAAM,QAAQ,IACjC,OAAO,QACJ,IAAI,MAAM,GAAG,SAAS,GAAG,QAAQ,KAAK,MAAM,QAAQ,KAAK,MACxD;GAEV,OAAO,KAAK,MAAM;EACpB,GAAG,CAAC;EAEN,OAAO;CACT;AACF"}
package/dist/index.d.ts CHANGED
@@ -1,8 +1,7 @@
1
- export { loopPaddingFilter } from './filters/loop-padding-filter';
2
- export type { MenuTextFilterOptions } from './filters/menu-text-filter';
3
- export { menuTextFilter } from './filters/menu-text-filter';
4
- export type { RenderResult } from './pic/render-result';
5
- export type { RenderPicOptions } from './pic/render-pic-options';
6
- export { renderPic } from './pic/render-pic';
7
- export { generatePic } from './pic/generate-pic';
8
- //# sourceMappingURL=index.d.ts.map
1
+ import { loopPaddingFilter } from "./filters/loop-padding-filter.js";
2
+ import { MenuTextFilterOptions, menuTextFilter } from "./filters/menu-text-filter.js";
3
+ import { RenderResult } from "./pic/render-result.js";
4
+ import { RenderPicOptions } from "./pic/render-pic-options.js";
5
+ import { renderPic } from "./pic/render-pic.js";
6
+ import { generatePic } from "./pic/generate-pic.js";
7
+ export { type MenuTextFilterOptions, type RenderPicOptions, type RenderResult, generatePic, loopPaddingFilter, menuTextFilter, renderPic };
package/dist/index.js CHANGED
@@ -1,12 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generatePic = exports.renderPic = exports.menuTextFilter = exports.loopPaddingFilter = void 0;
4
- var loop_padding_filter_1 = require("./filters/loop-padding-filter");
5
- Object.defineProperty(exports, "loopPaddingFilter", { enumerable: true, get: function () { return loop_padding_filter_1.loopPaddingFilter; } });
6
- var menu_text_filter_1 = require("./filters/menu-text-filter");
7
- Object.defineProperty(exports, "menuTextFilter", { enumerable: true, get: function () { return menu_text_filter_1.menuTextFilter; } });
8
- var render_pic_1 = require("./pic/render-pic");
9
- Object.defineProperty(exports, "renderPic", { enumerable: true, get: function () { return render_pic_1.renderPic; } });
10
- var generate_pic_1 = require("./pic/generate-pic");
11
- Object.defineProperty(exports, "generatePic", { enumerable: true, get: function () { return generate_pic_1.generatePic; } });
12
- //# sourceMappingURL=index.js.map
1
+ import { loopPaddingFilter } from "./filters/loop-padding-filter.js";
2
+ import { menuTextFilter } from "./filters/menu-text-filter.js";
3
+ import { renderPic } from "./pic/render-pic.js";
4
+ import { generatePic } from "./pic/generate-pic.js";
5
+ export { generatePic, loopPaddingFilter, menuTextFilter, renderPic };
@@ -1,11 +1,47 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_PALETTE = void 0;
4
- // prettier-ignore
5
- exports.DEFAULT_PALETTE = [
6
- 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99,
7
- 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0x88, 0x88, 0x01, 0x02, 0x03,
8
- 0x04, 0x05, 0x06, 0x88, 0x88, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd,
9
- 0xfe, 0xff, 0x08, 0x91, 0x2a, 0x3b, 0x4c, 0x5d, 0x6e, 0x88,
1
+ //#region src/pic/default-palette.ts
2
+ const DEFAULT_PALETTE = [
3
+ 0,
4
+ 17,
5
+ 34,
6
+ 51,
7
+ 68,
8
+ 85,
9
+ 102,
10
+ 119,
11
+ 136,
12
+ 153,
13
+ 170,
14
+ 187,
15
+ 204,
16
+ 221,
17
+ 238,
18
+ 136,
19
+ 136,
20
+ 1,
21
+ 2,
22
+ 3,
23
+ 4,
24
+ 5,
25
+ 6,
26
+ 136,
27
+ 136,
28
+ 249,
29
+ 250,
30
+ 251,
31
+ 252,
32
+ 253,
33
+ 254,
34
+ 255,
35
+ 8,
36
+ 145,
37
+ 42,
38
+ 59,
39
+ 76,
40
+ 93,
41
+ 110,
42
+ 136
10
43
  ];
44
+ //#endregion
45
+ export { DEFAULT_PALETTE };
46
+
11
47
  //# sourceMappingURL=default-palette.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"default-palette.js","sourceRoot":"","sources":["../../src/pic/default-palette.ts"],"names":[],"mappings":";;;AAAA,kBAAkB;AACL,QAAA,eAAe,GAAG;IAC7B,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IAC1D,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IAC1D,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IAC1D,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;CAClD,CAAC"}
1
+ {"version":3,"file":"default-palette.js","names":[],"sources":["../../src/pic/default-palette.ts"],"sourcesContent":["// biome-ignore format: readability\nexport const DEFAULT_PALETTE = [\n 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99,\n 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0x88, 0x88, 0x01, 0x02, 0x03,\n 0x04, 0x05, 0x06, 0x88, 0x88, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd,\n 0xfe, 0xff, 0x08, 0x91, 0x2a, 0x3b, 0x4c, 0x5d, 0x6e, 0x88,\n] as const;\n"],"mappings":";AACA,MAAa,kBAAkB;CAC7B;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CACtD;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CACtD;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CACtD;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;AACxD"}
@@ -1,12 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defaultPalettes = void 0;
4
- const default_palette_1 = require("./default-palette");
1
+ import { DEFAULT_PALETTE } from "./default-palette.js";
2
+ //#region src/pic/default-palettes.ts
5
3
  const defaultPalettes = () => [
6
- Uint8Array.from(default_palette_1.DEFAULT_PALETTE),
7
- Uint8Array.from(default_palette_1.DEFAULT_PALETTE),
8
- Uint8Array.from(default_palette_1.DEFAULT_PALETTE),
9
- Uint8Array.from(default_palette_1.DEFAULT_PALETTE),
4
+ Uint8Array.from(DEFAULT_PALETTE),
5
+ Uint8Array.from(DEFAULT_PALETTE),
6
+ Uint8Array.from(DEFAULT_PALETTE),
7
+ Uint8Array.from(DEFAULT_PALETTE)
10
8
  ];
11
- exports.defaultPalettes = defaultPalettes;
9
+ //#endregion
10
+ export { defaultPalettes };
11
+
12
12
  //# sourceMappingURL=default-palettes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"default-palettes.js","sourceRoot":"","sources":["../../src/pic/default-palettes.ts"],"names":[],"mappings":";;;AAAA,uDAAoD;AAI7C,MAAM,eAAe,GAAG,GAAe,EAAE,CAAC;IAC/C,UAAU,CAAC,IAAI,CAAC,iCAAe,CAAC;IAChC,UAAU,CAAC,IAAI,CAAC,iCAAe,CAAC;IAChC,UAAU,CAAC,IAAI,CAAC,iCAAe,CAAC;IAChC,UAAU,CAAC,IAAI,CAAC,iCAAe,CAAC;CACjC,CAAC;AALW,QAAA,eAAe,mBAK1B"}
1
+ {"version":3,"file":"default-palettes.js","names":[],"sources":["../../src/pic/default-palettes.ts"],"sourcesContent":["import { DEFAULT_PALETTE } from './default-palette.js';\n\nexport type PaletteSet = [Uint8Array, Uint8Array, Uint8Array, Uint8Array];\n\nexport const defaultPalettes = (): PaletteSet => [\n Uint8Array.from(DEFAULT_PALETTE),\n Uint8Array.from(DEFAULT_PALETTE),\n Uint8Array.from(DEFAULT_PALETTE),\n Uint8Array.from(DEFAULT_PALETTE),\n];\n"],"mappings":";;AAIA,MAAa,wBAAoC;CAC/C,WAAW,KAAK,eAAe;CAC/B,WAAW,KAAK,eAAe;CAC/B,WAAW,KAAK,eAAe;CAC/B,WAAW,KAAK,eAAe;AACjC"}
@@ -1,6 +1,7 @@
1
- import type { DrawCommand, Pic } from '@4bitlabs/sci0';
2
- import { RenderPicOptions } from './render-pic-options';
3
- import { RenderResult } from './render-result';
1
+ import { RenderResult } from "./render-result.js";
2
+ import { RenderPicOptions } from "./render-pic-options.js";
3
+ import { DrawCommand, Pic } from "@4bitlabs/sci0";
4
+ //#region src/pic/generate-pic.d.ts
4
5
  /**
5
6
  * Generate a {@link Pic} iterator that will emit after processing each {@link DrawCommand} is processed.
6
7
  *
@@ -24,5 +25,7 @@ import { RenderResult } from './render-result';
24
25
  * }
25
26
  * ```
26
27
  */
27
- export declare function generatePic(pic: Pic, options?: RenderPicOptions): Generator<[idx: number, command: DrawCommand, layers: RenderResult]>;
28
+ declare function generatePic(pic: Pic, options?: RenderPicOptions): Generator<[idx: number, command: DrawCommand, layers: RenderResult]>;
29
+ //#endregion
30
+ export { generatePic };
28
31
  //# sourceMappingURL=generate-pic.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate-pic.d.ts","sourceRoot":"","sources":["../../src/pic/generate-pic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAK/C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAiB,WAAW,CAC1B,GAAG,EAAE,GAAG,EACR,OAAO,GAAE,gBAAqB,GAC7B,SAAS,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC,CActE"}
1
+ {"version":3,"file":"generate-pic.d.ts","names":[],"sources":["../../src/pic/generate-pic.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;iBA+BiB,YACf,KAAK,KACL,UAAS,mBACR,WAAW,aAAa,SAAS,aAAa,QAAQ"}
@@ -1,43 +1,25 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generatePic = generatePic;
4
- const default_palettes_1 = require("./default-palettes");
5
- const screen_buffer_1 = require("./screen-buffer");
6
- const pic_step_1 = require("./pic-step");
7
- /**
8
- * Generate a {@link Pic} iterator that will emit after processing each {@link DrawCommand} is processed.
9
- *
10
- * @param pic Picture data.
11
- * @param options
12
- *
13
- * @example
14
- * ```ts
15
- * import { parsePic } from '@4bitlabs/sci0';
16
- * import { generatePic } from '@4bitlabs/sci0-renderer';
17
- * import { CGA } from '@4bitlabs/color/dithers';
18
- * import { createDitherFilter, renderPixelData } from '@4bitlabs/image';
19
- *
20
- * const classicPipeline = { render: createDitherFilter(CGA) };
21
- *
22
- * const picData = parsePic(data, { defer: true });
23
- * for (const [idx, cmd, layers] of generatePic(visible) {
24
- * const { visible } = layers;
25
- * const image = renderPixelData(visible, classicPipeline);
26
- * saveImage(`frame${idx}.png`, image);
27
- * }
28
- * ```
29
- */
1
+ import { createScreenBuffer } from "./screen-buffer.js";
2
+ import { picStep } from "./pic-step.js";
3
+ import { defaultPalettes } from "./default-palettes.js";
4
+ //#region src/pic/generate-pic.ts
30
5
  function* generatePic(pic, options = {}) {
31
- const { forcePal, width = 320, height = 190 } = options;
32
- const size = [width, height];
33
- const palettes = (0, default_palettes_1.defaultPalettes)();
34
- const [result, screen, tick] = (0, screen_buffer_1.createScreenBuffer)(forcePal, palettes, size);
35
- let step = 0;
36
- for (const cmd of pic) {
37
- tick(step);
38
- (0, pic_step_1.picStep)(cmd, screen, palettes);
39
- yield [step, cmd, result];
40
- step += 1;
41
- }
6
+ const { forcePal, width = 320, height = 190 } = options;
7
+ const size = [width, height];
8
+ const palettes = defaultPalettes();
9
+ const [result, screen, tick] = createScreenBuffer(forcePal, palettes, size);
10
+ let step = 0;
11
+ for (const cmd of pic) {
12
+ tick(step);
13
+ picStep(cmd, screen, palettes);
14
+ yield [
15
+ step,
16
+ cmd,
17
+ result
18
+ ];
19
+ step += 1;
20
+ }
42
21
  }
22
+ //#endregion
23
+ export { generatePic };
24
+
43
25
  //# sourceMappingURL=generate-pic.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate-pic.js","sourceRoot":"","sources":["../../src/pic/generate-pic.ts"],"names":[],"mappings":";;AA+BA,kCAiBC;AA5CD,yDAAqD;AACrD,mDAAqD;AACrD,yCAAqC;AAErC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,QAAe,CAAC,CAAC,WAAW,CAC1B,GAAQ,EACR,UAA4B,EAAE;IAE9B,MAAM,EAAE,QAAQ,EAAE,KAAK,GAAG,GAAG,EAAE,MAAM,GAAG,GAAG,EAAE,GAAG,OAAO,CAAC;IACxD,MAAM,IAAI,GAAS,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAEnC,MAAM,QAAQ,GAAG,IAAA,kCAAe,GAAE,CAAC;IACnC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,IAAA,kCAAkB,EAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;IAE5E,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,IAAI,CAAC,CAAC;QACX,IAAA,kBAAO,EAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;QAC/B,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;QAC1B,IAAI,IAAI,CAAC,CAAC;IACZ,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"generate-pic.js","names":[],"sources":["../../src/pic/generate-pic.ts"],"sourcesContent":["import type { DrawCommand, Pic } from '@4bitlabs/sci0';\nimport type { Vec2 } from '@4bitlabs/vec2';\nimport type { RenderPicOptions } from './render-pic-options.js';\nimport type { RenderResult } from './render-result.js';\nimport { defaultPalettes } from './default-palettes.js';\nimport { createScreenBuffer } from './screen-buffer.js';\nimport { picStep } from './pic-step.js';\n\n/**\n * Generate a {@link Pic} iterator that will emit after processing each {@link DrawCommand} is processed.\n *\n * @param pic Picture data.\n * @param options\n *\n * @example\n * ```ts\n * import { parsePic } from '@4bitlabs/sci0';\n * import { generatePic } from '@4bitlabs/sci0-renderer';\n * import { CGA } from '@4bitlabs/color/dithers';\n * import { createDitherFilter, renderPixelData } from '@4bitlabs/image';\n *\n * const classicPipeline = { render: createDitherFilter(CGA) };\n *\n * const picData = parsePic(data, { defer: true });\n * for (const [idx, cmd, layers] of generatePic(visible) {\n * const { visible } = layers;\n * const image = renderPixelData(visible, classicPipeline);\n * saveImage(`frame${idx}.png`, image);\n * }\n * ```\n */\nexport function* generatePic(\n pic: Pic,\n options: RenderPicOptions = {},\n): Generator<[idx: number, command: DrawCommand, layers: RenderResult]> {\n const { forcePal, width = 320, height = 190 } = options;\n const size: Vec2 = [width, height];\n\n const palettes = defaultPalettes();\n const [result, screen, tick] = createScreenBuffer(forcePal, palettes, size);\n\n let step = 0;\n for (const cmd of pic) {\n tick(step);\n picStep(cmd, screen, palettes);\n yield [step, cmd, result];\n step += 1;\n }\n}\n"],"mappings":";;;;AA+BA,UAAiB,YACf,KACA,UAA4B,CAAC,GACyC;CACtE,MAAM,EAAE,UAAU,QAAQ,KAAK,SAAS,QAAQ;CAChD,MAAM,OAAa,CAAC,OAAO,MAAM;CAEjC,MAAM,WAAW,gBAAgB;CACjC,MAAM,CAAC,QAAQ,QAAQ,QAAQ,mBAAmB,UAAU,UAAU,IAAI;CAE1E,IAAI,OAAO;CACX,KAAK,MAAM,OAAO,KAAK;EACrB,KAAK,IAAI;EACT,QAAQ,KAAK,QAAQ,QAAQ;EAC7B,MAAM;GAAC;GAAM;GAAK;EAAM;EACxB,QAAQ;CACV;AACF"}
@@ -1,46 +1,45 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.picStep = picStep;
4
- const exhaustive_1 = require("../utils/exhaustive");
1
+ import { exhaustive } from "../utils/exhaustive.js";
2
+ //#region src/pic/pic-step.ts
5
3
  function picStep(cmd, { fill, line, brush, blit }, palettes) {
6
- const [mode] = cmd;
7
- switch (mode) {
8
- case 'SET_PALETTE': {
9
- const [, [idx], ...palette] = cmd;
10
- palettes[idx].set(palette);
11
- break;
12
- }
13
- case 'UPDATE_PALETTE': {
14
- const [, , ...entries] = cmd;
15
- entries.forEach(([pal, idx, color]) => {
16
- palettes[pal][idx] = color;
17
- });
18
- break;
19
- }
20
- case 'FILL': {
21
- const [, [drawMode, drawCodes], pos] = cmd;
22
- const [x, y] = pos;
23
- fill(x, y, drawMode, drawCodes);
24
- break;
25
- }
26
- case 'PLINE': {
27
- const [, [drawMode, drawCodes], ...points] = cmd;
28
- for (let p = 0; p < points.length - 1; p++)
29
- line(points[p][0], points[p][1], points[p + 1][0], points[p + 1][1], drawMode, drawCodes);
30
- break;
31
- }
32
- case 'BRUSH': {
33
- const [, brushOptions, [cx, cy]] = cmd;
34
- brush(cx, cy, ...brushOptions);
35
- break;
36
- }
37
- case 'CEL': {
38
- const [, [drawMode], [x, y], cel] = cmd;
39
- blit(x, y, drawMode, cel);
40
- break;
41
- }
42
- default:
43
- (0, exhaustive_1.exhaustive)('unhandled opcode', mode);
44
- }
4
+ const [mode] = cmd;
5
+ switch (mode) {
6
+ case "SET_PALETTE": {
7
+ const [, [idx], ...palette] = cmd;
8
+ palettes[idx].set(palette);
9
+ break;
10
+ }
11
+ case "UPDATE_PALETTE": {
12
+ const [, , ...entries] = cmd;
13
+ entries.forEach(([pal, idx, color]) => {
14
+ palettes[pal][idx] = color;
15
+ });
16
+ break;
17
+ }
18
+ case "FILL": {
19
+ const [, [drawMode, drawCodes], pos] = cmd;
20
+ const [x, y] = pos;
21
+ fill(x, y, drawMode, drawCodes);
22
+ break;
23
+ }
24
+ case "PLINE": {
25
+ const [, [drawMode, drawCodes], ...points] = cmd;
26
+ for (let p = 0; p < points.length - 1; p++) line(points[p][0], points[p][1], points[p + 1][0], points[p + 1][1], drawMode, drawCodes);
27
+ break;
28
+ }
29
+ case "BRUSH": {
30
+ const [, brushOptions, [cx, cy]] = cmd;
31
+ brush(cx, cy, ...brushOptions);
32
+ break;
33
+ }
34
+ case "CEL": {
35
+ const [, [drawMode], [x, y], cel] = cmd;
36
+ blit(x, y, drawMode, cel);
37
+ break;
38
+ }
39
+ default: exhaustive("unhandled opcode", mode);
40
+ }
45
41
  }
42
+ //#endregion
43
+ export { picStep };
44
+
46
45
  //# sourceMappingURL=pic-step.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pic-step.js","sourceRoot":"","sources":["../../src/pic/pic-step.ts"],"names":[],"mappings":";;AAIA,0BAmDC;AArDD,oDAAiD;AAEjD,SAAgB,OAAO,CACrB,GAAgB,EAChB,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAU,EACnC,QAA0D;IAE1D,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC;IACnB,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,aAAa,CAAC,CAAC,CAAC;YACnB,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,OAAO,CAAC,GAAG,GAAG,CAAC;YAClC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAC3B,MAAM;QACR,CAAC;QACD,KAAK,gBAAgB,CAAC,CAAC,CAAC;YACtB,MAAM,CAAC,EAAE,AAAD,EAAG,GAAG,OAAO,CAAC,GAAG,GAAG,CAAC;YAC7B,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;gBACpC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YAC7B,CAAC,CAAC,CAAC;YACH,MAAM;QACR,CAAC;QACD,KAAK,MAAM,CAAC,CAAC,CAAC;YACZ,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC;YAC3C,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC;YACnB,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;YAChC,MAAM;QACR,CAAC;QACD,KAAK,OAAO,CAAC,CAAC,CAAC;YACb,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAE,GAAG,MAAM,CAAC,GAAG,GAAG,CAAC;YACjD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE;gBACxC,IAAI,CACF,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EACZ,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EACZ,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAChB,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAChB,QAAQ,EACR,SAAS,CACV,CAAC;YACJ,MAAM;QACR,CAAC;QACD,KAAK,OAAO,CAAC,CAAC,CAAC;YACb,MAAM,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC;YACvC,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,GAAG,YAAY,CAAC,CAAC;YAC/B,MAAM;QACR,CAAC;QACD,KAAK,KAAK,CAAC,CAAC,CAAC;YACX,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC;YACxC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;YAC1B,MAAM;QACR,CAAC;QACD;YACE,IAAA,uBAAU,EAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;IACzC,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"pic-step.js","names":[],"sources":["../../src/pic/pic-step.ts"],"sourcesContent":["import type { DrawCommand } from '@4bitlabs/sci0';\nimport type { Screen } from './tools/screen.js';\nimport { exhaustive } from '../utils/exhaustive.js';\n\nexport function picStep(\n cmd: DrawCommand,\n { fill, line, brush, blit }: Screen,\n palettes: [Uint8Array, Uint8Array, Uint8Array, Uint8Array],\n): void {\n const [mode] = cmd;\n switch (mode) {\n case 'SET_PALETTE': {\n const [, [idx], ...palette] = cmd;\n palettes[idx].set(palette);\n break;\n }\n case 'UPDATE_PALETTE': {\n const [, , ...entries] = cmd;\n entries.forEach(([pal, idx, color]) => {\n palettes[pal][idx] = color;\n });\n break;\n }\n case 'FILL': {\n const [, [drawMode, drawCodes], pos] = cmd;\n const [x, y] = pos;\n fill(x, y, drawMode, drawCodes);\n break;\n }\n case 'PLINE': {\n const [, [drawMode, drawCodes], ...points] = cmd;\n for (let p = 0; p < points.length - 1; p++)\n line(\n points[p][0],\n points[p][1],\n points[p + 1][0],\n points[p + 1][1],\n drawMode,\n drawCodes,\n );\n break;\n }\n case 'BRUSH': {\n const [, brushOptions, [cx, cy]] = cmd;\n brush(cx, cy, ...brushOptions);\n break;\n }\n case 'CEL': {\n const [, [drawMode], [x, y], cel] = cmd;\n blit(x, y, drawMode, cel);\n break;\n }\n default:\n exhaustive('unhandled opcode', mode);\n }\n}\n"],"mappings":";;AAIA,SAAgB,QACd,KACA,EAAE,MAAM,MAAM,OAAO,QACrB,UACM;CACN,MAAM,CAAC,QAAQ;CACf,QAAQ,MAAR;EACE,KAAK,eAAe;GAClB,MAAM,GAAG,CAAC,MAAM,GAAG,WAAW;GAC9B,SAAS,IAAI,CAAC,IAAI,OAAO;GACzB;EACF;EACA,KAAK,kBAAkB;GACrB,MAAM,KAAK,GAAG,WAAW;GACzB,QAAQ,SAAS,CAAC,KAAK,KAAK,WAAW;IACrC,SAAS,IAAI,CAAC,OAAO;GACvB,CAAC;GACD;EACF;EACA,KAAK,QAAQ;GACX,MAAM,GAAG,CAAC,UAAU,YAAY,OAAO;GACvC,MAAM,CAAC,GAAG,KAAK;GACf,KAAK,GAAG,GAAG,UAAU,SAAS;GAC9B;EACF;EACA,KAAK,SAAS;GACZ,MAAM,GAAG,CAAC,UAAU,YAAY,GAAG,UAAU;GAC7C,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,SAAS,GAAG,KACrC,KACE,OAAO,EAAE,CAAC,IACV,OAAO,EAAE,CAAC,IACV,OAAO,IAAI,EAAE,CAAC,IACd,OAAO,IAAI,EAAE,CAAC,IACd,UACA,SACF;GACF;EACF;EACA,KAAK,SAAS;GACZ,MAAM,GAAG,cAAc,CAAC,IAAI,OAAO;GACnC,MAAM,IAAI,IAAI,GAAG,YAAY;GAC7B;EACF;EACA,KAAK,OAAO;GACV,MAAM,GAAG,CAAC,WAAW,CAAC,GAAG,IAAI,OAAO;GACpC,KAAK,GAAG,GAAG,UAAU,GAAG;GACxB;EACF;EACA,SACE,WAAW,oBAAoB,IAAI;CACvC;AACF"}
@@ -1,17 +1,20 @@
1
- export interface RenderPicOptions {
2
- /**
3
- * Force the selection of SCI0 palette 0&ndash;3.
4
- */
5
- forcePal?: 0 | 1 | 2 | 3 | undefined;
6
- /**
7
- * The stage width.
8
- * @default 320
9
- */
10
- width?: number;
11
- /**
12
- * The stage height.
13
- * @default 190
14
- */
15
- height?: number;
1
+ //#region src/pic/render-pic-options.d.ts
2
+ interface RenderPicOptions {
3
+ /**
4
+ * Force the selection of SCI0 palette 0&ndash;3.
5
+ */
6
+ forcePal?: 0 | 1 | 2 | 3 | undefined;
7
+ /**
8
+ * The stage width.
9
+ * @default 320
10
+ */
11
+ width?: number;
12
+ /**
13
+ * The stage height.
14
+ * @default 190
15
+ */
16
+ height?: number;
16
17
  }
18
+ //#endregion
19
+ export { RenderPicOptions };
17
20
  //# sourceMappingURL=render-pic-options.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"render-pic-options.d.ts","sourceRoot":"","sources":["../../src/pic/render-pic-options.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;IAErC;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
1
+ {"version":3,"file":"render-pic-options.d.ts","names":[],"sources":["../../src/pic/render-pic-options.ts"],"mappings":";UAAiB;;;;EAIf;;;;;EAMA;;;;;EAMA"}
@@ -1,6 +1,7 @@
1
- import type { Pic } from '@4bitlabs/sci0';
2
- import { RenderResult } from './render-result';
3
- import { RenderPicOptions } from './render-pic-options';
1
+ import { RenderResult } from "./render-result.js";
2
+ import { RenderPicOptions } from "./render-pic-options.js";
3
+ import { Pic } from "@4bitlabs/sci0";
4
+ //#region src/pic/render-pic.d.ts
4
5
  /**
5
6
  * Render a {@link Pic} resource into its composite layers.
6
7
  *
@@ -23,5 +24,7 @@ import { RenderPicOptions } from './render-pic-options';
23
24
  * });
24
25
  * ```
25
26
  */
26
- export declare const renderPic: (pic: Pic, options?: RenderPicOptions) => RenderResult;
27
+ declare const renderPic: (pic: Pic, options?: RenderPicOptions) => RenderResult;
28
+ //#endregion
29
+ export { renderPic };
27
30
  //# sourceMappingURL=render-pic.d.ts.map