This commit is contained in:
Kyle
2018-11-07 16:14:04 -08:00
parent 46ea4a65fe
commit d46747be13
2 changed files with 28 additions and 23 deletions

View File

@@ -2,27 +2,29 @@ var mask = document.createElement("canvas")
var maskContext = mask.getContext("2d") var maskContext = mask.getContext("2d")
function drawMask(img, x, y, width, height, targetContext, imgMask, secondMask, arg) { function drawMask(img, x, y, width, height, targetContext, imgMask, secondMask, arg) {
var context = targetContext if (imgMask.width > 0) {
mask.width = width var context = targetContext
mask.height = height mask.width = width
maskContext.clearRect(0, 0, width, height) mask.height = height
maskContext.globalCompositeOperation = "source-over" maskContext.clearRect(0, 0, width, height)
if (secondMask.src != undefined) { maskContext.globalCompositeOperation = "source-over"
maskContext.drawImage(secondMask, 0, 0, width, height) if (secondMask.src != undefined && secondMask.width > 0) {
if (arg == "reverseSecond") { maskContext.drawImage(secondMask, 0, 0, width, height)
maskContext.globalCompositeOperation = "source-out" if (arg == "reverseSecond") {
} else { maskContext.globalCompositeOperation = "source-out"
maskContext.globalCompositeOperation = "source-in" } else {
} maskContext.globalCompositeOperation = "source-in"
} }
console.log(width + ", " + height + " --- " + imgMask.width + ", " + imgMask.height + " --- " + img.width + ", " + img.height) }
maskContext.drawImage(imgMask, 0, 0, width, height) //console.log(width + ", " + height + " --- " + imgMask.width + ", " + imgMask.height + " --- " + img.width + ", " + img.height)
maskContext.globalCompositeOperation = "source-in" maskContext.drawImage(imgMask, 0, 0, width, height)
if (img.src == undefined) { maskContext.globalCompositeOperation = "source-in"
maskContext.fillStyle = img if (img.src == undefined) {
maskContext.fillRect(0, 0, width, height) maskContext.fillStyle = img
} else { maskContext.fillRect(0, 0, width, height)
maskContext.drawImage(img, 0, 0, width, height) } else if (img.width > 0) {
} maskContext.drawImage(img, 0, 0, width, height)
targetContext.drawImage(mask, x, y, width, height) }
targetContext.drawImage(mask, x, y, width, height)
}
} }

View File

@@ -528,6 +528,9 @@ a:active {
<script crossorigin="anonymous"> <script crossorigin="anonymous">
//Need to do these things first!
cardWidth = 749
cardHeight = 1044
//Create the canvas for creating the border image //Create the canvas for creating the border image
var borderCanvas = document.createElement("canvas") var borderCanvas = document.createElement("canvas")
var border = borderCanvas.getContext("2d") var border = borderCanvas.getContext("2d")