From e787ce7d10ad7929bf5977f9855aeea01a9a79c4 Mon Sep 17 00:00:00 2001 From: Kyle <41976328+ImKyle4815@users.noreply.github.com> Date: Fri, 17 Aug 2018 20:11:47 -0700 Subject: [PATCH] Add files via upload --- KCI/data/scripts/mask.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/KCI/data/scripts/mask.js b/KCI/data/scripts/mask.js index 50a46a82..1339d935 100644 --- a/KCI/data/scripts/mask.js +++ b/KCI/data/scripts/mask.js @@ -1,13 +1,26 @@ var mask = document.createElement("canvas") var maskContext = mask.getContext("2d") -function drawMask(img, x, y, width, height, imgMask){ +function drawMask(img, x, y, width, height, imgMask, secondMask, arg) { mask.width = width mask.height = height maskContext.clearRect(0, 0, width, height) maskContext.globalCompositeOperation = "source-over" + if (secondMask.src != undefined) { + maskContext.drawImage(secondMask, 0, 0, width, height) + if (arg == "reverseSecond") { + maskContext.globalCompositeOperation = "source-out" + } else { + maskContext.globalCompositeOperation = "source-in" + } + } maskContext.drawImage(imgMask, 0, 0, width, height) - maskContext.globalCompositeOperation = "source-atop" - maskContext.drawImage(img, 0, 0, width, height) + maskContext.globalCompositeOperation = "source-in" + if (img.src == undefined) { + maskContext.fillStyle = img + maskContext.fillRect(0, 0, width, height) + } else { + maskContext.drawImage(img, 0, 0, width, height) + } card.drawImage(mask, x, y, width, height) } \ No newline at end of file