ttpg-darrell 1.1.68 → 1.1.69
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/build/cjs/lib/bug-workarounds/bug-unique-cards/bug-unique-cards.js +3 -1
- package/build/cjs/lib/bug-workarounds/bug-unique-cards/bug-unique-cards.js.map +1 -1
- package/build/cjs/lib/color-lib/color-mapping-rotating.d.ts +1 -0
- package/build/cjs/lib/color-lib/color-mapping-rotating.js +72 -0
- package/build/cjs/lib/color-lib/color-mapping-rotating.js.map +1 -0
- package/build/cjs/lib/dice-group/dice-group-testp.d.ts +1 -0
- package/build/cjs/lib/dice-group/dice-group-testp.js +39 -0
- package/build/cjs/lib/dice-group/dice-group-testp.js.map +1 -0
- package/build/cjs/lib/game-object/cardholder-player-name/cardholder-player-name-obj.d.ts +1 -0
- package/build/cjs/lib/game-object/cardholder-player-name/cardholder-player-name-obj.js +12 -0
- package/build/cjs/lib/game-object/cardholder-player-name/cardholder-player-name-obj.js.map +1 -0
- package/build/cjs/lib/game-object/deleted-items-container/deleted-items-container-obj.d.ts +1 -0
- package/build/cjs/lib/game-object/deleted-items-container/deleted-items-container-obj.js +7 -0
- package/build/cjs/lib/game-object/deleted-items-container/deleted-items-container-obj.js.map +1 -0
- package/build/cjs/lib/game-object/garbage/garbage-container-obj.d.ts +1 -0
- package/build/cjs/lib/game-object/garbage/garbage-container-obj.js +6 -0
- package/build/cjs/lib/game-object/garbage/garbage-container-obj.js.map +1 -0
- package/build/cjs/lib/parse/parse-color/parse-color.d.ts +7 -0
- package/build/cjs/lib/parse/parse-color/parse-color.js +51 -0
- package/build/cjs/lib/parse/parse-color/parse-color.js.map +1 -0
- package/build/cjs/lib-ext/color-mapping/color-extract.d.ts +1 -0
- package/build/cjs/lib-ext/color-mapping/color-extract.js +127 -0
- package/build/cjs/lib-ext/color-mapping/color-extract.js.map +1 -0
- package/build/cjs/lib-ext/color-mapping/color-mapping-linear-centered.d.ts +1 -0
- package/build/cjs/lib-ext/color-mapping/color-mapping-linear-centered.js +230 -0
- package/build/cjs/lib-ext/color-mapping/color-mapping-linear-centered.js.map +1 -0
- package/build/cjs/lib-ext/color-mapping/color-mapping-linear.d.ts +1 -0
- package/build/cjs/lib-ext/color-mapping/color-mapping-linear.js +217 -0
- package/build/cjs/lib-ext/color-mapping/color-mapping-linear.js.map +1 -0
- package/build/cjs/lib-ext/color-mapping/color-mapping-ridge.d.ts +1 -0
- package/build/cjs/lib-ext/color-mapping/color-mapping-ridge.js +216 -0
- package/build/cjs/lib-ext/color-mapping/color-mapping-ridge.js.map +1 -0
- package/build/cjs/lib-ext/color-mapping/color-mapping.d.ts +15 -0
- package/build/cjs/lib-ext/color-mapping/color-mapping.data.d.ts +7 -0
- package/build/cjs/lib-ext/color-mapping/color-mapping.data.js +790 -0
- package/build/cjs/lib-ext/color-mapping/color-mapping.data.js.map +1 -0
- package/build/cjs/lib-ext/color-mapping/color-mapping.js +54 -0
- package/build/cjs/lib-ext/color-mapping/color-mapping.js.map +1 -0
- package/build/cjs/lib-ext/color-mapping/raw-linear.d.ts +1 -0
- package/build/cjs/lib-ext/color-mapping/raw-linear.js +167 -0
- package/build/cjs/lib-ext/color-mapping/raw-linear.js.map +1 -0
- package/build/cjs/lib-ext/image/cell/cell-parser/cell-parser.test.d.ts +1 -0
- package/build/cjs/lib-ext/image/cell/cell-parser/cell-parser.test.js +212 -0
- package/build/cjs/lib-ext/image/cell/cell-parser/cell-parser.test.js.map +1 -0
- package/build/esm/lib/bug-workarounds/bug-unique-cards/bug-unique-cards.js +3 -1
- package/build/esm/lib/bug-workarounds/bug-unique-cards/bug-unique-cards.js.map +1 -1
- package/build/esm/lib/dice-group/dice-group-testp.d.ts +1 -0
- package/build/esm/lib/dice-group/dice-group-testp.js +37 -0
- package/build/esm/lib/dice-group/dice-group-testp.js.map +1 -0
- package/build/esm/lib/game-object/cardholder-player-name/cardholder-player-name-obj.d.ts +1 -0
- package/build/esm/lib/game-object/cardholder-player-name/cardholder-player-name-obj.js +10 -0
- package/build/esm/lib/game-object/cardholder-player-name/cardholder-player-name-obj.js.map +1 -0
- package/build/esm/lib/game-object/deleted-items-container/deleted-items-container-obj.d.ts +1 -0
- package/build/esm/lib/game-object/deleted-items-container/deleted-items-container-obj.js +5 -0
- package/build/esm/lib/game-object/deleted-items-container/deleted-items-container-obj.js.map +1 -0
- package/build/esm/lib/game-object/garbage/garbage-container-obj.d.ts +1 -0
- package/build/esm/lib/game-object/garbage/garbage-container-obj.js +4 -0
- package/build/esm/lib/game-object/garbage/garbage-container-obj.js.map +1 -0
- package/build/esm/lib/parse/parse-color/parse-color.d.ts +7 -0
- package/build/esm/lib/parse/parse-color/parse-color.js +44 -0
- package/build/esm/lib/parse/parse-color/parse-color.js.map +1 -0
- package/build/esm/lib-ext/image/cell/cell-parser/cell-parser.test.d.ts +1 -0
- package/build/esm/lib-ext/image/cell/cell-parser/cell-parser.test.js +210 -0
- package/build/esm/lib-ext/image/cell/cell-parser/cell-parser.test.js.map +1 -0
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@ const api_1 = require("@tabletop-playground/api");
|
|
|
5
5
|
const card_util_1 = require("../../card-util/card-util");
|
|
6
6
|
const deleted_items_container_1 = require("../../game-object/deleted-items-container/deleted-items-container");
|
|
7
7
|
const error_handler_1 = require("../../error-handler/error-handler");
|
|
8
|
+
const nsid_1 = require("../../nsid");
|
|
8
9
|
/**
|
|
9
10
|
* Monitor all decks expecting no NSID (metadata) repeats.
|
|
10
11
|
* Prune extra cards if found.
|
|
@@ -43,9 +44,10 @@ class BugUniqueCards {
|
|
|
43
44
|
});
|
|
44
45
|
if (removed) {
|
|
45
46
|
const removeCount = removed.getStackSize();
|
|
47
|
+
const removeNsids = nsid_1.NSID.getDeck(removed);
|
|
46
48
|
const residueCount = deck.getStackSize();
|
|
47
49
|
deleted_items_container_1.DeletedItemsContainer.destroyWithoutCopying(removed);
|
|
48
|
-
const msg = `BugUniqueCards: removed ${removeCount} duplicates, ${residueCount} remain`;
|
|
50
|
+
const msg = `BugUniqueCards: removed ${removeCount} duplicates, ${residueCount} remain [first dup: "${removeNsids[0]}"]`;
|
|
49
51
|
console.log(msg);
|
|
50
52
|
error_handler_1.ErrorHandler.onError.trigger(msg);
|
|
51
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bug-unique-cards.js","sourceRoot":"","sources":["../../../../../src/lib/bug-workarounds/bug-unique-cards/bug-unique-cards.ts"],"names":[],"mappings":";;;AAAA,kDAA6E;AAE7E,yDAAqD;AACrD,+GAA0G;AAC1G,qEAAiE;
|
|
1
|
+
{"version":3,"file":"bug-unique-cards.js","sourceRoot":"","sources":["../../../../../src/lib/bug-workarounds/bug-unique-cards/bug-unique-cards.ts"],"names":[],"mappings":";;;AAAA,kDAA6E;AAE7E,yDAAqD;AACrD,+GAA0G;AAC1G,qEAAiE;AACjE,qCAAkC;AAElC;;;GAGG;AACH,MAAa,cAAc;IAA3B;QACqB,cAAS,GAAG,IAAI,oBAAQ,EAAE,CAAC;QAE3B,uBAAkB,GAKvB,CAAC,IAAU,EAAQ,EAAE;YAC7B,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE;gBAClB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YAC5B,CAAC,CAAC,CAAC;QACP,CAAC,CAAC;IAuCN,CAAC;IArCG,IAAI;QACA,MAAM,aAAa,GAAG,KAAK,CAAC;QAC5B,KAAK,MAAM,GAAG,IAAI,WAAK,CAAC,aAAa,CAAC,aAAa,CAAC,EAAE,CAAC;YACnD,IAAI,GAAG,YAAY,UAAI,EAAE,CAAC;gBACtB,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;YAChD,CAAC;QACL,CAAC;QACD,kBAAY,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;YACrC,IAAI,GAAG,YAAY,UAAI,EAAE,CAAC;gBACtB,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;YAChD,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAED,YAAY,CAAC,IAAU;QACnB,MAAM,IAAI,GAAgB,IAAI,GAAG,EAAU,CAAC;QAC5C,MAAM,OAAO,GAAqB,IAAI,CAAC,SAAS,CAAC,WAAW,CACxD,IAAI,EACJ,CAAC,IAAY,EAAW,EAAE;YACtB,yBAAyB;YACzB,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBACpC,OAAO,IAAI,CAAC;YAChB,CAAC;YACD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACf,OAAO,KAAK,CAAC;QACjB,CAAC,CACJ,CAAC;QACF,IAAI,OAAO,EAAE,CAAC;YACV,MAAM,WAAW,GAAW,OAAO,CAAC,YAAY,EAAE,CAAC;YACnD,MAAM,WAAW,GAAkB,WAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YACzD,MAAM,YAAY,GAAW,IAAI,CAAC,YAAY,EAAE,CAAC;YACjD,+CAAqB,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC;YACrD,MAAM,GAAG,GAAW,2BAA2B,WAAW,gBAAgB,YAAY,wBAAwB,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC;YACjI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACjB,4BAAY,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACtC,CAAC;IACL,CAAC;CACJ;AAnDD,wCAmDC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Create game objects using given source colors, screenshot then use the
|
|
5
|
+
* lib-ext extract tool to read color values.
|
|
6
|
+
*/
|
|
7
|
+
const api_1 = require("@tabletop-playground/api");
|
|
8
|
+
const shuffle_1 = require("../shuffle/shuffle");
|
|
9
|
+
// Clear the world before (re)creating objects.
|
|
10
|
+
for (const obj of api_1.world.getAllObjects()) {
|
|
11
|
+
if (obj !== api_1.refObject) {
|
|
12
|
+
obj.destroy();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const templateId = "83FDE12C4E6D912B16B85E9A00422F43"; // cube
|
|
16
|
+
const cube = api_1.world.createObjectFromTemplate(
|
|
17
|
+
templateId,
|
|
18
|
+
new api_1.Vector(0, 0, api_1.world.getTableHeight() + 4)
|
|
19
|
+
);
|
|
20
|
+
if (!cube) {
|
|
21
|
+
throw new Error("Failed to create object");
|
|
22
|
+
}
|
|
23
|
+
cube.setRoughness(1);
|
|
24
|
+
cube.setMetallic(0);
|
|
25
|
+
cube.snapToGround();
|
|
26
|
+
const border = new api_1.Border();
|
|
27
|
+
const ui = new api_1.UIElement();
|
|
28
|
+
ui.position = new api_1.Vector(-4, 0, 2);
|
|
29
|
+
ui.widget = border.setChild(
|
|
30
|
+
new api_1.LayoutBox().setOverrideWidth(25).setOverrideHeight(25)
|
|
31
|
+
);
|
|
32
|
+
cube.addUI(ui);
|
|
33
|
+
// Look straight down at result.
|
|
34
|
+
const player = api_1.world.getAllPlayers()[0];
|
|
35
|
+
if (player) {
|
|
36
|
+
console.log(player.getPosition());
|
|
37
|
+
console.log(player.getRotation());
|
|
38
|
+
const z = api_1.world.getTableHeight() + 40;
|
|
39
|
+
player.setPositionAndRotation([-10, -25, z], [-90, 0, 0]);
|
|
40
|
+
}
|
|
41
|
+
const n = 16;
|
|
42
|
+
let colors = [];
|
|
43
|
+
for (let r = 0; r < n; r++) {
|
|
44
|
+
for (let g = 0; g < n; g++) {
|
|
45
|
+
for (let b = 0; b < n; b++) {
|
|
46
|
+
const color = new api_1.Color(
|
|
47
|
+
r / (n - 1),
|
|
48
|
+
g / (n - 1),
|
|
49
|
+
b / (n - 1)
|
|
50
|
+
);
|
|
51
|
+
colors.push(color);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
colors = new shuffle_1.Shuffle().shuffle(colors);
|
|
56
|
+
console.log("|colors|:", colors.length);
|
|
57
|
+
function setToNextColor() {
|
|
58
|
+
const color = colors.shift();
|
|
59
|
+
if (color) {
|
|
60
|
+
console.log(color.toHex(), colors.length);
|
|
61
|
+
api_1.world.setSlotColor(0, color);
|
|
62
|
+
cube === null || cube === void 0 ? void 0 : cube.setPrimaryColor(color);
|
|
63
|
+
border.setColor(color);
|
|
64
|
+
}
|
|
65
|
+
return color !== undefined;
|
|
66
|
+
}
|
|
67
|
+
const handle = setInterval(() => {
|
|
68
|
+
if (!setToNextColor()) {
|
|
69
|
+
clearInterval(handle);
|
|
70
|
+
}
|
|
71
|
+
}, 3000);
|
|
72
|
+
//# sourceMappingURL=color-mapping-rotating.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color-mapping-rotating.js","sourceRoot":"","sources":["../../../../src/lib/color-lib/color-mapping-rotating.ts"],"names":[],"mappings":";;AAAA;;;GAGG;AACH,kDAUkC;AAClC,gDAA6C;AAE7C,+CAA+C;AAC/C,KAAK,MAAM,GAAG,IAAI,WAAK,CAAC,aAAa,EAAE,EAAE,CAAC;IACtC,IAAI,GAAG,KAAK,eAAS,EAAE,CAAC;QACpB,GAAG,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;AACL,CAAC;AAED,MAAM,UAAU,GAAW,kCAAkC,CAAC,CAAC,OAAO;AACtE,MAAM,IAAI,GAA2B,WAAK,CAAC,wBAAwB,CAC/D,UAAU,EACV,IAAI,YAAM,CAAC,CAAC,EAAE,CAAC,EAAE,WAAK,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC,CAC/C,CAAC;AACF,IAAI,CAAC,IAAI,EAAE,CAAC;IACR,MAAM,IAAI,KAAK,CAAC,yBAAy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-0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const api_1 = require("@tabletop-playground/api");
|
|
4
|
+
const dice_group_1 = require("./dice-group");
|
|
5
|
+
api_1.world.setShowDiceRollMessages(false);
|
|
6
|
+
new dice_group_1.DiceGroupCleanup().init();
|
|
7
|
+
const player = api_1.world.getAllPlayers()[0];
|
|
8
|
+
if (!player) {
|
|
9
|
+
throw new Error("no player");
|
|
10
|
+
}
|
|
11
|
+
dice_group_1.DiceGroup.roll({
|
|
12
|
+
diceParams: [
|
|
13
|
+
{ sides: 10 },
|
|
14
|
+
{
|
|
15
|
+
id: "will-reroll",
|
|
16
|
+
name: "Rerolled",
|
|
17
|
+
sides: 10,
|
|
18
|
+
primaryColor: [1, 0, 0, 1],
|
|
19
|
+
secondaryColor: [1, 1, 0, 1],
|
|
20
|
+
hit: 11, // cannot hit, will reroll
|
|
21
|
+
reroll: true,
|
|
22
|
+
},
|
|
23
|
+
{ sides: 4 },
|
|
24
|
+
{ sides: 6 },
|
|
25
|
+
{ sides: 8 },
|
|
26
|
+
{ sides: 12 },
|
|
27
|
+
{ sides: 20 },
|
|
28
|
+
],
|
|
29
|
+
player,
|
|
30
|
+
position: api_1.refObject.getPosition().add([0, 4, 0]),
|
|
31
|
+
timeoutSeconds: -1, // no timeout
|
|
32
|
+
deleteAfterSeconds: -1, // no delete
|
|
33
|
+
callback: (diceResults) => {
|
|
34
|
+
console.log(diceResults
|
|
35
|
+
.map((diceResult) => dice_group_1.DiceGroup.format(diceResult))
|
|
36
|
+
.join(", "));
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=dice-group-testp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dice-group-testp.js","sourceRoot":"","sources":["../../../../src/lib/dice-group/dice-group-testp.ts"],"names":[],"mappings":";;AAAA,kDAAoE;AACpE,6CAAuE;AAEvE,WA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AC;IACN,CAAC;CACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const api_1 = require("@tabletop-playground/api");
|
|
4
|
+
const cardholder_player_name_1 = require("./cardholder-player-name");
|
|
5
|
+
// Wait a frame to:
|
|
6
|
+
// (1) let creator finish setting up if a new object,
|
|
7
|
+
// (2) let player data become valid if (re)loading.
|
|
8
|
+
const obj = api_1.refHolder; // ref* gets cleared end of frame
|
|
9
|
+
process.nextTick(() => {
|
|
10
|
+
new cardholder_player_name_1.CardHolderPlayerName(obj);
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=cardholder-player-name-obj.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cardholder-player-name-obj.js","sourceRoot":"","sources":["../../../../../src/lib/game-object/cardholder-player-name/cardholder-player-name-obj.ts"],"names":[],"mappings":";;AAAA,kDAAqD;AACrD,qEAAgE;AAEhE,mBAAmB;AACnB,qDAAqD;AACrD,mDAAmD;AACnD,MAAM,GAAG,GAAG,eAAS,CAAC,CAAC,iCAAiC;AACxD,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE;IAClB,IAAI,6CAAoB,CAAC,GAAG,CAAC,CAAC;AAClC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const api_1 = require("@tabletop-playground/api");
|
|
4
|
+
const deleted_items_container_1 = require("./deleted-items-container");
|
|
5
|
+
console.log("creating DeletedItemsContainer");
|
|
6
|
+
new deleted_items_container_1.DeletedItemsContainer(api_1.refContainer);
|
|
7
|
+
//# sourceMappingURL=deleted-items-container-obj.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deleted-items-container-obj.js","sourceRoot":"","sources":["../../../../../src/lib/game-object/deleted-items-container/deleted-items-container-obj.ts"],"names":[],"mappings":";;AAAA,kDAAwD;AACxD,uEAAkE;AAElE,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;AAC9C,IAAI,+CAAqB,CAAC,kBAAY,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const api_1 = require("@tabletop-playground/api");
|
|
4
|
+
const garbage_container_1 = require("./garbage-container");
|
|
5
|
+
new garbage_container_1.GarbageContainer(api_1.refContainer);
|
|
6
|
+
//# sourceMappingURL=garbage-container-obj.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"garbage-container-obj.js","sourceRoot":"","sources":["../../../../../src/lib/game-object/garbage/garbage-container-obj.ts"],"names":[],"mappings":";;AAAA,kDAAwD;AACxD,2DAAuD;AAEvD,IAAI,oCAAgB,CAAC,kBAAY,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Color } from "@tabletop-playground/api";
|
|
2
|
+
export declare const HEX_COLOR_REGEX: RegExp;
|
|
3
|
+
export declare class ParseColor {
|
|
4
|
+
private readonly _hexColorRegex;
|
|
5
|
+
parseColor(hexColor: string): Color | undefined;
|
|
6
|
+
parseColorOrThrow(hexColor: string): Color;
|
|
7
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ParseColor = exports.HEX_COLOR_REGEX = void 0;
|
|
4
|
+
const api_1 = require("@tabletop-playground/api");
|
|
5
|
+
exports.HEX_COLOR_REGEX = /^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
|
|
6
|
+
class ParseColor {
|
|
7
|
+
constructor() {
|
|
8
|
+
this._hexColorRegex = new RegExp(exports.HEX_COLOR_REGEX);
|
|
9
|
+
}
|
|
10
|
+
parseColor(hexColor) {
|
|
11
|
+
var _a;
|
|
12
|
+
const m = hexColor.match(this._hexColorRegex);
|
|
13
|
+
const hexStr =
|
|
14
|
+
(_a = m === null || m === void 0 ? void 0 : m[1]) !== null &&
|
|
15
|
+
_a !== void 0
|
|
16
|
+
? _a
|
|
17
|
+
: "";
|
|
18
|
+
if (!m) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
if (hexStr.length !== 3 && hexStr.length !== 6 && hexStr.length !== 8) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
let r = 0;
|
|
25
|
+
let g = 0;
|
|
26
|
+
let b = 0;
|
|
27
|
+
let a = 1;
|
|
28
|
+
if (hexStr.length === 3) {
|
|
29
|
+
r = Number.parseInt(hexStr.substring(0, 1), 16) / 15;
|
|
30
|
+
g = Number.parseInt(hexStr.substring(1, 2), 16) / 15;
|
|
31
|
+
b = Number.parseInt(hexStr.substring(2, 3), 16) / 15;
|
|
32
|
+
} else {
|
|
33
|
+
r = Number.parseInt(hexStr.substring(0, 2), 16) / 255;
|
|
34
|
+
g = Number.parseInt(hexStr.substring(2, 4), 16) / 255;
|
|
35
|
+
b = Number.parseInt(hexStr.substring(4, 6), 16) / 255;
|
|
36
|
+
}
|
|
37
|
+
if (hexStr.length === 8) {
|
|
38
|
+
a = Number.parseInt(hexStr.substring(6, 8), 16) / 255;
|
|
39
|
+
}
|
|
40
|
+
return new api_1.Color(r, g, b, a);
|
|
41
|
+
}
|
|
42
|
+
parseColorOrThrow(hexColor) {
|
|
43
|
+
const color = this.parseColor(hexColor);
|
|
44
|
+
if (!color) {
|
|
45
|
+
throw new Error(`bad hexColor "${hexColor}"`);
|
|
46
|
+
}
|
|
47
|
+
return color;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.ParseColor = ParseColor;
|
|
51
|
+
//# sourceMappingURL=parse-color.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-color.js","sourceRoot":"","sources":["../../../../../src/lib/parse/parse-color/parse-color.ts"],"names":[],"mappings":";;;AAAA,kDAAiD;AAEpC,QAAA,eAAe,GAAG,2CAA2C,CAAC;AAE3E,MAAa,UAAU;IAAvB;QACqB,mBAAc,GAAW,IAAI,MAAM,CAAC,uBAAe,CAAC,CAAC;IAsC1E,CAAC;IApCG,UAAU,CAAC,QAAgB;;QACvB,MAAM,CAAC,GAA4B,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACvE,MAAM,MAAM,GAAW,MAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAG,CAAC,CAAC,mCAAI,EAAE,CAAC;QACpC,IAAI,CAAC,CAAC,EAAE,CAAC;YACL,OAAO,SAAS,CAAC;QACrB,CAAC;QACD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACpE,OAAO,SAAS,CAAC;QACrB,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,CAAC;QACV,IAAI,CAAC,GAAG,CAAC,CAAC;QACV,IAAI,CAAC,GAAG,CAAC,CAAC;QACV,IAAI,CAAC,GAAG,CAAC,CAAC;QACV,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACtB,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC;YACrD,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,CAA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__awaiter) ||
|
|
4
|
+
function (thisArg, _arguments, P, generator) {
|
|
5
|
+
function adopt(value) {
|
|
6
|
+
return value instanceof P
|
|
7
|
+
? value
|
|
8
|
+
: new P(function (resolve) {
|
|
9
|
+
resolve(value);
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
13
|
+
function fulfilled(value) {
|
|
14
|
+
try {
|
|
15
|
+
step(generator.next(value));
|
|
16
|
+
} catch (e) {
|
|
17
|
+
reject(e);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function rejected(value) {
|
|
21
|
+
try {
|
|
22
|
+
step(generator["throw"](value));
|
|
23
|
+
} catch (e) {
|
|
24
|
+
reject(e);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function step(result) {
|
|
28
|
+
result.done
|
|
29
|
+
? resolve(result.value)
|
|
30
|
+
: adopt(result.value).then(fulfilled, rejected);
|
|
31
|
+
}
|
|
32
|
+
step(
|
|
33
|
+
(generator = generator.apply(thisArg, _arguments || [])).next()
|
|
34
|
+
);
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
var __importDefault =
|
|
38
|
+
(this && this.__importDefault) ||
|
|
39
|
+
function (mod) {
|
|
40
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
41
|
+
};
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
/**
|
|
44
|
+
* Given a screenshot and start/end coordinates extract the color values.
|
|
45
|
+
*/
|
|
46
|
+
const fs_1 = __importDefault(require("fs"));
|
|
47
|
+
const sharp_1 = __importDefault(require("sharp"));
|
|
48
|
+
function extractColors(filename, startX, startY, endX, endY, n) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
const result = [];
|
|
51
|
+
const image = (0, sharp_1.default)(filename);
|
|
52
|
+
const metadata = yield image.metadata();
|
|
53
|
+
const w = metadata.width;
|
|
54
|
+
const h = metadata.height;
|
|
55
|
+
if (!w || !h) {
|
|
56
|
+
throw new Error("bad metadata");
|
|
57
|
+
}
|
|
58
|
+
const raw = yield image.raw().toBuffer();
|
|
59
|
+
const pixelArray = new Uint8ClampedArray(raw); // [r, g, b, a] repeated
|
|
60
|
+
if (pixelArray.length !== w * h * 4) {
|
|
61
|
+
throw new Error("bad pixel array");
|
|
62
|
+
}
|
|
63
|
+
const getPx = (x, y) => {
|
|
64
|
+
const i = (y * w + x) * 4;
|
|
65
|
+
const pixel = pixelArray.slice(i, i + 4);
|
|
66
|
+
const s = 10000;
|
|
67
|
+
const r = Math.floor((pixel[0] * s) / 255) / s;
|
|
68
|
+
const g = Math.floor((pixel[1] * s) / 255) / s;
|
|
69
|
+
const b = Math.floor((pixel[2] * s) / 255) / s;
|
|
70
|
+
return [r, g, b];
|
|
71
|
+
};
|
|
72
|
+
const dx = (endX - startX) / (n - 1);
|
|
73
|
+
const dy = (endY - startY) / (n - 1);
|
|
74
|
+
for (let i = 0; i < n; i++) {
|
|
75
|
+
const x = Math.round(startX + i * dx);
|
|
76
|
+
const y = Math.round(startY + i * dy);
|
|
77
|
+
const rgb = getPx(x, y);
|
|
78
|
+
result.push(rgb);
|
|
79
|
+
}
|
|
80
|
+
return result;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
function processScreenshot() {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
const filename =
|
|
86
|
+
"/Users/darrell/Desktop/Screenshot 2024-08-16 at 10.34.21 AM.png";
|
|
87
|
+
if (!fs_1.default.existsSync(filename)) {
|
|
88
|
+
throw new Error(`file not found "${filename}"`);
|
|
89
|
+
}
|
|
90
|
+
// Plastic.
|
|
91
|
+
{
|
|
92
|
+
const startX = 50;
|
|
93
|
+
const startY = 44;
|
|
94
|
+
const endX = 4904;
|
|
95
|
+
const endY = 43;
|
|
96
|
+
const n = 40;
|
|
97
|
+
const colors = yield extractColors(
|
|
98
|
+
filename,
|
|
99
|
+
startX,
|
|
100
|
+
startY,
|
|
101
|
+
endX,
|
|
102
|
+
endY,
|
|
103
|
+
n
|
|
104
|
+
);
|
|
105
|
+
console.log(colors);
|
|
106
|
+
}
|
|
107
|
+
// Widget.
|
|
108
|
+
{
|
|
109
|
+
const startX = 55;
|
|
110
|
+
const startY = 107;
|
|
111
|
+
const endX = 4898;
|
|
112
|
+
const endY = 107;
|
|
113
|
+
const n = 40;
|
|
114
|
+
const colors = yield extractColors(
|
|
115
|
+
filename,
|
|
116
|
+
startX,
|
|
117
|
+
startY,
|
|
118
|
+
endX,
|
|
119
|
+
endY,
|
|
120
|
+
n
|
|
121
|
+
);
|
|
122
|
+
console.log(colors);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
processScreenshot();
|
|
127
|
+
//# sourceMappingURL=color-extract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color-extract.js","sourceRoot":"","sources":["../../../../src/lib-ext/color-mapping/color-extract.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;;GAEG;AACH,4CAAoB;AACpB,kDAAwC;AAIxC,SAAe,aAAa,CACxB,QAAgB,EAChB,MAAc,EACd,MAAc,EACd,IAAY,EACZ,IAAY,EACZ,CAAS;;QAET,MAAM,MAAM,GAAe,EAAE,CAAC;QAC9B,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,QAAQ,CAAC,CAAC;QAC9B,MAAM,QAAQ,GAAa,MAAM,KAAK,CAAC,QAAQ,EAAE,CAAC;QAClD,MAAM,CAAC,GAAuB,QAAQ,CAAC,KAAK,CAAC;QAC7C,MAAM,CAAC,GAAuB,QAAQ,CAAC,MAAM,CAAC;QAC9C,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC;QACpC,CAAC;QAED,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,CAAC,QAAQ,EAA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ACN,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,CAAC,CACJ,CAAC;YAEF,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACxB,CAAC;IACL,CAAC;CAAA;AAED,iBAAiB,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding =
|
|
3
|
+
(this && this.__createBinding) ||
|
|
4
|
+
(Object.create
|
|
5
|
+
? function (o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (
|
|
9
|
+
!desc ||
|
|
10
|
+
("get" in desc
|
|
11
|
+
? !m.__esModule
|
|
12
|
+
: desc.writable || desc.configurable)
|
|
13
|
+
) {
|
|
14
|
+
desc = {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () {
|
|
17
|
+
return m[k];
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
Object.defineProperty(o, k2, desc);
|
|
22
|
+
}
|
|
23
|
+
: function (o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
o[k2] = m[k];
|
|
26
|
+
});
|
|
27
|
+
var __setModuleDefault =
|
|
28
|
+
(this && this.__setModuleDefault) ||
|
|
29
|
+
(Object.create
|
|
30
|
+
? function (o, v) {
|
|
31
|
+
Object.defineProperty(o, "default", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
value: v,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
: function (o, v) {
|
|
37
|
+
o["default"] = v;
|
|
38
|
+
});
|
|
39
|
+
var __importStar =
|
|
40
|
+
(this && this.__importStar) ||
|
|
41
|
+
function (mod) {
|
|
42
|
+
if (mod && mod.__esModule) return mod;
|
|
43
|
+
var result = {};
|
|
44
|
+
if (mod != null)
|
|
45
|
+
for (var k in mod)
|
|
46
|
+
if (
|
|
47
|
+
k !== "default" &&
|
|
48
|
+
Object.prototype.hasOwnProperty.call(mod, k)
|
|
49
|
+
)
|
|
50
|
+
__createBinding(result, mod, k);
|
|
51
|
+
__setModuleDefault(result, mod);
|
|
52
|
+
return result;
|
|
53
|
+
};
|
|
54
|
+
var __awaiter =
|
|
55
|
+
(this && this.__awaiter) ||
|
|
56
|
+
function (thisArg, _arguments, P, generator) {
|
|
57
|
+
function adopt(value) {
|
|
58
|
+
return value instanceof P
|
|
59
|
+
? value
|
|
60
|
+
: new P(function (resolve) {
|
|
61
|
+
resolve(value);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
65
|
+
function fulfilled(value) {
|
|
66
|
+
try {
|
|
67
|
+
step(generator.next(value));
|
|
68
|
+
} catch (e) {
|
|
69
|
+
reject(e);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function rejected(value) {
|
|
73
|
+
try {
|
|
74
|
+
step(generator["throw"](value));
|
|
75
|
+
} catch (e) {
|
|
76
|
+
reject(e);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function step(result) {
|
|
80
|
+
result.done
|
|
81
|
+
? resolve(result.value)
|
|
82
|
+
: adopt(result.value).then(fulfilled, rejected);
|
|
83
|
+
}
|
|
84
|
+
step(
|
|
85
|
+
(generator = generator.apply(thisArg, _arguments || [])).next()
|
|
86
|
+
);
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
90
|
+
const color_mapping_data_1 = require("./color-mapping.data");
|
|
91
|
+
const scikitjs_1 = require("scikitjs");
|
|
92
|
+
const tensorflow = __importStar(require("@tensorflow/tfjs"));
|
|
93
|
+
(0, scikitjs_1.setBackend)(tensorflow);
|
|
94
|
+
function centerRGBs(colors) {
|
|
95
|
+
colors.forEach((rgb) => {
|
|
96
|
+
rgb[0] = rgb[0] - 0.5;
|
|
97
|
+
rgb[1] = rgb[1] - 0.5;
|
|
98
|
+
rgb[2] = rgb[2] - 0.5;
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
centerRGBs(color_mapping_data_1.PLASTIC_COLORS);
|
|
102
|
+
centerRGBs(color_mapping_data_1.WIDGET_COLORS);
|
|
103
|
+
centerRGBs(color_mapping_data_1.RAW_COLORS);
|
|
104
|
+
centerRGBs(color_mapping_data_1.PLASTIC_COLORS_SPECTRUM);
|
|
105
|
+
centerRGBs(color_mapping_data_1.WIDGET_COLORS_SPECTRUM);
|
|
106
|
+
centerRGBs(color_mapping_data_1.RAW_COLORS_SPECTRUM);
|
|
107
|
+
// Because we are using squares, center values around [-0.5:0.5]
|
|
108
|
+
const raw = {
|
|
109
|
+
R: color_mapping_data_1.RAW_COLORS.map(([r, _g, _b]) => r),
|
|
110
|
+
G: color_mapping_data_1.RAW_COLORS.map(([_r, g, _b]) => g),
|
|
111
|
+
B: color_mapping_data_1.RAW_COLORS.map(([_r, _g, b]) => b),
|
|
112
|
+
RS: color_mapping_data_1.RAW_COLORS_SPECTRUM.map(([r, _g, _b]) => r),
|
|
113
|
+
GS: color_mapping_data_1.RAW_COLORS_SPECTRUM.map(([_r, g, _b]) => g),
|
|
114
|
+
BS: color_mapping_data_1.RAW_COLORS_SPECTRUM.map(([_r, _g, b]) => b),
|
|
115
|
+
};
|
|
116
|
+
function processOne(channel, raw) {
|
|
117
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
118
|
+
let best;
|
|
119
|
+
let bestScore = 0;
|
|
120
|
+
for (let i = 0; i < 20; i++) {
|
|
121
|
+
const model = yield new scikitjs_1.LinearRegression({
|
|
122
|
+
fitIntercept: true,
|
|
123
|
+
}).fit(raw, channel);
|
|
124
|
+
const score = model.score(raw, channel);
|
|
125
|
+
if (score > bestScore) {
|
|
126
|
+
const coefs = model.coef.arraySync().flat();
|
|
127
|
+
best = {
|
|
128
|
+
intercept: model.intercept,
|
|
129
|
+
coefs,
|
|
130
|
+
score,
|
|
131
|
+
};
|
|
132
|
+
const scrub = (x) => Math.round(x * 10000) / 10000;
|
|
133
|
+
best.intercept = scrub(best.intercept);
|
|
134
|
+
best.coefs = best.coefs.map(scrub);
|
|
135
|
+
best.score = scrub(best.score);
|
|
136
|
+
bestScore = score;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return best;
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
function processOneSq(channel, raw) {
|
|
143
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
144
|
+
raw = raw.map((entry) => {
|
|
145
|
+
const result = [...entry];
|
|
146
|
+
for (const value of entry) {
|
|
147
|
+
result.push(value * value);
|
|
148
|
+
}
|
|
149
|
+
return result;
|
|
150
|
+
});
|
|
151
|
+
return yield processOne(channel, raw);
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
function processAll() {
|
|
155
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
156
|
+
let result;
|
|
157
|
+
console.log("----------------------------------------");
|
|
158
|
+
result = {
|
|
159
|
+
r: yield processOne(raw.R, color_mapping_data_1.PLASTIC_COLORS),
|
|
160
|
+
g: yield processOne(raw.G, color_mapping_data_1.PLASTIC_COLORS),
|
|
161
|
+
b: yield processOne(raw.B, color_mapping_data_1.PLASTIC_COLORS),
|
|
162
|
+
score: 0,
|
|
163
|
+
};
|
|
164
|
+
result.score = (result.r.score + result.g.score + result.b.score) / 3;
|
|
165
|
+
console.log("plastic", JSON.stringify(result));
|
|
166
|
+
result = {
|
|
167
|
+
r: yield processOne(raw.R, color_mapping_data_1.WIDGET_COLORS),
|
|
168
|
+
g: yield processOne(raw.G, color_mapping_data_1.WIDGET_COLORS),
|
|
169
|
+
b: yield processOne(raw.B, color_mapping_data_1.WIDGET_COLORS),
|
|
170
|
+
score: 0,
|
|
171
|
+
};
|
|
172
|
+
result.score = (result.r.score + result.g.score + result.b.score) / 3;
|
|
173
|
+
console.log("widget", JSON.stringify(result));
|
|
174
|
+
console.log("----------------------------------------");
|
|
175
|
+
result = {
|
|
176
|
+
r: yield processOneSq(raw.R, color_mapping_data_1.PLASTIC_COLORS),
|
|
177
|
+
g: yield processOneSq(raw.G, color_mapping_data_1.PLASTIC_COLORS),
|
|
178
|
+
b: yield processOneSq(raw.B, color_mapping_data_1.PLASTIC_COLORS),
|
|
179
|
+
score: 0,
|
|
180
|
+
};
|
|
181
|
+
result.score = (result.r.score + result.g.score + result.b.score) / 3;
|
|
182
|
+
console.log("plasticSq", JSON.stringify(result));
|
|
183
|
+
result = {
|
|
184
|
+
r: yield processOneSq(raw.R, color_mapping_data_1.WIDGET_COLORS),
|
|
185
|
+
g: yield processOneSq(raw.G, color_mapping_data_1.WIDGET_COLORS),
|
|
186
|
+
b: yield processOneSq(raw.B, color_mapping_data_1.WIDGET_COLORS),
|
|
187
|
+
score: 0,
|
|
188
|
+
};
|
|
189
|
+
result.score = (result.r.score + result.g.score + result.b.score) / 3;
|
|
190
|
+
console.log("widgetSq", JSON.stringify(result));
|
|
191
|
+
console.log("----------------------------------------");
|
|
192
|
+
result = {
|
|
193
|
+
r: yield processOneSq(
|
|
194
|
+
raw.RS,
|
|
195
|
+
color_mapping_data_1.PLASTIC_COLORS_SPECTRUM
|
|
196
|
+
),
|
|
197
|
+
g: yield processOneSq(
|
|
198
|
+
raw.GS,
|
|
199
|
+
color_mapping_data_1.PLASTIC_COLORS_SPECTRUM
|
|
200
|
+
),
|
|
201
|
+
b: yield processOneSq(
|
|
202
|
+
raw.BS,
|
|
203
|
+
color_mapping_data_1.PLASTIC_COLORS_SPECTRUM
|
|
204
|
+
),
|
|
205
|
+
score: 0,
|
|
206
|
+
};
|
|
207
|
+
result.score = (result.r.score + result.g.score + result.b.score) / 3;
|
|
208
|
+
console.log("plasticSqSpectrum", JSON.stringify(result));
|
|
209
|
+
result = {
|
|
210
|
+
r: yield processOneSq(
|
|
211
|
+
raw.RS,
|
|
212
|
+
color_mapping_data_1.WIDGET_COLORS_SPECTRUM
|
|
213
|
+
),
|
|
214
|
+
g: yield processOneSq(
|
|
215
|
+
raw.GS,
|
|
216
|
+
color_mapping_data_1.WIDGET_COLORS_SPECTRUM
|
|
217
|
+
),
|
|
218
|
+
b: yield processOneSq(
|
|
219
|
+
raw.BS,
|
|
220
|
+
color_mapping_data_1.WIDGET_COLORS_SPECTRUM
|
|
221
|
+
),
|
|
222
|
+
score: 0,
|
|
223
|
+
};
|
|
224
|
+
result.score = (result.r.score + result.g.score + result.b.score) / 3;
|
|
225
|
+
console.log("widgetSqSpectrun", JSON.stringify(result));
|
|
226
|
+
console.log("----------------------------------------");
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
processAll();
|
|
230
|
+
//# sourceMappingURL=color-mapping-linear-centered.js.map
|