From e01ecadad4ce195b3bfc1cb5a0e73629c7cfb45f Mon Sep 17 00:00:00 2001 From: Alfred Dagenais Date: Sat, 15 Jan 2022 11:32:02 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=20Reset=20Canvas=20on=20each=20?= =?UTF-8?q?pass=20of=20drawing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main.js b/src/main.js index 365bd04..37a0b7c 100644 --- a/src/main.js +++ b/src/main.js @@ -3,8 +3,8 @@ const { createCanvas, loadImage } = require("canvas"); const console = require("console"); const { layersOrder, format, rarity } = require("./config.js"); -const canvas = createCanvas(format.width, format.height); -const ctx = canvas.getContext("2d"); +let canvas; +let ctx; if (!process.env.PWD) { process.env.PWD = process.cwd(); @@ -132,6 +132,9 @@ const createFiles = async edition => { let numDupes = 0; for (let i = 1; i <= edition; i++) { + canvas = createCanvas(format.width, format.height); + ctx = canvas.getContext("2d"); + await layers.forEach(async (layer) => { await drawLayer(layer, i); });