From fe5abd6edabf5197b0bb3c105484ed5ad016591f Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Sun, 29 Jun 2025 22:38:09 +0300 Subject: [PATCH] Add alphaMod mod --- common/Drawings/Format/Format.js | 4 ++++ tests/common/color-mods/color-mods.js | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/common/Drawings/Format/Format.js b/common/Drawings/Format/Format.js index d6e74f7348..2493fd1be6 100644 --- a/common/Drawings/Format/Format.js +++ b/common/Drawings/Format/Format.js @@ -2073,6 +2073,10 @@ RGBA.A = 255 * val; break; } + case "alphaMod": { + RGBA.A = RGBA.A * val; + break; + } case"blue": { RGBA.B = this.CrgbtoRgbColor(val); break; diff --git a/tests/common/color-mods/color-mods.js b/tests/common/color-mods/color-mods.js index 3d4c60ca73..bfd3fc8ce3 100644 --- a/tests/common/color-mods/color-mods.js +++ b/tests/common/color-mods/color-mods.js @@ -17325,4 +17325,20 @@ function mod(name, value) { testResult = test(rgb(68, 114, 196, 255),[mod("alpha", -100000)],rgb(68, 114, 196, 0)); fTestFunction(testResult); }); + QUnit.test("Test alpha mod", (assert) => { + const fTestFunction = assertTest(assert); + let testResult; + testResult = test(rgb(68, 114, 196, 128),[mod("alphaMod", 50000)],rgb(68, 114, 196, 64)); + fTestFunction(testResult); + testResult = test(rgb(68, 114, 196, 128),[mod("alphaMod", 0)],rgb(68, 114, 196, 0)); + fTestFunction(testResult); + testResult = test(rgb(68, 114, 196, 128),[mod("alphaMod", 25000)],rgb(68, 114, 196, 31)); + fTestFunction(testResult); + testResult = test(rgb(68, 114, 196, 128),[mod("alphaMod", 100000)],rgb(68, 114, 196, 128)); + fTestFunction(testResult); + testResult = test(rgb(68, 114, 196, 128),[mod("alphaMod", -50000)],rgb(68, 114, 196, 0)); + fTestFunction(testResult); + testResult = test(rgb(68, 114, 196, 128),[mod("alphaMod", 200000)],rgb(68, 114, 196, 255)); + fTestFunction(testResult); + }); });