@4bitlabs/sci0-renderer 0.1.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 (87) hide show
  1. package/LICENSE.txt +10 -0
  2. package/README.md +17 -0
  3. package/dist/filters/loop-padding-filter.d.ts +4 -0
  4. package/dist/filters/loop-padding-filter.d.ts.map +1 -0
  5. package/dist/filters/loop-padding-filter.js +33 -0
  6. package/dist/filters/loop-padding-filter.js.map +1 -0
  7. package/dist/filters/menu-text-filter.d.ts +9 -0
  8. package/dist/filters/menu-text-filter.d.ts.map +1 -0
  9. package/dist/filters/menu-text-filter.js +38 -0
  10. package/dist/filters/menu-text-filter.js.map +1 -0
  11. package/dist/index.d.ts +8 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +12 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/pic/default-palette.d.ts +2 -0
  16. package/dist/pic/default-palette.d.ts.map +1 -0
  17. package/dist/pic/default-palette.js +11 -0
  18. package/dist/pic/default-palette.js.map +1 -0
  19. package/dist/pic/default-palettes.d.ts +3 -0
  20. package/dist/pic/default-palettes.d.ts.map +1 -0
  21. package/dist/pic/default-palettes.js +12 -0
  22. package/dist/pic/default-palettes.js.map +1 -0
  23. package/dist/pic/generate-pic.d.ts +28 -0
  24. package/dist/pic/generate-pic.d.ts.map +1 -0
  25. package/dist/pic/generate-pic.js +43 -0
  26. package/dist/pic/generate-pic.js.map +1 -0
  27. package/dist/pic/pic-step.d.ts +4 -0
  28. package/dist/pic/pic-step.d.ts.map +1 -0
  29. package/dist/pic/pic-step.js +46 -0
  30. package/dist/pic/pic-step.js.map +1 -0
  31. package/dist/pic/render-pic-options.d.ts +17 -0
  32. package/dist/pic/render-pic-options.d.ts.map +1 -0
  33. package/dist/pic/render-pic-options.js +3 -0
  34. package/dist/pic/render-pic-options.js.map +1 -0
  35. package/dist/pic/render-pic.d.ts +27 -0
  36. package/dist/pic/render-pic.d.ts.map +1 -0
  37. package/dist/pic/render-pic.js +43 -0
  38. package/dist/pic/render-pic.js.map +1 -0
  39. package/dist/pic/render-result.d.ts +8 -0
  40. package/dist/pic/render-result.d.ts.map +1 -0
  41. package/dist/pic/render-result.js +3 -0
  42. package/dist/pic/render-result.js.map +1 -0
  43. package/dist/pic/screen-buffer.d.ts +7 -0
  44. package/dist/pic/screen-buffer.d.ts.map +1 -0
  45. package/dist/pic/screen-buffer.js +70 -0
  46. package/dist/pic/screen-buffer.js.map +1 -0
  47. package/dist/pic/tools/circles.d.ts +3 -0
  48. package/dist/pic/tools/circles.d.ts.map +1 -0
  49. package/dist/pic/tools/circles.js +87 -0
  50. package/dist/pic/tools/circles.js.map +1 -0
  51. package/dist/pic/tools/create-blitter.d.ts +5 -0
  52. package/dist/pic/tools/create-blitter.d.ts.map +1 -0
  53. package/dist/pic/tools/create-blitter.js +22 -0
  54. package/dist/pic/tools/create-blitter.js.map +1 -0
  55. package/dist/pic/tools/create-brush.d.ts +4 -0
  56. package/dist/pic/tools/create-brush.d.ts.map +1 -0
  57. package/dist/pic/tools/create-brush.js +37 -0
  58. package/dist/pic/tools/create-brush.js.map +1 -0
  59. package/dist/pic/tools/create-flood-fill.d.ts +4 -0
  60. package/dist/pic/tools/create-flood-fill.d.ts.map +1 -0
  61. package/dist/pic/tools/create-flood-fill.js +63 -0
  62. package/dist/pic/tools/create-flood-fill.js.map +1 -0
  63. package/dist/pic/tools/create-line.d.ts +3 -0
  64. package/dist/pic/tools/create-line.d.ts.map +1 -0
  65. package/dist/pic/tools/create-line.js +46 -0
  66. package/dist/pic/tools/create-line.js.map +1 -0
  67. package/dist/pic/tools/create-marker.d.ts +3 -0
  68. package/dist/pic/tools/create-marker.d.ts.map +1 -0
  69. package/dist/pic/tools/create-marker.js +11 -0
  70. package/dist/pic/tools/create-marker.js.map +1 -0
  71. package/dist/pic/tools/index.d.ts +6 -0
  72. package/dist/pic/tools/index.d.ts.map +1 -0
  73. package/dist/pic/tools/index.js +14 -0
  74. package/dist/pic/tools/index.js.map +1 -0
  75. package/dist/pic/tools/noise.d.ts +3 -0
  76. package/dist/pic/tools/noise.d.ts.map +1 -0
  77. package/dist/pic/tools/noise.js +24 -0
  78. package/dist/pic/tools/noise.js.map +1 -0
  79. package/dist/pic/tools/screen.d.ts +16 -0
  80. package/dist/pic/tools/screen.d.ts.map +1 -0
  81. package/dist/pic/tools/screen.js +3 -0
  82. package/dist/pic/tools/screen.js.map +1 -0
  83. package/dist/utils/exhaustive.d.ts +2 -0
  84. package/dist/utils/exhaustive.d.ts.map +1 -0
  85. package/dist/utils/exhaustive.js +7 -0
  86. package/dist/utils/exhaustive.js.map +1 -0
  87. package/package.json +32 -0
