@4bitlabs/sci0-renderer 0.1.0 → 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.
- package/dist/filters/loop-padding-filter.d.ts +6 -3
- package/dist/filters/loop-padding-filter.d.ts.map +1 -1
- package/dist/filters/loop-padding-filter.js +25 -30
- package/dist/filters/loop-padding-filter.js.map +1 -1
- package/dist/filters/menu-text-filter.d.ts +10 -7
- package/dist/filters/menu-text-filter.d.ts.map +1 -1
- package/dist/filters/menu-text-filter.js +22 -35
- package/dist/filters/menu-text-filter.js.map +1 -1
- package/dist/index.d.ts +7 -8
- package/dist/index.js +5 -12
- package/dist/pic/default-palette.js +45 -9
- package/dist/pic/default-palette.js.map +1 -1
- package/dist/pic/default-palettes.js +9 -9
- package/dist/pic/default-palettes.js.map +1 -1
- package/dist/pic/generate-pic.d.ts +7 -4
- package/dist/pic/generate-pic.d.ts.map +1 -1
- package/dist/pic/generate-pic.js +22 -40
- package/dist/pic/generate-pic.js.map +1 -1
- package/dist/pic/pic-step.js +42 -43
- package/dist/pic/pic-step.js.map +1 -1
- package/dist/pic/render-pic-options.d.ts +18 -15
- package/dist/pic/render-pic-options.d.ts.map +1 -1
- package/dist/pic/render-pic.d.ts +7 -4
- package/dist/pic/render-pic.d.ts.map +1 -1
- package/dist/pic/render-pic.js +18 -40
- package/dist/pic/render-pic.js.map +1 -1
- package/dist/pic/render-result.d.ts +9 -6
- package/dist/pic/render-result.d.ts.map +1 -1
- package/dist/pic/screen-buffer.js +64 -67
- package/dist/pic/screen-buffer.js.map +1 -1
- package/dist/pic/tools/circles.js +82 -84
- package/dist/pic/tools/circles.js.map +1 -1
- package/dist/pic/tools/create-blitter.js +14 -19
- package/dist/pic/tools/create-blitter.js.map +1 -1
- package/dist/pic/tools/create-brush.js +22 -34
- package/dist/pic/tools/create-brush.js.map +1 -1
- package/dist/pic/tools/create-flood-fill.js +43 -60
- package/dist/pic/tools/create-flood-fill.js.map +1 -1
- package/dist/pic/tools/create-line.js +37 -43
- package/dist/pic/tools/create-line.js.map +1 -1
- package/dist/pic/tools/index.js +5 -14
- package/dist/pic/tools/noise.js +160 -22
- package/dist/pic/tools/noise.js.map +1 -1
- package/dist/utils/exhaustive.js +5 -4
- package/dist/utils/exhaustive.js.map +1 -1
- package/package.json +16 -15
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/pic/default-palette.d.ts +0 -2
- package/dist/pic/default-palette.d.ts.map +0 -1
- package/dist/pic/default-palettes.d.ts +0 -3
- package/dist/pic/default-palettes.d.ts.map +0 -1
- package/dist/pic/pic-step.d.ts +0 -4
- package/dist/pic/pic-step.d.ts.map +0 -1
- package/dist/pic/render-pic-options.js +0 -3
- package/dist/pic/render-pic-options.js.map +0 -1
- package/dist/pic/render-result.js +0 -3
- package/dist/pic/render-result.js.map +0 -1
- package/dist/pic/screen-buffer.d.ts +0 -7
- package/dist/pic/screen-buffer.d.ts.map +0 -1
- package/dist/pic/tools/circles.d.ts +0 -3
- package/dist/pic/tools/circles.d.ts.map +0 -1
- package/dist/pic/tools/create-blitter.d.ts +0 -5
- package/dist/pic/tools/create-blitter.d.ts.map +0 -1
- package/dist/pic/tools/create-brush.d.ts +0 -4
- package/dist/pic/tools/create-brush.d.ts.map +0 -1
- package/dist/pic/tools/create-flood-fill.d.ts +0 -4
- package/dist/pic/tools/create-flood-fill.d.ts.map +0 -1
- package/dist/pic/tools/create-line.d.ts +0 -3
- package/dist/pic/tools/create-line.d.ts.map +0 -1
- package/dist/pic/tools/create-marker.d.ts +0 -3
- package/dist/pic/tools/create-marker.d.ts.map +0 -1
- package/dist/pic/tools/create-marker.js +0 -11
- package/dist/pic/tools/create-marker.js.map +0 -1
- package/dist/pic/tools/index.d.ts +0 -6
- package/dist/pic/tools/index.d.ts.map +0 -1
- package/dist/pic/tools/index.js.map +0 -1
- package/dist/pic/tools/noise.d.ts +0 -3
- package/dist/pic/tools/noise.d.ts.map +0 -1
- package/dist/pic/tools/screen.d.ts +0 -16
- package/dist/pic/tools/screen.d.ts.map +0 -1
- package/dist/pic/tools/screen.js +0 -3
- package/dist/pic/tools/screen.js.map +0 -1
- package/dist/utils/exhaustive.d.ts +0 -2
- package/dist/utils/exhaustive.d.ts.map +0 -1
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
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","
|
|
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
|
-
|
|
2
|
-
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
25
|
+
//#endregion
|
|
26
|
+
export { loopPaddingFilter };
|
|
27
|
+
|
|
33
28
|
//# sourceMappingURL=loop-padding-filter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loop-padding-filter.js","
|
|
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
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
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","
|
|
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
|
-
|
|
2
|
-
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
22
|
+
//#endregion
|
|
23
|
+
export { menuTextFilter };
|
|
24
|
+
|
|
38
25
|
//# sourceMappingURL=menu-text-filter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu-text-filter.js","
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export { generatePic
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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","
|
|
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
|
-
|
|
2
|
-
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
Uint8Array.from(DEFAULT_PALETTE),
|
|
5
|
+
Uint8Array.from(DEFAULT_PALETTE),
|
|
6
|
+
Uint8Array.from(DEFAULT_PALETTE),
|
|
7
|
+
Uint8Array.from(DEFAULT_PALETTE)
|
|
10
8
|
];
|
|
11
|
-
|
|
9
|
+
//#endregion
|
|
10
|
+
export { defaultPalettes };
|
|
11
|
+
|
|
12
12
|
//# sourceMappingURL=default-palettes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-palettes.js","
|
|
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
|
|
2
|
-
import { RenderPicOptions } from
|
|
3
|
-
import {
|
|
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
|
-
|
|
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","
|
|
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"}
|
package/dist/pic/generate-pic.js
CHANGED
|
@@ -1,43 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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","
|
|
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"}
|
package/dist/pic/pic-step.js
CHANGED
|
@@ -1,46 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
package/dist/pic/pic-step.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pic-step.js","
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
//#region src/pic/render-pic-options.d.ts
|
|
2
|
+
interface RenderPicOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Force the selection of SCI0 palette 0–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","
|
|
1
|
+
{"version":3,"file":"render-pic-options.d.ts","names":[],"sources":["../../src/pic/render-pic-options.ts"],"mappings":";UAAiB;;;;EAIf;;;;;EAMA;;;;;EAMA"}
|
package/dist/pic/render-pic.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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
|
-
|
|
27
|
+
declare const renderPic: (pic: Pic, options?: RenderPicOptions) => RenderResult;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { renderPic };
|
|
27
30
|
//# sourceMappingURL=render-pic.d.ts.map
|