@4bitlabs/sci0 2.3.0 → 2.4.1
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/index.d.ts +1 -1
- package/dist/models/cursor.d.ts +0 -1
- package/dist/models/cursor.d.ts.map +1 -1
- package/dist/parsers/cursor.d.ts +7 -2
- package/dist/parsers/cursor.d.ts.map +1 -1
- package/dist/parsers/cursor.js +16 -10
- package/dist/parsers/cursor.js.map +1 -1
- package/dist/parsers/font.d.ts +5 -1
- package/dist/parsers/font.d.ts.map +1 -1
- package/dist/parsers/font.js +4 -4
- package/dist/parsers/font.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export declare const Cursor: {
|
|
|
21
21
|
};
|
|
22
22
|
/** @deprecated use parseFont() instead */
|
|
23
23
|
export declare const Font: {
|
|
24
|
-
parseFrom: (source: Uint8Array) => import("./models/font-face").FontFace;
|
|
24
|
+
parseFrom: (source: Uint8Array, options?: import("./parsers/font").ParseFontOptions) => import("./models/font-face").FontFace;
|
|
25
25
|
};
|
|
26
26
|
/** @deprecated use parseView() instead */
|
|
27
27
|
export declare const View: {
|
package/dist/models/cursor.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cursor.d.ts","sourceRoot":"","sources":["../../src/models/cursor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,MAAM,WAAW,MAAO,SAAQ,gBAAgB;IAC9C,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"cursor.d.ts","sourceRoot":"","sources":["../../src/models/cursor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,MAAM,WAAW,MAAO,SAAQ,gBAAgB;IAC9C,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7C"}
|
package/dist/parsers/cursor.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { type Cursor } from '../models/cursor';
|
|
2
|
-
type
|
|
2
|
+
type ColorMapping = {
|
|
3
|
+
black: number;
|
|
4
|
+
gray: number;
|
|
5
|
+
white: number;
|
|
6
|
+
keyColor: number;
|
|
7
|
+
};
|
|
3
8
|
export interface ParseCursorOptions {
|
|
4
|
-
mapping?:
|
|
9
|
+
mapping?: ColorMapping;
|
|
5
10
|
}
|
|
6
11
|
export declare const parseFrom: (source: Uint8Array, options?: ParseCursorOptions) => Cursor;
|
|
7
12
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cursor.d.ts","sourceRoot":"","sources":["../../src/parsers/cursor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"cursor.d.ts","sourceRoot":"","sources":["../../src/parsers/cursor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE/C,KAAK,YAAY,GAAG;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AASF,MAAM,WAAW,kBAAkB;IACjC,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB;AAED,eAAO,MAAM,SAAS,WACZ,UAAU,YACT,kBAAkB,KAC1B,MAsCF,CAAC"}
|
package/dist/parsers/cursor.js
CHANGED
|
@@ -2,18 +2,25 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseFrom = void 0;
|
|
4
4
|
const image_1 = require("@4bitlabs/image");
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
const DEFAULT_MAPPING = {
|
|
6
|
+
black: 0x00,
|
|
7
|
+
white: 0x0f,
|
|
8
|
+
gray: 0x07,
|
|
9
|
+
keyColor: 0x0d,
|
|
10
|
+
};
|
|
10
11
|
const parseFrom = (source, options = {}) => {
|
|
11
12
|
const { mapping = DEFAULT_MAPPING } = options;
|
|
13
|
+
const { keyColor } = mapping;
|
|
14
|
+
const colorLut = [
|
|
15
|
+
mapping.black,
|
|
16
|
+
mapping.white,
|
|
17
|
+
mapping.keyColor,
|
|
18
|
+
mapping.gray,
|
|
19
|
+
];
|
|
12
20
|
const view = new DataView(source.buffer, source.byteOffset, source.byteLength);
|
|
13
|
-
// Parse data;
|
|
14
21
|
const hotspot = [view.getUint16(0, true), view.getUint16(2, true)];
|
|
15
|
-
const img = (0, image_1.createIndexedPixelData)(16, 16);
|
|
16
|
-
const stride = 16
|
|
22
|
+
const img = (0, image_1.createIndexedPixelData)(16, 16, { keyColor });
|
|
23
|
+
const stride = 16;
|
|
17
24
|
for (let y = 0; y < 16; y++) {
|
|
18
25
|
for (let x = 0; x < 16; x++) {
|
|
19
26
|
const idx = 4 + y * 2;
|
|
@@ -22,12 +29,11 @@ const parseFrom = (source, options = {}) => {
|
|
|
22
29
|
const a = (tx >> (15 - x)) & 1;
|
|
23
30
|
const b = (clr >> (15 - x)) & 1;
|
|
24
31
|
const value = (a << 1) | b;
|
|
25
|
-
img.pixels[x
|
|
32
|
+
img.pixels[x + y * stride] = colorLut[value];
|
|
26
33
|
}
|
|
27
34
|
}
|
|
28
35
|
return {
|
|
29
36
|
...img,
|
|
30
|
-
keyColor: 0xff,
|
|
31
37
|
hotspot,
|
|
32
38
|
};
|
|
33
39
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cursor.js","sourceRoot":"","sources":["../../src/parsers/cursor.ts"],"names":[],"mappings":";;;AAAA,2CAAyD;
|
|
1
|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E,IAAI,CAAC,CAAC;YACrC,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC;YAE3C,MAAM,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;YAC/B,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;YAChC,MAAM,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;YAC3B,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;IAED,OAAO;QACL,GAAG,GAAG;QACN,OAAO;KACR,CAAC;AACJ,CAAC,CAAC;AAzCW,QAAA,SAAS,aAyCpB"}
|
package/dist/parsers/font.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import { FontFace } from '../models/font-face';
|
|
2
|
-
export
|
|
2
|
+
export interface ParseFontOptions {
|
|
3
|
+
color?: number;
|
|
4
|
+
keyColor?: number;
|
|
5
|
+
}
|
|
6
|
+
export declare const parseFrom: (source: Uint8Array, options?: ParseFontOptions) => FontFace;
|
|
3
7
|
//# sourceMappingURL=font.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"font.d.ts","sourceRoot":"","sources":["../../src/parsers/font.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"font.d.ts","sourceRoot":"","sources":["../../src/parsers/font.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAG/C,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,SAAS,WACZ,UAAU,YACT,gBAAgB,KACxB,QAqCF,CAAC"}
|
package/dist/parsers/font.js
CHANGED
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.parseFrom = void 0;
|
|
4
4
|
const image_1 = require("@4bitlabs/image");
|
|
5
5
|
const repeat_1 = require("../utils/repeat");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
6
|
+
const parseFrom = (source, options = {}) => {
|
|
7
|
+
const { color = 0x0f, keyColor = 0x00 } = options;
|
|
8
8
|
const headerView = new DataView(source.buffer, source.byteOffset, 6);
|
|
9
9
|
const count = headerView.getUint16(2, true);
|
|
10
10
|
const lineHeight = headerView.getUint16(4, true);
|
|
@@ -13,13 +13,13 @@ const parseFrom = (source) => {
|
|
|
13
13
|
const characters = pointers.map((offset) => {
|
|
14
14
|
const [width, height] = [source[offset], source[offset + 1]];
|
|
15
15
|
const widthBytes = (width + 7) >>> 3;
|
|
16
|
-
const image = (0, image_1.createIndexedPixelData)(width, height, { keyColor
|
|
16
|
+
const image = (0, image_1.createIndexedPixelData)(width, height, { keyColor });
|
|
17
17
|
for (let y = 0; y < height; y++) {
|
|
18
18
|
const yOffset = offset + 2 + y * widthBytes;
|
|
19
19
|
for (let x = 0; x < width; x++) {
|
|
20
20
|
const idx = yOffset + (x >>> 3);
|
|
21
21
|
const bit = (source[idx] >>> (7 - (x & 0b111))) & 1;
|
|
22
|
-
image.pixels[x
|
|
22
|
+
image.pixels[x + y * width] = bit ? color : keyColor;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
return image;
|
package/dist/parsers/font.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"font.js","sourceRoot":"","sources":["../../src/parsers/font.ts"],"names":[],"mappings":";;;AAAA,2CAAgF;AAEhF,4CAAyC;
|
|
1
|
+
{"version":3,"file":"font.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AM,EAAE,CAAC,EAAE,EAAE,CAAC;YAChC,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC;YAE5C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC/B,MAAM,GAAG,GAAG,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;gBAChC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;gBACpD,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC;YACvD,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,UAAU;QACV,UAAU;KACX,CAAC;AACJ,CAAC,CAAC;AAxCW,QAAA,SAAS,aAwCpB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@4bitlabs/sci0",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.1",
|
|
4
4
|
"description": "Library for parsing and rendering assets from Sierra On-line's SCI-engine.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"license": "ISC",
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@4bitlabs/codecs": "^1.0.4",
|
|
28
|
-
"@4bitlabs/image": "^3.3.
|
|
28
|
+
"@4bitlabs/image": "^3.3.2",
|
|
29
29
|
"@4bitlabs/numeric-deque": "^1.1.3",
|
|
30
30
|
"@4bitlabs/readers": "^2.0.4"
|
|
31
31
|
}
|