From 6cc2cced9a2c312691fe86dc90d6ed55bccc0bd7 Mon Sep 17 00:00:00 2001 From: An Orbit <68935009+orbit-loona@users.noreply.github.com> Date: Tue, 2 Jan 2024 23:58:57 -0500 Subject: [PATCH] fix GBGs --- mods/a_mod_by_alice.js | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/mods/a_mod_by_alice.js b/mods/a_mod_by_alice.js index 61872d72..a55735a2 100644 --- a/mods/a_mod_by_alice.js +++ b/mods/a_mod_by_alice.js @@ -4331,11 +4331,28 @@ color1 and color2 spread through striped paint like dye does with itself. col // Draw the current pixels var canvas = document.getElementById("game"); var ctx = canvas.getContext("2d"); - ctx.clearRect(0,0,canvas.width,canvas.height); - if(settings.bg) { - ctx.fillStyle = settings.bg; - ctx.fillRect(0,0,canvas.width,canvas.height) - }; + ctx.clearRect(0, 0, canvas.width, canvas.height); + if(settings["bg"]) { + if(settings["bg"] instanceof Array) { + settings.bgAngle ??= 0; + var angle = (settings.bgAngle) * Math.PI / 180; + ctx.fillStyle = ctx.createLinearGradient( + 0, + 0, + canvas.width * Math.cos(angle) + 0, + canvas.height * Math.sin(angle) + ); + var colors = settings["bg"]; + for(i = 0; i < colors.length; i++) { + var color = colors[i]; + var position = i / (colors.length - 1); + ctx.fillStyle.addColorStop(position,color); + }; + } else { + ctx.fillStyle = settings["bg"]; + }; + ctx.fillRect(0, 0, canvas.width, canvas.height); + } var pixelDrawList = pixelsFirst.concat(pixelsLast); for (var i = 0; i < pixelDrawList.length; i++) { pixel = pixelDrawList[i];