@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.
- 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,63 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.createFloodFill = void 0;
|
|
4
|
-
const numeric_deque_1 = require("@4bitlabs/numeric-deque");
|
|
1
|
+
import { NumericDeque } from "@4bitlabs/numeric-deque";
|
|
2
|
+
//#region src/pic/tools/create-flood-fill.ts
|
|
5
3
|
const createFloodFill = (plot, isLegal, [width, height]) => {
|
|
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
|
-
|
|
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
|
-
};
|
|
4
|
+
const visited = new Uint8ClampedArray(width * height);
|
|
5
|
+
const stack = new NumericDeque(width * height, Uint32Array);
|
|
6
|
+
return function floodFill(ix, iy, drawMode, drawCodes) {
|
|
7
|
+
visited.fill(0);
|
|
8
|
+
stack.clear();
|
|
9
|
+
const start = iy * width + ix;
|
|
10
|
+
stack.push(start);
|
|
11
|
+
do {
|
|
12
|
+
const i = stack.shift();
|
|
13
|
+
if (visited[i]) continue;
|
|
14
|
+
visited[i] = 255;
|
|
15
|
+
const x = i % width;
|
|
16
|
+
const y = i / width >>> 0;
|
|
17
|
+
if (!isLegal(x, y, drawMode)) continue;
|
|
18
|
+
plot(x, y, drawMode, drawCodes);
|
|
19
|
+
const initialAbove = y - 1 >= 0 && !visited[i - width] && isLegal(x, y - 1, drawMode);
|
|
20
|
+
const initialBelow = y + 1 < height && !visited[i + width] && isLegal(x, y + 1, drawMode);
|
|
21
|
+
if (initialAbove) stack.push(i - width);
|
|
22
|
+
if (initialBelow) stack.push(i + width);
|
|
23
|
+
for (let dir = 1; dir >= -1; dir -= 2) {
|
|
24
|
+
let visitedAbove = initialAbove;
|
|
25
|
+
let visitedBelow = initialBelow;
|
|
26
|
+
for (let sx = x + dir; (dir > 0 ? sx < width : sx >= 0) && isLegal(sx, y, drawMode); sx += dir) {
|
|
27
|
+
const idx = i + (sx - x);
|
|
28
|
+
visited[idx] = 255;
|
|
29
|
+
plot(sx, y, drawMode, drawCodes);
|
|
30
|
+
if (y - 1 >= 0 && !visited[idx - width]) if (isLegal(sx, y - 1, drawMode)) {
|
|
31
|
+
if (!visitedAbove) stack.push(idx - width);
|
|
32
|
+
visitedAbove = true;
|
|
33
|
+
} else visitedAbove = false;
|
|
34
|
+
if (y + 1 < height && !visited[idx + width]) if (isLegal(sx, y + 1, drawMode)) {
|
|
35
|
+
if (!visitedBelow) stack.push(idx + width);
|
|
36
|
+
visitedBelow = true;
|
|
37
|
+
} else visitedBelow = false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
} while (!stack.isEmpty());
|
|
41
|
+
};
|
|
61
42
|
};
|
|
62
|
-
|
|
43
|
+
//#endregion
|
|
44
|
+
export { createFloodFill };
|
|
45
|
+
|
|
63
46
|
//# sourceMappingURL=create-flood-fill.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-flood-fill.js","
|
|
1
|
+
{"version":3,"file":"create-flood-fill.js","names":[],"sources":["../../../src/pic/tools/create-flood-fill.ts"],"sourcesContent":["import { NumericDeque } from '@4bitlabs/numeric-deque';\nimport type { Vec2 } from '@4bitlabs/vec2';\nimport type { DrawMode, DrawCodes } from '@4bitlabs/sci0';\nimport type { Filler, IsFillable, Plotter } from './screen.js';\n\nexport const createFloodFill = (\n plot: Plotter,\n isLegal: IsFillable,\n [width, height]: Readonly<Vec2>,\n): Filler => {\n const visited = new Uint8ClampedArray(width * height);\n const stack = new NumericDeque(width * height, Uint32Array);\n\n return function floodFill(\n ix: number,\n iy: number,\n drawMode: DrawMode,\n drawCodes: DrawCodes,\n ): void {\n visited.fill(0);\n stack.clear();\n\n const start = iy * width + ix;\n stack.push(start);\n\n do {\n const i = stack.shift();\n\n if (visited[i]) continue;\n visited[i] = 0xff;\n\n const x = i % width;\n const y = (i / width) >>> 0;\n\n if (!isLegal(x, y, drawMode)) continue;\n plot(x, y, drawMode, drawCodes);\n\n const initialAbove =\n y - 1 >= 0 && !visited[i - width] && isLegal(x, y - 1, drawMode);\n const initialBelow =\n y + 1 < height && !visited[i + width] && isLegal(x, y + 1, drawMode);\n\n if (initialAbove) stack.push(i - width);\n if (initialBelow) stack.push(i + width);\n\n // scan right and left\n for (let dir = 1; dir >= -1; dir -= 2) {\n let visitedAbove = initialAbove;\n let visitedBelow = initialBelow;\n\n for (\n let sx = x + dir;\n (dir > 0 ? sx < width : sx >= 0) && isLegal(sx, y, drawMode);\n sx += dir\n ) {\n const idx = i + (sx - x);\n visited[idx] = 0xff;\n plot(sx, y, drawMode, drawCodes);\n\n if (y - 1 >= 0 && !visited[idx - width]) {\n if (isLegal(sx, y - 1, drawMode)) {\n if (!visitedAbove) stack.push(idx - width);\n visitedAbove = true;\n } else {\n visitedAbove = false;\n }\n }\n\n if (y + 1 < height && !visited[idx + width]) {\n if (isLegal(sx, y + 1, drawMode)) {\n if (!visitedBelow) stack.push(idx + width);\n visitedBelow = true;\n } else {\n visitedBelow = false;\n }\n }\n }\n }\n } while (!stack.isEmpty());\n };\n};\n"],"mappings":";;AAKA,MAAa,mBACX,MACA,SACA,CAAC,OAAO,YACG;CACX,MAAM,UAAU,IAAI,kBAAkB,QAAQ,MAAM;CACpD,MAAM,QAAQ,IAAI,aAAa,QAAQ,QAAQ,WAAW;CAE1D,OAAO,SAAS,UACd,IACA,IACA,UACA,WACM;EACN,QAAQ,KAAK,CAAC;EACd,MAAM,MAAM;EAEZ,MAAM,QAAQ,KAAK,QAAQ;EAC3B,MAAM,KAAK,KAAK;EAEhB,GAAG;GACD,MAAM,IAAI,MAAM,MAAM;GAEtB,IAAI,QAAQ,IAAI;GAChB,QAAQ,KAAK;GAEb,MAAM,IAAI,IAAI;GACd,MAAM,IAAK,IAAI,UAAW;GAE1B,IAAI,CAAC,QAAQ,GAAG,GAAG,QAAQ,GAAG;GAC9B,KAAK,GAAG,GAAG,UAAU,SAAS;GAE9B,MAAM,eACJ,IAAI,KAAK,KAAK,CAAC,QAAQ,IAAI,UAAU,QAAQ,GAAG,IAAI,GAAG,QAAQ;GACjE,MAAM,eACJ,IAAI,IAAI,UAAU,CAAC,QAAQ,IAAI,UAAU,QAAQ,GAAG,IAAI,GAAG,QAAQ;GAErE,IAAI,cAAc,MAAM,KAAK,IAAI,KAAK;GACtC,IAAI,cAAc,MAAM,KAAK,IAAI,KAAK;GAGtC,KAAK,IAAI,MAAM,GAAG,OAAO,IAAI,OAAO,GAAG;IACrC,IAAI,eAAe;IACnB,IAAI,eAAe;IAEnB,KACE,IAAI,KAAK,IAAI,MACZ,MAAM,IAAI,KAAK,QAAQ,MAAM,MAAM,QAAQ,IAAI,GAAG,QAAQ,GAC3D,MAAM,KACN;KACA,MAAM,MAAM,KAAK,KAAK;KACtB,QAAQ,OAAO;KACf,KAAK,IAAI,GAAG,UAAU,SAAS;KAE/B,IAAI,IAAI,KAAK,KAAK,CAAC,QAAQ,MAAM,QAC/B,IAAI,QAAQ,IAAI,IAAI,GAAG,QAAQ,GAAG;MAChC,IAAI,CAAC,cAAc,MAAM,KAAK,MAAM,KAAK;MACzC,eAAe;KACjB,OACE,eAAe;KAInB,IAAI,IAAI,IAAI,UAAU,CAAC,QAAQ,MAAM,QACnC,IAAI,QAAQ,IAAI,IAAI,GAAG,QAAQ,GAAG;MAChC,IAAI,CAAC,cAAc,MAAM,KAAK,MAAM,KAAK;MACzC,eAAe;KACjB,OACE,eAAe;IAGrB;GACF;EACF,SAAS,CAAC,MAAM,QAAQ;CAC1B;AACF"}
|
|
@@ -1,46 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createLine = void 0;
|
|
1
|
+
//#region src/pic/tools/create-line.ts
|
|
4
2
|
const createLine = (plot) => function line(x0, y0, x1, y1, drawMode, drawCodes) {
|
|
5
|
-
|
|
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
|
-
if (eps << 1 >= ady) {
|
|
39
|
-
x += sx;
|
|
40
|
-
eps -= ady;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
3
|
+
if (x0 === x1) {
|
|
4
|
+
for (let y = Math.min(y0, y1); y <= Math.max(y0, y1); y++) plot(x0, y, drawMode, drawCodes);
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
if (y0 === y1) {
|
|
8
|
+
for (let x = Math.min(x0, x1); x <= Math.max(x0, x1); x++) plot(x, y0, drawMode, drawCodes);
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
plot(x0, y0, drawMode, drawCodes);
|
|
12
|
+
plot(x1, y1, drawMode, drawCodes);
|
|
13
|
+
const dx = x1 - x0;
|
|
14
|
+
const dy = y1 - y0;
|
|
15
|
+
const adx = Math.abs(dx);
|
|
16
|
+
const ady = Math.abs(dy);
|
|
17
|
+
const sx = dx > 0 ? 1 : -1;
|
|
18
|
+
const sy = dy > 0 ? 1 : -1;
|
|
19
|
+
let eps = 0;
|
|
20
|
+
if (adx > ady) for (let x = x0, y = y0; sx < 0 ? x >= x1 : x <= x1; x += sx) {
|
|
21
|
+
plot(x, y, drawMode, drawCodes);
|
|
22
|
+
eps += ady;
|
|
23
|
+
if (eps << 1 >= adx) {
|
|
24
|
+
y += sy;
|
|
25
|
+
eps -= adx;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else for (let x = x0, y = y0; sy < 0 ? y >= y1 : y <= y1; y += sy) {
|
|
29
|
+
plot(x, y, drawMode, drawCodes);
|
|
30
|
+
eps += adx;
|
|
31
|
+
if (eps << 1 >= ady) {
|
|
32
|
+
x += sx;
|
|
33
|
+
eps -= ady;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
44
36
|
};
|
|
45
|
-
|
|
37
|
+
//#endregion
|
|
38
|
+
export { createLine };
|
|
39
|
+
|
|
46
40
|
//# sourceMappingURL=create-line.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-line.js","
|
|
1
|
+
{"version":3,"file":"create-line.js","names":[],"sources":["../../../src/pic/tools/create-line.ts"],"sourcesContent":["import type { DrawMode, DrawCodes } from '@4bitlabs/sci0';\nimport type { Liner, Plotter } from './screen.js';\n\nexport const createLine = (plot: Plotter): Liner =>\n function line(\n x0: number,\n y0: number,\n x1: number,\n y1: number,\n drawMode: DrawMode,\n drawCodes: DrawCodes,\n ): void {\n if (x0 === x1) {\n for (let y = Math.min(y0, y1); y <= Math.max(y0, y1); y++)\n plot(x0, y, drawMode, drawCodes);\n return;\n }\n\n if (y0 === y1) {\n for (let x = Math.min(x0, x1); x <= Math.max(x0, x1); x++)\n plot(x, y0, drawMode, drawCodes);\n return;\n }\n\n plot(x0, y0, drawMode, drawCodes);\n plot(x1, y1, drawMode, drawCodes);\n\n const dx = x1 - x0;\n const dy = y1 - y0;\n const adx = Math.abs(dx);\n const ady = Math.abs(dy);\n const sx = dx > 0 ? 1 : -1;\n const sy = dy > 0 ? 1 : -1;\n\n let eps = 0;\n\n if (adx > ady) {\n for (let x = x0, y = y0; sx < 0 ? x >= x1 : x <= x1; x += sx) {\n plot(x, y, drawMode, drawCodes);\n eps += ady;\n if (eps << 1 >= adx) {\n y += sy;\n eps -= adx;\n }\n }\n } else {\n for (let x = x0, y = y0; sy < 0 ? y >= y1 : y <= y1; y += sy) {\n plot(x, y, drawMode, drawCodes);\n eps += adx;\n if (eps << 1 >= ady) {\n x += sx;\n eps -= ady;\n }\n }\n }\n };\n"],"mappings":";AAGA,MAAa,cAAc,SACzB,SAAS,KACP,IACA,IACA,IACA,IACA,UACA,WACM;CACN,IAAI,OAAO,IAAI;EACb,KAAK,IAAI,IAAI,KAAK,IAAI,IAAI,EAAE,GAAG,KAAK,KAAK,IAAI,IAAI,EAAE,GAAG,KACpD,KAAK,IAAI,GAAG,UAAU,SAAS;EACjC;CACF;CAEA,IAAI,OAAO,IAAI;EACb,KAAK,IAAI,IAAI,KAAK,IAAI,IAAI,EAAE,GAAG,KAAK,KAAK,IAAI,IAAI,EAAE,GAAG,KACpD,KAAK,GAAG,IAAI,UAAU,SAAS;EACjC;CACF;CAEA,KAAK,IAAI,IAAI,UAAU,SAAS;CAChC,KAAK,IAAI,IAAI,UAAU,SAAS;CAEhC,MAAM,KAAK,KAAK;CAChB,MAAM,KAAK,KAAK;CAChB,MAAM,MAAM,KAAK,IAAI,EAAE;CACvB,MAAM,MAAM,KAAK,IAAI,EAAE;CACvB,MAAM,KAAK,KAAK,IAAI,IAAI;CACxB,MAAM,KAAK,KAAK,IAAI,IAAI;CAExB,IAAI,MAAM;CAEV,IAAI,MAAM,KACR,KAAK,IAAI,IAAI,IAAI,IAAI,IAAI,KAAK,IAAI,KAAK,KAAK,KAAK,IAAI,KAAK,IAAI;EAC5D,KAAK,GAAG,GAAG,UAAU,SAAS;EAC9B,OAAO;EACP,IAAI,OAAO,KAAK,KAAK;GACnB,KAAK;GACL,OAAO;EACT;CACF;MAEA,KAAK,IAAI,IAAI,IAAI,IAAI,IAAI,KAAK,IAAI,KAAK,KAAK,KAAK,IAAI,KAAK,IAAI;EAC5D,KAAK,GAAG,GAAG,UAAU,SAAS;EAC9B,OAAO;EACP,IAAI,OAAO,KAAK,KAAK;GACnB,KAAK;GACL,OAAO;EACT;CACF;AAEJ"}
|
package/dist/pic/tools/index.js
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
|
1
|
+
import { createBrush } from "./create-brush.js";
|
|
2
|
+
import { createFloodFill } from "./create-flood-fill.js";
|
|
3
|
+
import { createLine } from "./create-line.js";
|
|
4
|
+
import { createBlitter } from "./create-blitter.js";
|
|
5
|
+
export { createBlitter, createBrush, createFloodFill, createLine };
|
package/dist/pic/tools/noise.js
CHANGED
|
@@ -1,24 +1,162 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
//#region src/pic/tools/noise.ts
|
|
2
|
+
const BYTE = Array(8).fill(0).map((_, i) => i);
|
|
3
|
+
const NOISE = [
|
|
4
|
+
32,
|
|
5
|
+
148,
|
|
6
|
+
2,
|
|
7
|
+
36,
|
|
8
|
+
144,
|
|
9
|
+
130,
|
|
10
|
+
164,
|
|
11
|
+
162,
|
|
12
|
+
130,
|
|
13
|
+
9,
|
|
14
|
+
10,
|
|
15
|
+
34,
|
|
16
|
+
18,
|
|
17
|
+
16,
|
|
18
|
+
66,
|
|
19
|
+
20,
|
|
20
|
+
145,
|
|
21
|
+
74,
|
|
22
|
+
145,
|
|
23
|
+
17,
|
|
24
|
+
8,
|
|
25
|
+
18,
|
|
26
|
+
37,
|
|
27
|
+
16,
|
|
28
|
+
34,
|
|
29
|
+
168,
|
|
30
|
+
20,
|
|
31
|
+
36,
|
|
32
|
+
0,
|
|
33
|
+
80,
|
|
34
|
+
36,
|
|
35
|
+
4
|
|
36
|
+
].flatMap((it) => BYTE.map((idx) => (it >>> 7 - idx & 1) === 1));
|
|
37
|
+
const NOISE_OFFSETS = [
|
|
38
|
+
0,
|
|
39
|
+
24,
|
|
40
|
+
48,
|
|
41
|
+
196,
|
|
42
|
+
220,
|
|
43
|
+
101,
|
|
44
|
+
235,
|
|
45
|
+
72,
|
|
46
|
+
96,
|
|
47
|
+
189,
|
|
48
|
+
137,
|
|
49
|
+
4,
|
|
50
|
+
10,
|
|
51
|
+
244,
|
|
52
|
+
125,
|
|
53
|
+
109,
|
|
54
|
+
133,
|
|
55
|
+
176,
|
|
56
|
+
142,
|
|
57
|
+
149,
|
|
58
|
+
31,
|
|
59
|
+
34,
|
|
60
|
+
13,
|
|
61
|
+
223,
|
|
62
|
+
42,
|
|
63
|
+
120,
|
|
64
|
+
213,
|
|
65
|
+
115,
|
|
66
|
+
28,
|
|
67
|
+
180,
|
|
68
|
+
64,
|
|
69
|
+
161,
|
|
70
|
+
185,
|
|
71
|
+
60,
|
|
72
|
+
202,
|
|
73
|
+
88,
|
|
74
|
+
146,
|
|
75
|
+
52,
|
|
76
|
+
204,
|
|
77
|
+
206,
|
|
78
|
+
215,
|
|
79
|
+
66,
|
|
80
|
+
144,
|
|
81
|
+
15,
|
|
82
|
+
139,
|
|
83
|
+
127,
|
|
84
|
+
50,
|
|
85
|
+
237,
|
|
86
|
+
92,
|
|
87
|
+
157,
|
|
88
|
+
200,
|
|
89
|
+
153,
|
|
90
|
+
173,
|
|
91
|
+
78,
|
|
92
|
+
86,
|
|
93
|
+
166,
|
|
94
|
+
247,
|
|
95
|
+
104,
|
|
96
|
+
183,
|
|
97
|
+
37,
|
|
98
|
+
130,
|
|
99
|
+
55,
|
|
100
|
+
58,
|
|
101
|
+
81,
|
|
102
|
+
105,
|
|
103
|
+
38,
|
|
104
|
+
56,
|
|
105
|
+
82,
|
|
106
|
+
158,
|
|
107
|
+
154,
|
|
108
|
+
79,
|
|
109
|
+
167,
|
|
110
|
+
67,
|
|
111
|
+
16,
|
|
112
|
+
128,
|
|
113
|
+
238,
|
|
114
|
+
61,
|
|
115
|
+
89,
|
|
116
|
+
53,
|
|
117
|
+
207,
|
|
118
|
+
121,
|
|
119
|
+
116,
|
|
120
|
+
181,
|
|
121
|
+
162,
|
|
122
|
+
177,
|
|
123
|
+
150,
|
|
124
|
+
35,
|
|
125
|
+
224,
|
|
126
|
+
190,
|
|
127
|
+
5,
|
|
128
|
+
245,
|
|
129
|
+
110,
|
|
130
|
+
25,
|
|
131
|
+
197,
|
|
132
|
+
102,
|
|
133
|
+
73,
|
|
134
|
+
240,
|
|
135
|
+
209,
|
|
136
|
+
84,
|
|
137
|
+
169,
|
|
138
|
+
112,
|
|
139
|
+
75,
|
|
140
|
+
164,
|
|
141
|
+
226,
|
|
142
|
+
230,
|
|
143
|
+
229,
|
|
144
|
+
171,
|
|
145
|
+
228,
|
|
146
|
+
210,
|
|
147
|
+
170,
|
|
148
|
+
76,
|
|
149
|
+
227,
|
|
150
|
+
6,
|
|
151
|
+
111,
|
|
152
|
+
198,
|
|
153
|
+
74,
|
|
154
|
+
117,
|
|
155
|
+
163,
|
|
156
|
+
151,
|
|
157
|
+
225
|
|
23
158
|
];
|
|
159
|
+
//#endregion
|
|
160
|
+
export { NOISE, NOISE_OFFSETS };
|
|
161
|
+
|
|
24
162
|
//# sourceMappingURL=noise.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noise.js","
|
|
1
|
+
{"version":3,"file":"noise.js","names":[],"sources":["../../../src/pic/tools/noise.ts"],"sourcesContent":["const BYTE = Array(8)\n .fill(0)\n .map((_, i) => i);\n\nexport const NOISE: boolean[] = [\n 0x20, 0x94, 0x02, 0x24, 0x90, 0x82, 0xa4, 0xa2, 0x82, 0x09, 0x0a, 0x22, 0x12,\n 0x10, 0x42, 0x14, 0x91, 0x4a, 0x91, 0x11, 0x08, 0x12, 0x25, 0x10, 0x22, 0xa8,\n 0x14, 0x24, 0x00, 0x50, 0x24, 0x04,\n].flatMap((it) => BYTE.map((idx) => ((it >>> (7 - idx)) & 0b1) === 0b1));\n\nexport const NOISE_OFFSETS: number[] = [\n 0x00, 0x18, 0x30, 0xc4, 0xdc, 0x65, 0xeb, 0x48, 0x60, 0xbd, 0x89, 0x04, 0x0a,\n 0xf4, 0x7d, 0x6d, 0x85, 0xb0, 0x8e, 0x95, 0x1f, 0x22, 0x0d, 0xdf, 0x2a, 0x78,\n 0xd5, 0x73, 0x1c, 0xb4, 0x40, 0xa1, 0xb9, 0x3c, 0xca, 0x58, 0x92, 0x34, 0xcc,\n 0xce, 0xd7, 0x42, 0x90, 0x0f, 0x8b, 0x7f, 0x32, 0xed, 0x5c, 0x9d, 0xc8, 0x99,\n 0xad, 0x4e, 0x56, 0xa6, 0xf7, 0x68, 0xb7, 0x25, 0x82, 0x37, 0x3a, 0x51, 0x69,\n 0x26, 0x38, 0x52, 0x9e, 0x9a, 0x4f, 0xa7, 0x43, 0x10, 0x80, 0xee, 0x3d, 0x59,\n 0x35, 0xcf, 0x79, 0x74, 0xb5, 0xa2, 0xb1, 0x96, 0x23, 0xe0, 0xbe, 0x05, 0xf5,\n 0x6e, 0x19, 0xc5, 0x66, 0x49, 0xf0, 0xd1, 0x54, 0xa9, 0x70, 0x4b, 0xa4, 0xe2,\n 0xe6, 0xe5, 0xab, 0xe4, 0xd2, 0xaa, 0x4c, 0xe3, 0x06, 0x6f, 0xc6, 0x4a, 0x75,\n 0xa3, 0x97, 0xe1,\n];\n"],"mappings":";AAAA,MAAM,OAAO,MAAM,CAAC,CAAC,CAClB,KAAK,CAAC,CAAC,CACP,KAAK,GAAG,MAAM,CAAC;AAElB,MAAa,QAAmB;CAC9B;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CACxE;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CACxE;CAAM;CAAM;CAAM;CAAM;CAAM;AAChC,CAAC,CAAC,SAAS,OAAO,KAAK,KAAK,SAAU,OAAQ,IAAI,MAAQ,OAAS,CAAG,CAAC;AAEvE,MAAa,gBAA0B;CACrC;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CACxE;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CACxE;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CACxE;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CACxE;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CACxE;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CACxE;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CACxE;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CACxE;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CACxE;CAAM;CAAM;AACd"}
|
package/dist/utils/exhaustive.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.exhaustive = exhaustive;
|
|
1
|
+
//#region src/utils/exhaustive.ts
|
|
4
2
|
function exhaustive(msg, _) {
|
|
5
|
-
|
|
3
|
+
throw new Error(`${msg}: ${JSON.stringify(_)}`);
|
|
6
4
|
}
|
|
5
|
+
//#endregion
|
|
6
|
+
export { exhaustive };
|
|
7
|
+
|
|
7
8
|
//# sourceMappingURL=exhaustive.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exhaustive.js","
|
|
1
|
+
{"version":3,"file":"exhaustive.js","names":[],"sources":["../../src/utils/exhaustive.ts"],"sourcesContent":["export function exhaustive(msg: string, _: never): never {\n throw new Error(`${msg}: ${JSON.stringify(_)}`);\n}\n"],"mappings":";AAAA,SAAgB,WAAW,KAAa,GAAiB;CACvD,MAAM,IAAI,MAAM,GAAG,IAAI,IAAI,KAAK,UAAU,CAAC,GAAG;AAChD"}
|
package/package.json
CHANGED
|
@@ -1,32 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@4bitlabs/sci0-renderer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
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
5
|
"homepage": "https://github.com/32bitkid/sci.js/tree/main/libs/sci0#readme",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/32bitkid/sci.js/issues"
|
|
8
|
+
},
|
|
8
9
|
"repository": {
|
|
9
10
|
"type": "git",
|
|
10
11
|
"url": "git+https://github.com/32bitkid/sci.js.git"
|
|
11
12
|
},
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
"license": "ISC",
|
|
14
|
+
"author": "J. Holmes <j@holmes.codes>",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"exports": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
15
18
|
"files": [
|
|
16
19
|
"./dist/**/*"
|
|
17
20
|
],
|
|
18
21
|
"scripts": {
|
|
22
|
+
"build": "tsdown",
|
|
19
23
|
"clean": "tsc --build --clean",
|
|
20
|
-
"clean:wipe": "rimraf ./dist"
|
|
21
|
-
"build": "tsc --build"
|
|
24
|
+
"clean:wipe": "rimraf ./dist"
|
|
22
25
|
},
|
|
23
|
-
"author": "J. Holmes <j@holmes.codes>",
|
|
24
|
-
"license": "ISC",
|
|
25
26
|
"dependencies": {
|
|
26
|
-
"@4bitlabs/image": "^
|
|
27
|
-
"@4bitlabs/numeric-deque": "^
|
|
28
|
-
"@4bitlabs/sci0": "^
|
|
29
|
-
"@4bitlabs/vec2": "^
|
|
27
|
+
"@4bitlabs/image": "^5.0.0",
|
|
28
|
+
"@4bitlabs/numeric-deque": "^2.0.0",
|
|
29
|
+
"@4bitlabs/sci0": "^6.0.0",
|
|
30
|
+
"@4bitlabs/vec2": "^3.0.0"
|
|
30
31
|
},
|
|
31
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "e8b4502e1f5fd42407c8857829e66eb5713a9f84"
|
|
32
33
|
}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"default-palette.d.ts","sourceRoot":"","sources":["../../src/pic/default-palette.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,eAAe,0LAKlB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/pic/pic-step.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"render-pic-options.js","sourceRoot":"","sources":["../../src/pic/render-pic-options.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"render-result.js","sourceRoot":"","sources":["../../src/pic/render-result.ts"],"names":[],"mappings":""}
|
|
@@ -1,7 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,5 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|