package/LICENSE.txt ADDED
@@ -0,0 +1,10 @@
1
+ Copyright (c) 2024, J. Holmes
2
+
3
+ Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted,
4
+ provided that the above copyright notice and this permission notice appear in all copies.
5
+
6
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
7
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
8
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
9
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
10
+ THIS SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,17 @@
1
+ # @4bitlabs/sci0 [![License][license]][npm] [![NPM Version][version]][npm] [![NPM Downloads][dl]][npm]
2
+
3
+ [npm]: https://www.npmjs.com/package/@4bitlabs/sci0-filters
4
+ [version]: https://img.shields.io/npm/v/%404bitlabs%2Fsci0-filters
5
+ [license]: https://img.shields.io/npm/l/%404bitlabs%2Fsci0-filters
6
+ [dl]: https://img.shields.io/npm/dy/%404bitlabs%2Fsci0-filters
7
+
8
+ Image processing filters and rendering functions for [Sierra On-line's][sierra] [<abbr title="Sierra Creative Interpreter">SCI</abbr>-engine][sci0] graphical assets.
9
+
10
+ [sierra]: https://en.wikipedia.org/wiki/Sierra_Entertainment
11
+ [sci0]: http://sciwiki.sierrahelp.com/index.php/Sierra_Creative_Interpreter
12
+
13
+ ## Documentation
14
+
15
+ Full documentation for the library can be found [here][docs].
16
+
17
+ [docs]: https://32bitkid.github.io/sci.js/modules/_4bitlabs_sci0_filters.html
@@ -0,0 +1,4 @@
1
+ import type { Loop } from '@4bitlabs/sci0';
2
+ import type { PixelFilter } from '@4bitlabs/image';
3
+ export declare const loopPaddingFilter: (loop: Loop) => PixelFilter;
4
+ //# sourceMappingURL=loop-padding-filter.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loopPaddingFilter = void 0;
4
+ const image_1 = require("@4bitlabs/image");
5
+ 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
+ };
31
+ };
32
+ exports.loopPaddingFilter = loopPaddingFilter;
33
+ //# sourceMappingURL=loop-padding-filter.js.map
@@ -0,0 +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"}
@@ -0,0 +1,9 @@
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;
7
+ }
8
+ export declare const menuTextFilter: (ox: number, oy: number, options: MenuTextFilterOptions) => PixelFilter;
9
+ //# sourceMappingURL=menu-text-filter.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.menuTextFilter = void 0;
4
+ const image_1 = require("@4bitlabs/image");
5
+ 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
+ };
36
+ };
37
+ exports.menuTextFilter = menuTextFilter;
38
+ //# sourceMappingURL=menu-text-filter.js.map
@@ -0,0 +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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/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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,YAAY,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,YAAY,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,YAAY,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,12 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qEAAkE;AAAzD,wHAAA,iBAAiB,OAAA;AAE1B,+DAA4D;AAAnD,kHAAA,cAAc,OAAA;AAIvB,+CAA6C;AAApC,uGAAA,SAAS,OAAA;AAClB,mDAAiD;AAAxC,2GAAA,WAAW,OAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const DEFAULT_PALETTE: readonly [0, 17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 136, 136, 1, 2, 3, 4, 5, 6, 136, 136, 249, 250, 251, 252, 253, 254, 255, 8, 145, 42, 59, 76, 93, 110, 136];
2
+ //# sourceMappingURL=default-palette.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-palette.d.ts","sourceRoot":"","sources":["../../src/pic/default-palette.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,eAAe,0LAKlB,CAAC"}
@@ -0,0 +1,11 @@
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,
10
+ ];
11
+ //# sourceMappingURL=default-palette.js.map
@@ -0,0 +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"}
@@ -0,0 +1,3 @@
1
+ export type PaletteSet = [Uint8Array, Uint8Array, Uint8Array, Uint8Array];
2
+ export declare const defaultPalettes: () => PaletteSet;
3
+ //# sourceMappingURL=default-palettes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-palettes.d.ts","sourceRoot":"","sources":["../../src/pic/default-palettes.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,UAAU,GAAG,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;AAE1E,eAAO,MAAM,eAAe,QAAO,UAKlC,CAAC"}
@@ -0,0 +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");
5
+ 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),
10
+ ];
11
+ exports.defaultPalettes = defaultPalettes;
12
+ //# sourceMappingURL=default-palettes.js.map
@@ -0,0 +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"}
@@ -0,0 +1,28 @@
1
+ import type { DrawCommand, Pic } from '@4bitlabs/sci0';
2
+ import { RenderPicOptions } from './render-pic-options';
3
+ import { RenderResult } from './render-result';
4
+ /**
5
+ * Generate a {@link Pic} iterator that will emit after processing each {@link DrawCommand} is processed.
6
+ *
7
+ * @param pic Picture data.
8
+ * @param options
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import { parsePic } from '@4bitlabs/sci0';
13
+ * import { generatePic } from '@4bitlabs/sci0-renderer';
14
+ * import { CGA } from '@4bitlabs/color/dithers';
15
+ * import { createDitherFilter, renderPixelData } from '@4bitlabs/image';
16
+ *
17
+ * const classicPipeline = { render: createDitherFilter(CGA) };
18
+ *
19
+ * const picData = parsePic(data, { defer: true });
20
+ * for (const [idx, cmd, layers] of generatePic(visible) {
21
+ * const { visible } = layers;
22
+ * const image = renderPixelData(visible, classicPipeline);
23
+ * saveImage(`frame${idx}.png`, image);
24
+ * }
25
+ * ```
26
+ */
27
+ export declare function generatePic(pic: Pic, options?: RenderPicOptions): Generator<[idx: number, command: DrawCommand, layers: RenderResult]>;
28
+ //# sourceMappingURL=generate-pic.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,43 @@
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
+ */
30
+ 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
+ }
42
+ }
43
+ //# sourceMappingURL=generate-pic.js.map
@@ -0,0 +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"}
@@ -0,0 +1,4 @@
1
+ import type { DrawCommand } from '@4bitlabs/sci0';
2
+ import type { Screen } from './tools/screen';
3
+ export declare function picStep(cmd: DrawCommand, { fill, line, brush, blit }: Screen, palettes: [Uint8Array, Uint8Array, Uint8Array, Uint8Array]): void;
4
+ //# sourceMappingURL=pic-step.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pic-step.d.ts","sourceRoot":"","sources":["../../src/pic/pic-step.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAG7C,wBAAgB,OAAO,CACrB,GAAG,EAAE,WAAW,EAChB,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,MAAM,EACnC,QAAQ,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,GACzD,IAAI,CA+CN"}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.picStep = picStep;
4
+ const exhaustive_1 = require("../utils/exhaustive");
5
+ 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
+ }
45
+ }
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AAC,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"}
@@ -0,0 +1,17 @@
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;
16
+ }
17
+ //# sourceMappingURL=render-pic-options.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=render-pic-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-pic-options.js","sourceRoot":"","sources":["../../src/pic/render-pic-options.ts"],"names":[],"mappings":""}
@@ -0,0 +1,27 @@
1
+ import type { Pic } from '@4bitlabs/sci0';
2
+ import { RenderResult } from './render-result';
3
+ import { RenderPicOptions } from './render-pic-options';
4
+ /**
5
+ * Render a {@link Pic} resource into its composite layers.
6
+ *
7
+ * @param pic The picture data to render.
8
+ * @param options
9
+ *
10
+ * @see {@link RenderResult}
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * import { parsePic } from '@4bitlabs/sci0';
15
+ * import { renderPic } from '@4bitlabs/sci0-renderer';
16
+ * import { CGA } from '@4bitlabs/color/dithers';
17
+ * import { createDitherFilter, renderPixelData } from '@4bitlabs/image';
18
+ *
19
+ * const picData = parsePic(data);
20
+ * const { visible, priority, control } = renderPic(picData);
21
+ * const image = renderPixelData(visible, {
22
+ * render: createDitherFilter(CGA),
23
+ * });
24
+ * ```
25
+ */
26
+ export declare const renderPic: (pic: Pic, options?: RenderPicOptions) => RenderResult;
27
+ //# sourceMappingURL=render-pic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-pic.d.ts","sourceRoot":"","sources":["../../src/pic/render-pic.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAIxD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,SAAS,QACf,GAAG,YACC,gBAAgB,KACxB,YAeF,CAAC"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.renderPic = void 0;
4
+ const screen_buffer_1 = require("./screen-buffer");
5
+ const pic_step_1 = require("./pic-step");
6
+ const default_palettes_1 = require("./default-palettes");
7
+ /**
8
+ * Render a {@link Pic} resource into its composite layers.
9
+ *
10
+ * @param pic The picture data to render.
11
+ * @param options
12
+ *
13
+ * @see {@link RenderResult}
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * import { parsePic } from '@4bitlabs/sci0';
18
+ * import { renderPic } from '@4bitlabs/sci0-renderer';
19
+ * import { CGA } from '@4bitlabs/color/dithers';
20
+ * import { createDitherFilter, renderPixelData } from '@4bitlabs/image';
21
+ *
22
+ * const picData = parsePic(data);
23
+ * const { visible, priority, control } = renderPic(picData);
24
+ * const image = renderPixelData(visible, {
25
+ * render: createDitherFilter(CGA),
26
+ * });
27
+ * ```
28
+ */
29
+ const renderPic = (pic, options = {}) => {
30
+ const { forcePal, width = 320, height = 190 } = options;
31
+ const size = [width, height];
32
+ const palettes = (0, default_palettes_1.defaultPalettes)();
33
+ const [result, screen, tick] = (0, screen_buffer_1.createScreenBuffer)(forcePal, palettes, size);
34
+ let step = 0;
35
+ for (const cmd of pic) {
36
+ tick(step);
37
+ (0, pic_step_1.picStep)(cmd, screen, palettes);
38
+ step += 1;
39
+ }
40
+ return result;
41
+ };
42
+ exports.renderPic = renderPic;
43
+ //# sourceMappingURL=render-pic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-pic.js","sourceRoot":"","sources":["../../src/pic/render-pic.ts"],"names":[],"mappings":";;;AAEA,mDAAqD;AAGrD,yCAAqC;AACrC,yDAAqD;AAErD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACI,MAAM,SAAS,GAAG,CACvB,GAAQ,EACR,UAA4B,EAAE,EAChB,EAAE;IAChB,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,IAAI,IAAI,CAAC,CAAC;IACZ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAlBW,QAAA,SAAS,aAkBpB"}
@@ -0,0 +1,8 @@
1
+ import type { IndexedPixelData } from '@4bitlabs/image';
2
+ export interface RenderResult {
3
+ visible: IndexedPixelData;
4
+ priority: IndexedPixelData;
5
+ control: IndexedPixelData;
6
+ tBuffer: Uint32Array;
7
+ }
8
+ //# sourceMappingURL=render-result.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-result.d.ts","sourceRoot":"","sources":["../../src/pic/render-result.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,gBAAgB,CAAC;IAC1B,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,OAAO,EAAE,gBAAgB,CAAC;IAC1B,OAAO,EAAE,WAAW,CAAC;CACtB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=render-result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-result.js","sourceRoot":"","sources":["../../src/pic/render-result.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ import type { Vec2 } from '@4bitlabs/vec2';
2
+ import { type Screen } from './tools/screen';
3
+ import { type RenderResult } from './render-result';
4
+ type SetTValueFn = (n: number) => void;
5
+ export declare const createScreenBuffer: (forcePal: 0 | 1 | 2 | 3 | undefined, palettes: [Uint8Array, Uint8Array, Uint8Array, Uint8Array], [width, height]: Vec2) => [RenderResult, Screen, SetTValueFn];
6
+ export {};
7
+ //# sourceMappingURL=screen-buffer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"screen-buffer.d.ts","sourceRoot":"","sources":["../../src/pic/screen-buffer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAG3C,OAAO,EAIL,KAAK,MAAM,EACZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAQpD,KAAK,WAAW,GAAG,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;AAEvC,eAAO,MAAM,kBAAkB,aACnB,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,SAAS,YACzB,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,mBACzC,IAAI,KACpB,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,CA0EpC,CAAC"}
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createScreenBuffer = void 0;
4
+ const image_1 = require("@4bitlabs/image");
5
+ const sci0_1 = require("@4bitlabs/sci0");
6
+ const tools_1 = require("./tools");
7
+ const createScreenBuffer = (forcePal, palettes, [width, height]) => {
8
+ const visible = (0, image_1.createIndexedPixelData)(width, height);
9
+ const priority = (0, image_1.createIndexedPixelData)(width, height);
10
+ const control = (0, image_1.createIndexedPixelData)(width, height);
11
+ const tBuffer = new Uint32Array(width * height).fill(-1);
12
+ let t = 0;
13
+ const setTValue = (next) => {
14
+ t = next;
15
+ };
16
+ visible.pixels.fill(0xff);
17
+ priority.pixels.fill(0x00);
18
+ control.pixels.fill(0x00);
19
+ const setPixel = (x, y, color) => {
20
+ const idx = width * y + x;
21
+ visible.pixels[idx] = (color & 0b1111) | (color << 4);
22
+ };
23
+ const plot = (x, y, drawMode, drawCodes) => {
24
+ if (x < 0 || x >= width || y < 0 || y >= height)
25
+ return;
26
+ const idx = width * y + x;
27
+ if (sci0_1.DrawMode.isVisualMode(drawMode)) {
28
+ const pal = forcePal !== null && forcePal !== void 0 ? forcePal : (drawCodes[0] / 40) >>> 0;
29
+ const palette = palettes[pal];
30
+ const palIndex = drawCodes[0] % 40 >>> 0;
31
+ visible.pixels[idx] = palette[palIndex];
32
+ tBuffer[idx] = t;
33
+ }
34
+ if (sci0_1.DrawMode.isPriorityMode(drawMode)) {
35
+ priority.pixels[idx] = drawCodes[1];
36
+ }
37
+ if (sci0_1.DrawMode.isControlMode(drawMode)) {
38
+ control.pixels[idx] = drawCodes[2];
39
+ }
40
+ };
41
+ const isFillable = (x, y, drawMode) => {
42
+ const idx = x + y * width;
43
+ if (sci0_1.DrawMode.isVisualMode(drawMode)) {
44
+ const dither = (x & 1) ^ (y & 1);
45
+ const val = visible.pixels[idx];
46
+ const [high, low] = [val >>> 4, val & 0b1111];
47
+ return 0xf === (dither ? high : low);
48
+ }
49
+ /* TODO not sure if this is correct… but it looks *okay*-ish.
50
+ * SCI Companion seems to be able to recognize the difference between "never-touched" pixels and
51
+ * replaced 0x00 pixels in control and priority layers. Not sure if its intentional or not. But
52
+ * may require a different way of modeling indexed "alpha" channel.
53
+ */
54
+ return ((sci0_1.DrawMode.isPriorityMode(drawMode) && priority.pixels[idx] === 0x00) ||
55
+ (sci0_1.DrawMode.isControlMode(drawMode) && control.pixels[idx] === 0x00));
56
+ };
57
+ return [
58
+ { visible, priority, control, tBuffer },
59
+ {
60
+ setPixel,
61
+ brush: (0, tools_1.createBrush)(plot, [width, height]),
62
+ fill: (0, tools_1.createFloodFill)(plot, isFillable, [width, height]),
63
+ line: (0, tools_1.createLine)(plot),
64
+ blit: (0, tools_1.createBlitter)(setPixel, [width, height]),
65
+ },
66
+ setTValue,
67
+ ];
68
+ };
69
+ exports.createScreenBuffer = createScreenBuffer;
70
+ //# sourceMappingURL=screen-buffer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"screen-buffer.js","sourceRoot":"","sources":["../../src/pic/screen-buffer.ts"],"names":[],"mappings":";;;AACA,2CAAyD;AACzD,yCAA0C;AAQ1C,mCAKiB;AAIV,MAAM,kBAAkB,GAAG,CAChC,QAAmC,EACnC,QAA0D,EAC1D,CAAC,KAAK,EAAE,MAAM,CAAO,EACgB,EAAE;IACvC,MAAM,OAAO,GAAG,IAAA,8BAAsB,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACtD,MAAM,QAAQ,GAAG,IAAA,8BAAsB,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACvD,MAAM,OAAO,GAAG,IAAA,8BAAsB,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACtD,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAEzD,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,MAAM,SAAS,GAAG,CAAC,IAAY,EAAE,EAAE;QACjC,CAAC,GAAG,IAAI,CAAC;IACX,CAAC,CAAC;IAEF,OAAO,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mBAAW,EAAC,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;YACzC,IAAI,EAAE,IAAA,uBAAe,EAAC,IAAI,EAAE,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;YACxD,IAAI,EAAE,IAAA,kBAAU,EAAC,IAAI,CAAC;YACtB,IAAI,EAAE,IAAA,qBAAa,EAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;SAC/C;QACD,SAAS;KACV,CAAC;AACJ,CAAC,CAAC;AA9EW,QAAA,kBAAkB,sBA8E7B"}
@@ -0,0 +1,3 @@
1
+ declare const circleBitmaps: number[][];
2
+ export default circleBitmaps;
3
+ //# sourceMappingURL=circles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"circles.d.ts","sourceRoot":"","sources":["../../../src/pic/tools/circles.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,aAAa,EAAE,MAAM,EAAE,EAoF5B,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // prettier-ignore
4
+ const circleBitmaps = [
5
+ [
6
+ 0b1
7
+ ],
8
+ [
9
+ 0b010,
10
+ 0b111,
11
+ 0b010,
12
+ ],
13
+ [
14
+ 0b01110,
15
+ 0b11111,
16
+ 0b11111,
17
+ 0b11111,
18
+ 0b01110,
19
+ ],
20
+ [
21
+ 0b0011100,
22
+ 0b0111110,
23
+ 0b1111111,
24
+ 0b1111111,
25
+ 0b1111111,
26
+ 0b0111110,
27
+ 0b0011100,
28
+ ],
29
+ [
30
+ 0b000111000,
31
+ 0b011111110,
32
+ 0b111111111,
33
+ 0b111111111,
34
+ 0b111111111,
35
+ 0b111111111,
36
+ 0b111111111,
37
+ 0b011111110,
38
+ 0b000111000,
39
+ ],
40
+ [
41
+ 0b00001110000,
42
+ 0b00111111100,
43
+ 0b01111111110,
44
+ 0b01111111110,
45
+ 0b11111111111,
46
+ 0b11111111111,
47
+ 0b11111111111,
48
+ 0b01111111110,
49
+ 0b01111111110,
50
+ 0b00111111100,
51
+ 0b00011111000,
52
+ ],
53
+ [
54
+ 0b0000111110000,
55
+ 0b0011111111100,
56
+ 0b0111111111110,
57
+ 0b0111111111110,
58
+ 0b1111111111111,
59
+ 0b1111111111111,
60
+ 0b1111111111111,
61
+ 0b1111111111111,
62
+ 0b1111111111111,
63
+ 0b0111111111110,
64
+ 0b0111111111110,
65
+ 0b0011111111100,
66
+ 0b0000111110000,
67
+ ],
68
+ [
69
+ 0b000001111100000,
70
+ 0b000111111111000,
71
+ 0b001111111111100,
72
+ 0b011111111111110,
73
+ 0b011111111111110,
74
+ 0b111111111111111,
75
+ 0b111111111111111,
76
+ 0b111111111111111,
77
+ 0b111111111111111,
78
+ 0b111111111111111,
79
+ 0b011111111111110,
80
+ 0b011111111111110,
81
+ 0b001111111111100,
82
+ 0b000111111111000,
83
+ 0b000001111100000,
84
+ ],
85
+ ];
86
+ exports.default = circleBitmaps;
87
+ //# sourceMappingURL=circles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"circles.js","sourceRoot":"","sources":["../../../src/pic/tools/circles.ts"],"names":[],"mappings":";;AAAA,kBAAkB;AAClB,MAAM,aAAa,GAAe;IAChC;QACE,GAAG;KACJ;IACD;QACE,KAAK;QACL,KAAK;QACL,KAAK;KACN;IAED;QACE,OAAO;QACP,OAAO;QACP,OAAO;QACP,OAAO;QACP,OAAO;KACR;IAED;QACE,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;KACV;IAED;QACE,WAAW;QACX,WAAW;QACX,WAAW;QACX,WAAW;QACX,WAAW;QACX,WAAW;QACX,WAAW;QACX,WAAW;QACX,WAAW;KACZ;IACD;QACE,aAAa;QACb,aAAa;QACb,aAAa;QACb,aAAa;QACb,aAAa;QACb,aAAa;QACb,aAAa;QACb,aAAa;QACb,aAAa;QACb,aAAa;QACb,aAAa;KACd;IACD;QACE,eAAe;QACf,eAAe;QACf,eAAe;QACf,eAAe;QACf,eAAe;QACf,eAAe;QACf,eAAe;QACf,eAAe;QACf,eAAe;QACf,eAAe;QACf,eAAe;QACf,eAAe;QACf,eAAe;KAChB;IACD;QACE,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;KAClB;CACF,CAAC;AAEF,kBAAe,aAAa,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { type Vec2 } from '@4bitlabs/vec2';
2
+ import { DrawMode, Cel } from '@4bitlabs/sci0';
3
+ import { RawPlotter } from './screen';
4
+ export declare const createBlitter: (plot: RawPlotter, [stageWidth, stageHeight]: Readonly<Vec2>) => (x0: number, y0: number, drawMode: DrawMode, cel: Cel) => void;
5
+ //# sourceMappingURL=create-blitter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-blitter.d.ts","sourceRoot":"","sources":["../../../src/pic/tools/create-blitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,eAAO,MAAM,aAAa,SACjB,UAAU,6BAA6B,QAAQ,CAAC,IAAI,CAAC,UACvD,MAAM,MAAM,MAAM,YAAY,QAAQ,OAAO,GAAG,KAAG,IAevD,CAAC"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createBlitter = void 0;
4
+ const sci0_1 = require("@4bitlabs/sci0");
5
+ const createBlitter = (plot, [stageWidth, stageHeight]) => (x0, y0, drawMode, cel) => {
6
+ if (sci0_1.DrawMode.isControlMode(drawMode) || sci0_1.DrawMode.isPriorityMode(drawMode))
7
+ console.warn('unhandled CEL command on Control/Priority layer');
8
+ if (!sci0_1.DrawMode.isVisualMode(drawMode))
9
+ return;
10
+ const data = cel.pixels;
11
+ for (let y = y0; y < y0 + cel.height; y++)
12
+ for (let x = x0; x < x0 + cel.width; x++) {
13
+ if (x >= stageWidth || y >= stageHeight)
14
+ continue;
15
+ const color = data[x + y * cel.width];
16
+ if (color === cel.keyColor)
17
+ continue;
18
+ plot(x, y, color);
19
+ }
20
+ };
21
+ exports.createBlitter = createBlitter;
22
+ //# sourceMappingURL=create-blitter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-blitter.js","sourceRoot":"","sources":["../../../src/pic/tools/create-blitter.ts"],"names":[],"mappings":";;;AACA,yCAA+C;AAGxC,MAAM,aAAa,GACxB,CAAC,IAAgB,EAAE,CAAC,UAAU,EAAE,WAAW,CAAiB,EAAE,EAAE,CAChE,CAAC,EAAU,EAAE,EAAU,EAAE,QAAkB,EAAE,GAAQ,EAAQ,EAAE;IAC7D,IAAI,eAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,eAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC;QACvE,OAAO,CAAC,IAAI,CAAC,iDAAiD,CAAC,CAAC;IAElE,IAAI,CAAC,eAAQ,CAAC,YAAY,CAAC,QAAQ,CAAC;QAAE,OAAO;IAE7C,MAAM,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC;IACxB,KAAK,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE;QACvC,KAAK,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;YACzC,IAAI,CAAC,IAAI,UAAU,IAAI,CAAC,IAAI,WAAW;gBAAE,SAAS;YAElD,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC;YACtC,IAAI,KAAK,KAAK,GAAG,CAAC,QAAQ;gBAAE,SAAS;YACrC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;QACpB,CAAC;AACL,CAAC,CAAC;AAjBS,QAAA,aAAa,iBAiBtB"}
@@ -0,0 +1,4 @@
1
+ import { type Vec2 } from '@4bitlabs/vec2';
2
+ import { Brusher, Plotter } from './screen';
3
+ export declare const createBrush: (plot: Plotter, [stageWidth, stageHeight]: Readonly<Vec2>) => Brusher;
4
+ //# sourceMappingURL=create-brush.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-brush.d.ts","sourceRoot":"","sources":["../../../src/pic/tools/create-brush.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAI5C,eAAO,MAAM,WAAW,SAChB,OAAO,6BACc,QAAQ,CAAC,IAAI,CAAC,KACxC,OAmCA,CAAC"}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createBrush = void 0;
7
+ const noise_1 = require("./noise");
8
+ const circles_1 = __importDefault(require("./circles"));
9
+ const createBrush = (plot, [stageWidth, stageHeight]) => function brush(cx, cy, drawMode, drawCodes, size, isRect, isSpray, textureCode) {
10
+ const baseWidth = isRect ? 2 : 1;
11
+ const width = baseWidth + size * 2;
12
+ const height = 1 + size * 2;
13
+ let top = Math.max(0, cy - size);
14
+ let left = Math.max(0, cx - size);
15
+ const bottom = top + height;
16
+ const right = left + width;
17
+ if (right >= stageWidth)
18
+ left = stageWidth - width;
19
+ if (bottom >= stageHeight)
20
+ top = stageHeight - height;
21
+ let noiseIdx = noise_1.NOISE_OFFSETS[textureCode];
22
+ for (let py = top; py < bottom; py += 1)
23
+ for (let px = left; px < right; px += 1) {
24
+ if (!isRect) {
25
+ const sprite = circles_1.default[size];
26
+ const row = sprite[py - top];
27
+ const shift = width - (px - left) - 1;
28
+ if (((row >>> shift) & 0b1) === 0)
29
+ continue;
30
+ }
31
+ if (isSpray && !noise_1.NOISE[noiseIdx++ & 0xff])
32
+ continue;
33
+ plot(px, py, drawMode, drawCodes);
34
+ }
35
+ };
36
+ exports.createBrush = createBrush;
37
+ //# sourceMappingURL=create-brush.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-brush.js","sourceRoot":"","sources":["../../../src/pic/tools/create-brush.ts"],"names":[],"mappings":";;;;;;AAGA,mCAA+C;AAC/C,wDAAgC;AAEzB,MAAM,WAAW,GAAG,CACzB,IAAa,EACb,CAAC,UAAU,EAAE,WAAW,CAAiB,EAChC,EAAE,CACX,SAAS,KAAK,CACZ,EAAE,EACF,EAAE,EACF,QAAkB,EAClB,SAAoB,EACpB,IAAI,EACJ,MAAM,EACN,OAAO,EACP,WAAW;IAEX,MAAM,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACjC,MAAM,KAAK,GAAG,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC;IACnC,MAAM,MAAM,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC;IAE5B,IAAI,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IACjC,IAAI,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IAClC,MAAM,MAAM,GAAG,GAAG,GAAG,MAAM,CAAC;IAC5B,MAAM,KAAK,GAAG,IAAI,GAAG,KAAK,CAAC;IAC3B,IAAI,KAAK,IAAI,UAAU;QAAE,IAAI,GAAG,UAAU,GAAG,KAAK,CAAC;IACnD,IAAI,MAAM,IAAI,WAAW;QAAE,GAAG,GAAG,WAAW,GAAG,MAAM,CAAC;IAEtD,IAAI,QAAQ,GAAG,qBAAa,CAAC,WAAW,CAAC,CAAC;IAE1C,KAAK,IAAI,EAAE,GAAG,GAAG,EAAE,EAAE,GAAG,MAAM,EAAE,EAAE,IAAI,CAAC;QACrC,KAAK,IAAI,EAAE,GAAG,IAAI,EAAE,EAAE,GAAG,KAAK,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC;YACxC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,MAAM,MAAM,GAAG,iBAAO,CAAC,IAAI,CAAC,CAAC;gBAC7B,MAAM,GAAG,GAAG,MAAM,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC;gBAC7B,MAAM,KAAK,GAAG,KAAK,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;gBACtC,IAAI,CAAC,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC;oBAAE,SAAS;YAC9C,CAAC;YACD,IAAI,OAAO,IAAI,CAAC,aAAK,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC;gBAAE,SAAS;YACnD,IAAI,CAAC,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;QACpC,CAAC;AACL,CAAC,CAAC;AAtCS,QAAA,WAAW,eAsCpB"}
@@ -0,0 +1,4 @@
1
+ import { type Vec2 } from '@4bitlabs/vec2';
2
+ import { Filler, IsFillable, Plotter } from './screen';
3
+ export declare const createFloodFill: (plot: Plotter, isLegal: IsFillable, [width, height]: Readonly<Vec2>) => Filler;
4
+ //# sourceMappingURL=create-flood-fill.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-flood-fill.d.ts","sourceRoot":"","sources":["../../../src/pic/tools/create-flood-fill.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEvD,eAAO,MAAM,eAAe,SACpB,OAAO,WACJ,UAAU,mBACF,QAAQ,CAAC,IAAI,CAAC,KAC9B,MAuEF,CAAC"}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createFloodFill = void 0;
4
+ const numeric_deque_1 = require("@4bitlabs/numeric-deque");
5
+ const createFloodFill = (plot, isLegal, [width, height]) => {
6
+ const visited = new Uint8ClampedArray(width * height);
7
+ const stack = new numeric_deque_1.NumericDeque(width * height, Uint32Array);
8
+ return function floodFill(ix, iy, drawMode, drawCodes) {
9
+ visited.fill(0);
10
+ stack.clear();
11
+ const start = iy * width + ix;
12
+ stack.push(start);
13
+ do {
14
+ const i = stack.shift();
15
+ if (visited[i])
16
+ continue;
17
+ visited[i] = 0xff;
18
+ const x = i % width;
19
+ const y = (i / width) >>> 0;
20
+ if (!isLegal(x, y, drawMode))
21
+ continue;
22
+ plot(x, y, drawMode, drawCodes);
23
+ const initialAbove = y - 1 >= 0 && !visited[i - width] && isLegal(x, y - 1, drawMode);
24
+ const initialBelow = y + 1 < height && !visited[i + width] && isLegal(x, y + 1, drawMode);
25
+ if (initialAbove)
26
+ stack.push(i - width);
27
+ if (initialBelow)
28
+ stack.push(i + width);
29
+ // scan right and left
30
+ for (let dir = 1; dir >= -1; dir -= 2) {
31
+ let visitedAbove = initialAbove;
32
+ let visitedBelow = initialBelow;
33
+ for (let sx = x + dir; (dir > 0 ? sx < width : sx >= 0) && isLegal(sx, y, drawMode); sx += dir) {
34
+ const idx = i + (sx - x);
35
+ visited[idx] = 0xff;
36
+ plot(sx, y, drawMode, drawCodes);
37
+ if (y - 1 >= 0 && !visited[idx - width]) {
38
+ if (isLegal(sx, y - 1, drawMode)) {
39
+ if (!visitedAbove)
40
+ stack.push(idx - width);
41
+ visitedAbove = true;
42
+ }
43
+ else {
44
+ visitedAbove = false;
45
+ }
46
+ }
47
+ if (y + 1 < height && !visited[idx + width]) {
48
+ if (isLegal(sx, y + 1, drawMode)) {
49
+ if (!visitedBelow)
50
+ stack.push(idx + width);
51
+ visitedBelow = true;
52
+ }
53
+ else {
54
+ visitedBelow = false;
55
+ }
56
+ }
57
+ }
58
+ }
59
+ } while (!stack.isEmpty());
60
+ };
61
+ };
62
+ exports.createFloodFill = createFloodFill;
63
+ //# sourceMappingURL=create-flood-fill.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-flood-fill.js","sourceRoot":"","sources":["../../../src/pic/tools/create-flood-fill.ts"],"names":[],"mappings":";;;AAAA,2DAAuD;AAKhD,MAAM,eAAe,GAAG,CAC7B,IAAa,EACb,OAAmB,EACnB,CAAC,KAAK,EAAE,MAAM,CAAiB,EACvB,EAAE;IACV,MAAM,OAAO,GAAG,IAAI,iBAAiB,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC;IACtD,MAAM,KAAK,GAAG,IAAI,4BAAY,CAAC,KAAK,GAAG,MAAM,EAAE,WAAW,CAAC,CAAC;IAE5D,OAAO,SAAS,SAAS,CACvB,EAAU,EACV,EAAU,EACV,QAAkB,EAClB,SAAoB;QAEpB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAChB,KAAK,CAAC,KAAK,EAAE,CAAC;QAEd,MAAM,KAAK,GAAG,EAAE,GAAG,KAAK,GAAG,EAAE,CAAC;QAC9B,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAElB,GAAG,CAAC;YACF,MAAM,CAAC,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;YAExB,IAAI,OAAO,CAAC,CAAC,CAAC;gBAAE,SAAS;YACzB,OAAO,CAAC,CAAC,CAAC,GAAG,IA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.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-line.d.ts","sourceRoot":"","sources":["../../../src/pic/tools/create-line.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAE1C,eAAO,MAAM,UAAU,SAAU,OAAO,KAAG,KAoDxC,CAAC"}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createLine = void 0;
4
+ const createLine = (plot) => function line(x0, y0, x1, y1, drawMode, drawCodes) {
5
+ if (x0 === x1) {
6
+ for (let y = Math.min(y0, y1); y <= Math.max(y0, y1); y++)
7
+ plot(x0, y, drawMode, drawCodes);
8
+ return;
9
+ }
10
+ if (y0 === y1) {
11
+ for (let x = Math.min(x0, x1); x <= Math.max(x0, x1); x++)
12
+ plot(x, y0, drawMode, drawCodes);
13
+ return;
14
+ }
15
+ plot(x0, y0, drawMode, drawCodes);
16
+ plot(x1, y1, drawMode, drawCodes);
17
+ const dx = x1 - x0;
18
+ const dy = y1 - y0;
19
+ const adx = Math.abs(dx);
20
+ const ady = Math.abs(dy);
21
+ const sx = dx > 0 ? 1 : -1;
22
+ const sy = dy > 0 ? 1 : -1;
23
+ let eps = 0;
24
+ if (adx > ady) {
25
+ for (let x = x0, y = y0; sx < 0 ? x >= x1 : x <= x1; x += sx) {
26
+ plot(x, y, drawMode, drawCodes);
27
+ eps += ady;
28
+ if (eps << 1 >= adx) {
29
+ y += sy;
30
+ eps -= adx;
31
+ }
32
+ }
33
+ }
34
+ else {
35
+ for (let x = x0, y = y0; sy < 0 ? y >= y1 : y <= y1; y += sy) {
36
+ plot(x, y, drawMode, drawCodes);
37
+ eps += adx;
38
+ if (eps << 1 >= ady) {
39
+ x += sx;
40
+ eps -= ady;
41
+ }
42
+ }
43
+ }
44
+ };
45
+ exports.createLine = createLine;
46
+ //# sourceMappingURL=create-line.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":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: Plotter) => Filler;
3
+ //# sourceMappingURL=create-marker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-marker.d.ts","sourceRoot":"","sources":["../../../src/pic/tools/create-marker.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAE3C,eAAO,MAAM,YAAY,SAAU,OAAO,KAAG,MAW1C,CAAC"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createMarker = void 0;
4
+ const createMarker = (plot) => function marker(x, y, drawMode, drawCodes) {
5
+ plot(x - 1, y, drawMode, drawCodes);
6
+ plot(x, y - 1, drawMode, drawCodes);
7
+ plot(x + 1, y, drawMode, drawCodes);
8
+ plot(x, y + 1, drawMode, drawCodes);
9
+ };
10
+ exports.createMarker = createMarker;
11
+ //# sourceMappingURL=create-marker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-marker.js","sourceRoot":"","sources":["../../../src/pic/tools/create-marker.ts"],"names":[],"mappings":";;;AAGO,MAAM,YAAY,GAAG,CAAC,IAAa,EAAU,EAAE,CACpD,SAAS,MAAM,CACb,CAAS,EACT,CAAS,EACT,QAAkB,EAClB,SAAoB;IAEpB,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;IACpC,IAAI,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;IACpC,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;IACpC,IAAI,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AACtC,CAAC,CAAC;AAXS,QAAA,YAAY,gBAWrB"}
@@ -0,0 +1,6 @@
1
+ export { createBrush } from './create-brush';
2
+ export { createFloodFill } from './create-flood-fill';
3
+ export { createLine } from './create-line';
4
+ export { createMarker } from './create-marker';
5
+ export { createBlitter } from './create-blitter';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pic/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createBlitter = exports.createMarker = exports.createLine = exports.createFloodFill = exports.createBrush = void 0;
4
+ var create_brush_1 = require("./create-brush");
5
+ Object.defineProperty(exports, "createBrush", { enumerable: true, get: function () { return create_brush_1.createBrush; } });
6
+ var create_flood_fill_1 = require("./create-flood-fill");
7
+ Object.defineProperty(exports, "createFloodFill", { enumerable: true, get: function () { return create_flood_fill_1.createFloodFill; } });
8
+ var create_line_1 = require("./create-line");
9
+ Object.defineProperty(exports, "createLine", { enumerable: true, get: function () { return create_line_1.createLine; } });
10
+ var create_marker_1 = require("./create-marker");
11
+ Object.defineProperty(exports, "createMarker", { enumerable: true, get: function () { return create_marker_1.createMarker; } });
12
+ var create_blitter_1 = require("./create-blitter");
13
+ Object.defineProperty(exports, "createBlitter", { enumerable: true, get: function () { return create_blitter_1.createBlitter; } });
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/pic/tools/index.ts"],"names":[],"mappings":";;;AAAA,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AACpB,yDAAsD;AAA7C,oHAAA,eAAe,OAAA;AACxB,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AACnB,iDAA+C;AAAtC,6GAAA,YAAY,OAAA;AACrB,mDAAiD;AAAxC,+GAAA,aAAa,OAAA"}
@@ -0,0 +1,3 @@
1
+ export declare const NOISE: boolean[];
2
+ export declare const NOISE_OFFSETS: number[];
3
+ //# sourceMappingURL=noise.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"noise.d.ts","sourceRoot":"","sources":["../../../src/pic/tools/noise.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,KAAK,EAAE,OAAO,EAI6C,CAAC;AAEzE,eAAO,MAAM,aAAa,EAAE,MAAM,EAWjC,CAAC"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NOISE_OFFSETS = exports.NOISE = void 0;
4
+ const BYTE = Array(8)
5
+ .fill(0)
6
+ .map((_, i) => i);
7
+ exports.NOISE = [
8
+ 0x20, 0x94, 0x02, 0x24, 0x90, 0x82, 0xa4, 0xa2, 0x82, 0x09, 0x0a, 0x22, 0x12,
9
+ 0x10, 0x42, 0x14, 0x91, 0x4a, 0x91, 0x11, 0x08, 0x12, 0x25, 0x10, 0x22, 0xa8,
10
+ 0x14, 0x24, 0x00, 0x50, 0x24, 0x04,
11
+ ].flatMap((it) => BYTE.map((idx) => ((it >>> (7 - idx)) & 0b1) === 0b1));
12
+ exports.NOISE_OFFSETS = [
13
+ 0x00, 0x18, 0x30, 0xc4, 0xdc, 0x65, 0xeb, 0x48, 0x60, 0xbd, 0x89, 0x04, 0x0a,
14
+ 0xf4, 0x7d, 0x6d, 0x85, 0xb0, 0x8e, 0x95, 0x1f, 0x22, 0x0d, 0xdf, 0x2a, 0x78,
15
+ 0xd5, 0x73, 0x1c, 0xb4, 0x40, 0xa1, 0xb9, 0x3c, 0xca, 0x58, 0x92, 0x34, 0xcc,
16
+ 0xce, 0xd7, 0x42, 0x90, 0x0f, 0x8b, 0x7f, 0x32, 0xed, 0x5c, 0x9d, 0xc8, 0x99,
17
+ 0xad, 0x4e, 0x56, 0xa6, 0xf7, 0x68, 0xb7, 0x25, 0x82, 0x37, 0x3a, 0x51, 0x69,
18
+ 0x26, 0x38, 0x52, 0x9e, 0x9a, 0x4f, 0xa7, 0x43, 0x10, 0x80, 0xee, 0x3d, 0x59,
19
+ 0x35, 0xcf, 0x79, 0x74, 0xb5, 0xa2, 0xb1, 0x96, 0x23, 0xe0, 0xbe, 0x05, 0xf5,
20
+ 0x6e, 0x19, 0xc5, 0x66, 0x49, 0xf0, 0xd1, 0x54, 0xa9, 0x70, 0x4b, 0xa4, 0xe2,
21
+ 0xe6, 0xe5, 0xab, 0xe4, 0xd2, 0xaa, 0x4c, 0xe3, 0x06, 0x6f, 0xc6, 0x4a, 0x75,
22
+ 0xa3, 0x97, 0xe1,
23
+ ];
24
+ //# sourceMappingURL=noise.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"noise.js","sourceRoot":"","sources":["../../../src/pic/tools/noise.ts"],"names":[],"mappings":";;;AAAA,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC;KAClB,IAAI,CAAC,CAAC,CAAC;KACP,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;AAEP,QAAA,KAAK,GAAc;IAC9B,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IAC5E,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IAC5E,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;CACnC,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AE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IAC5E,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IAC5E,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IAC5E,IAAI,EAAE,IAAI,EAAE,IAAI;CACjB,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { DrawMode, DrawCodes, Cel } from '@4bitlabs/sci0';
2
+ export type RawPlotter = (x: number, y: number, color: number) => void;
3
+ export type Plotter = (x: number, y: number, drawMode: DrawMode, drawCodes: DrawCodes) => void;
4
+ export type IsFillable = (x: number, y: number, drawMode: DrawMode) => boolean;
5
+ export type Filler = (x: number, y: number, drawMode: DrawMode, drawCodes: DrawCodes) => void;
6
+ export type Liner = (x0: number, y0: number, x1: number, y1: number, drawMode: DrawMode, drawCodes: DrawCodes) => void;
7
+ export type Brusher = (cx: number, cy: number, drawMode: DrawMode, drawCodes: DrawCodes, size: number, isRect: boolean, isSpray: boolean, textureCode: number) => void;
8
+ export type Blitter = (x: number, y: number, drawMode: DrawMode, cel: Cel) => void;
9
+ export interface Screen {
10
+ brush: Brusher;
11
+ fill: Filler;
12
+ line: Liner;
13
+ setPixel: RawPlotter;
14
+ blit: Blitter;
15
+ }
16
+ //# sourceMappingURL=screen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"screen.d.ts","sourceRoot":"","sources":["../../../src/pic/tools/screen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE,MA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CAAC;IACZ,QAAQ,EAAE,UAAU,CAAC;IACrB,IAAI,EAAE,OAAO,CAAC;CACf"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=screen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"screen.js","sourceRoot":"","sources":["../../../src/pic/tools/screen.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export declare function exhaustive(msg: string, _: never): never;
2
+ //# sourceMappingURL=exhaustive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exhaustive.d.ts","sourceRoot":"","sources":["../../src/utils/exhaustive.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,GAAG,KAAK,CAEvD"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.exhaustive = exhaustive;
4
+ function exhaustive(msg, _) {
5
+ throw new Error(`${msg}: ${JSON.stringify(_)}`);
6
+ }
7
+ //# sourceMappingURL=exhaustive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exhaustive.js","sourceRoot":"","sources":["../../src/utils/exhaustive.ts"],"names":[],"mappings":";;AAAA,gCAEC;AAFD,SAAgB,UAAU,CAAC,GAAW,EAAE,CAAQ;IAC9C,MAAM,IAAI,KAAK,CAAC,GAAG,GAAG,KAAK,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAClD,CAAC"}
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@4bitlabs/sci0-renderer",
3
+ "version": "0.1.0",
4
+ "description": "Image processing filters and rendering functions for Sierra On-line SCI0 graphical assets.",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "homepage": "https://github.com/32bitkid/sci.js/tree/main/libs/sci0#readme",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/32bitkid/sci.js.git"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/32bitkid/sci.js/issues"
14
+ },
15
+ "files": [
16
+ "./dist/**/*"
17
+ ],
18
+ "scripts": {
19
+ "clean": "tsc --build --clean",
20
+ "clean:wipe": "rimraf ./dist",
21
+ "build": "tsc --build"
22
+ },
23
+ "author": "J. Holmes <j@holmes.codes>",
24
+ "license": "ISC",
25
+ "dependencies": {
26
+ "@4bitlabs/image": "^4.0.0",
27
+ "@4bitlabs/numeric-deque": "^1.1.6",
28
+ "@4bitlabs/sci0": "^5.0.0",
29
+ "@4bitlabs/vec2": "^2.0.0"
30
+ },
31
+ "gitHead": "bf751c6b4b90983544797fc6e5e0bc0330a10d87"
32
+ }