diff --git a/src/index.js b/src/index.js index 1c96b6f..c14ac50 100644 --- a/src/index.js +++ b/src/index.js @@ -23,10 +23,20 @@ for (const { cookie, id, installation, overrideConfig, post } of FIELDS) { const totalSize = config.challengeConfig.size; const partitionSize = config.challengeConfig.partitionSize; - const canvas = await renderPartition(totalSize, partitionSize, subreddit, challenge, sequence, name); + const canvas = await renderPartition(totalSize, partitionSize, subreddit, challenge, sequence, name,false,false); const writeStream = createWriteStream(`${OUTPUT_DIR}/${id}.png`); canvas.createPNGStream().pipe(writeStream); + + const bancanvas = await renderPartition(totalSize, partitionSize, subreddit, challenge, sequence, name,true,false); + + const banWriteStream = createWriteStream(`${OUTPUT_DIR}/${id}_b.png`); + bancanvas.createPNGStream().pipe(banWriteStream); + + const shadecanvas = await renderPartition(totalSize, partitionSize, subreddit, challenge, sequence, name,true,true); + + const shadeWriteStream = createWriteStream(`${OUTPUT_DIR}/${id}_s.png`); + shadecanvas.createPNGStream().pipe(shadeWriteStream); } catch (error) { log("failed to capture screenshot for %s", installation, error); } diff --git a/src/render.js b/src/render.js index 3425b76..70c6726 100644 --- a/src/render.js +++ b/src/render.js @@ -5,7 +5,7 @@ import { decodePartition } from "./utils/decode.js"; import { fetchPartition } from "./partition.js"; import { getCellColor } from "./utils/color.js"; -export async function renderPartition(totalSize, partitionSize, subreddit, challenge, sequence, name) { +export async function renderPartition(totalSize, partitionSize, subreddit, challenge, sequence, name, banOnly, shade) { log("capturing screenshot for %s", name); const partitionCount = Math.floor(totalSize / partitionSize); @@ -28,7 +28,7 @@ export async function renderPartition(totalSize, partitionSize, subreddit, chall let index = 0; for (const cell of cells) { - const color = getCellColor(cell); + const color = getCellColor(cell, banOnly, shade); imageData.data[index * 4] = (color >> 16) & 0xFF; imageData.data[index * 4 + 1] = (color >> 8) & 0xFF; diff --git a/src/utils/color.js b/src/utils/color.js index df0be26..ae8c4a9 100644 --- a/src/utils/color.js +++ b/src/utils/color.js @@ -9,17 +9,25 @@ const TEAM_COLORS = [ const BAN_COLOR = 0x7DFF00; const UNCLAIMED_COLOR = 0x000000; - +const CLAIMED_SHADE = 0x202020; /** * Gets an RGB color representing a given cell. * @param {import("./decode").Cell | null} cell the cell to get the color for * @returns {number} the color */ -export function getCellColor(cell) { +export function getCellColor(cell,banOnly,shade) { if (cell?.ban) { return BAN_COLOR; } else if (cell?.team !== undefined) { - return TEAM_COLORS[cell.team]; + if(banOnly) { + if(shade) { + return CLAIMED_SHADE; + } + else return UNCLAIMED_COLOR; + } + else { + return TEAM_COLORS[cell.team]; + } } return UNCLAIMED_COLOR;