Skip to content

Commit 0bbe385

Browse files
committed
banonly and banonly shaded view added
1 parent 31c8914 commit 0bbe385

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

src/index.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,20 @@ for (const { cookie, id, installation, overrideConfig, post } of FIELDS) {
2323
const totalSize = config.challengeConfig.size;
2424
const partitionSize = config.challengeConfig.partitionSize;
2525

26-
const canvas = await renderPartition(totalSize, partitionSize, subreddit, challenge, sequence, name);
26+
const canvas = await renderPartition(totalSize, partitionSize, subreddit, challenge, sequence, name,false,false);
2727

2828
const writeStream = createWriteStream(`${OUTPUT_DIR}/${id}.png`);
2929
canvas.createPNGStream().pipe(writeStream);
30+
31+
const bancanvas = await renderPartition(totalSize, partitionSize, subreddit, challenge, sequence, name,true,false);
32+
33+
const banWriteStream = createWriteStream(`${OUTPUT_DIR}/${id}_b.png`);
34+
bancanvas.createPNGStream().pipe(banWriteStream);
35+
36+
const shadecanvas = await renderPartition(totalSize, partitionSize, subreddit, challenge, sequence, name,true,true);
37+
38+
const shadeWriteStream = createWriteStream(`${OUTPUT_DIR}/${id}_s.png`);
39+
shadecanvas.createPNGStream().pipe(shadeWriteStream);
3040
} catch (error) {
3141
log("failed to capture screenshot for %s", installation, error);
3242
}

src/render.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { decodePartition } from "./utils/decode.js";
55
import { fetchPartition } from "./partition.js";
66
import { getCellColor } from "./utils/color.js";
77

8-
export async function renderPartition(totalSize, partitionSize, subreddit, challenge, sequence, name) {
8+
export async function renderPartition(totalSize, partitionSize, subreddit, challenge, sequence, name, banOnly, shade) {
99
log("capturing screenshot for %s", name);
1010

1111
const partitionCount = Math.floor(totalSize / partitionSize);
@@ -28,7 +28,7 @@ export async function renderPartition(totalSize, partitionSize, subreddit, chall
2828
let index = 0;
2929

3030
for (const cell of cells) {
31-
const color = getCellColor(cell);
31+
const color = getCellColor(cell, banOnly, shade);
3232

3333
imageData.data[index * 4] = (color >> 16) & 0xFF;
3434
imageData.data[index * 4 + 1] = (color >> 8) & 0xFF;

src/utils/color.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,25 @@ const TEAM_COLORS = [
99

1010
const BAN_COLOR = 0x7DFF00;
1111
const UNCLAIMED_COLOR = 0x000000;
12-
12+
const CLAIMED_SHADE = 0x202020;
1313
/**
1414
* Gets an RGB color representing a given cell.
1515
* @param {import("./decode").Cell | null} cell the cell to get the color for
1616
* @returns {number} the color
1717
*/
18-
export function getCellColor(cell) {
18+
export function getCellColor(cell,banOnly,shade) {
1919
if (cell?.ban) {
2020
return BAN_COLOR;
2121
} else if (cell?.team !== undefined) {
22-
return TEAM_COLORS[cell.team];
22+
if(banOnly) {
23+
if(shade) {
24+
return CLAIMED_SHADE;
25+
}
26+
else return UNCLAIMED_COLOR;
27+
}
28+
else {
29+
return TEAM_COLORS[cell.team];
30+
}
2331
}
2432

2533
return UNCLAIMED_COLOR;

0 commit comments

Comments
 (0)