diff --git a/data/images/imageCSV.csv b/data/images/imageCSV.csv index c4f9b974..ba52ca09 100644 --- a/data/images/imageCSV.csv +++ b/data/images/imageCSV.csv @@ -15,51 +15,53 @@ Red Land,m15RLFull.png,Full-0-0-750-1050;Title-0-0-750-1050;Type-0-0-750-1050;Ru Green Land,m15GLFull.png,Full-0-0-750-1050;Title-0-0-750-1050;Type-0-0-750-1050;Rules Text-0-0-750-1050;Pinline-0-0-750-1050;Frame-0-0-750-1050 Multicolored Land,m15MLFull.png,Full-0-0-750-1050;Title-0-0-750-1050;Type-0-0-750-1050;Rules Text-0-0-750-1050;Pinline-0-0-750-1050;Frame-0-0-750-1050 Colorless Land,m15CLFull.png,Full-0-0-750-1050;Title-0-0-750-1050;Type-0-0-750-1050;Rules Text-0-0-750-1050;Pinline-0-0-750-1050;Frame-0-0-750-1050 -White,m15WPT.png,Full-570-934-137-77 -Blue,m15UPT.png,Full-570-934-137-77 -Black,m15BPT.png,Full-570-934-137-77 -Red,m15RPT.png,Full-570-934-137-77 -Green,m15GPT.png,Full-570-934-137-77 -Multicolored,m15MPT.png,Full-570-934-137-77 -Artifact,m15APT.png,Full-570-934-137-77 -Colorless,m15CPT.png,Full-570-934-137-77 -Vehicle,m15VPT.png,Full-570-934-137-77 -White,m15WLegendary.png,Full-20-20-714-186 -Blue,m15ULegendary.png,Full-20-20-714-186 -Black,m15BLegendary.png,Full-20-20-714-186 -Red,m15RLegendary.png,Full-20-20-714-186 -Green,m15GLegendary.png,Full-20-20-714-186 -Multicolored,m15MLegendary.png,Full-20-20-714-186 -Artifact,m15ALegendary.png,Full-20-20-714-186 -Colorless,m15CLegendary.png,Full-20-20-714-186 -White,m15WRareStamp.png,Full-329-949-90-50 -Blue,m15URareStamp.png,Full-329-949-90-50 -Black,m15BRareStamp.png,Full-329-949-90-50 -Red,m15RRareStamp.png,Full-329-949-90-50 -Green,m15GRareStamp.png,Full-329-949-90-50 -Multicolored,m15MRareStamp.png,Full-329-949-90-50 -Artifact,m15ARareStamp.png,Full-329-949-90-50 -Colorless,m15CRareStamp.png,Full-329-949-90-50 -White,m15WMiracle.png,Full-30-30-690-511 -Blue,m15UMiracle.png,Full-30-30-690-511 -Black,m15BMiracle.png,Full-30-30-690-511 -Red,m15RMiracle.png,Full-30-30-690-511 -Green,m15GMiracle.png,Full-30-30-690-511 -Multicolored,m15MMiracle.png,Full-30-30-690-511 -Artifact,m15AMiracle.png,Full-30-30-690-511 -Colorless,m15CMiracle.png,Full-30-30-690-511 -White,m15WNyx.png,Full-30-30-690-586 -Blue,m15UNyx.png,Full-30-30-690-586 -Black,m15BNyx.png,Full-30-30-690-586 -Red,m15RNyx.png,Full-30-30-690-586 -Green,m15GNyx.png,Full-30-30-690-586 -Multicolored,m15MNyx.png,Full-30-30-690-586 -Artifact,m15ANyx.png,Full-30-30-690-586 -Colorless,m15CNyx.png,Full-30-30-690-586 -White Land,m15WLNyx.png,Full-30-30-690-586 -Blue Land,m15ULNyx.png,Full-30-30-690-586 -Black Land,m15BLNyx.png,Full-30-30-690-586 -Red Land,m15RLNyx.png,Full-30-30-690-586 -Green Land,m15GLNyx.png,Full-30-30-690-586 -Multicolored Land,m15MLNyx.png,Full-30-30-690-586 -Colorless Land,m15CLNyx.png,Full-30-30-690-586 \ No newline at end of file +White PT,m15WPT.png,Full-570-934-137-77 +Blue PT,m15UPT.png,Full-570-934-137-77 +Black PT,m15BPT.png,Full-570-934-137-77 +Red PT,m15RPT.png,Full-570-934-137-77 +Green PT,m15GPT.png,Full-570-934-137-77 +Multicolored PT,m15MPT.png,Full-570-934-137-77 +Artifact PT,m15APT.png,Full-570-934-137-77 +Colorless PT,m15CPT.png,Full-570-934-137-77 +Vehicle PT,m15VPT.png,Full-570-934-137-77 +White Legendary,m15WLegendary.png,Full-20-20-714-186 +Blue Legendary,m15ULegendary.png,Full-20-20-714-186 +Black Legendary,m15BLegendary.png,Full-20-20-714-186 +Red Legendary,m15RLegendary.png,Full-20-20-714-186 +Green Legendary,m15GLegendary.png,Full-20-20-714-186 +Multicolored Legendary,m15MLegendary.png,Full-20-20-714-186 +Artifact Legendary,m15ALegendary.png,Full-20-20-714-186 +Colorless Legendary,m15CLegendary.png,Full-20-20-714-186 +White Rare Stamp,m15WRareStamp.png,Full-329-949-90-50 +Blue Rare Stamp,m15URareStamp.png,Full-329-949-90-50 +Black Rare Stamp,m15BRareStamp.png,Full-329-949-90-50 +Red Rare Stamp,m15RRareStamp.png,Full-329-949-90-50 +Green Rare Stamp,m15GRareStamp.png,Full-329-949-90-50 +Multicolored Rare Stamp,m15MRareStamp.png,Full-329-949-90-50 +Artifact Rare Stamp,m15ARareStamp.png,Full-329-949-90-50 +Colorless Rare Stamp,m15CRareStamp.png,Full-329-949-90-50 +Holo Stamp,stamp.png,Full-340-965-70-38 +Black Border,masks/Border.png,Full-0-0-750-1050 +White Miracle,m15WMiracle.png,Full-30-30-690-511 +Blue Miracle,m15UMiracle.png,Full-30-30-690-511 +Black Miracle,m15BMiracle.png,Full-30-30-690-511 +Red Miracle,m15RMiracle.png,Full-30-30-690-511 +Green Miracle,m15GMiracle.png,Full-30-30-690-511 +Multicolored Miracle,m15MMiracle.png,Full-30-30-690-511 +Artifact Miracle,m15AMiracle.png,Full-30-30-690-511 +Colorless Miracle,m15CMiracle.png,Full-30-30-690-511 +White Nyx,m15WNyx.png,Full-30-30-690-586 +Blue Nyx,m15UNyx.png,Full-30-30-690-586 +Black Nyx,m15BNyx.png,Full-30-30-690-586 +Red Nyx,m15RNyx.png,Full-30-30-690-586 +Green Nyx,m15GNyx.png,Full-30-30-690-586 +Multicolored Nyx,m15MNyx.png,Full-30-30-690-586 +Artifact Nyx,m15ANyx.png,Full-30-30-690-586 +Colorless Nyx,m15CNyx.png,Full-30-30-690-586 +White Land Nyx,m15WLNyx.png,Full-30-30-690-586 +Blue Land Nyx,m15ULNyx.png,Full-30-30-690-586 +Black Land Nyx,m15BLNyx.png,Full-30-30-690-586 +Red Land Nyx,m15RLNyx.png,Full-30-30-690-586 +Green Land Nyx,m15GLNyx.png,Full-30-30-690-586 +Multicolored Land Nyx,m15MLNyx.png,Full-30-30-690-586 +Colorless Land Nyx,m15CLNyx.png,Full-30-30-690-586 \ No newline at end of file diff --git a/data/images/stamp.png b/data/images/stamp.png new file mode 100644 index 00000000..e0561ee3 Binary files /dev/null and b/data/images/stamp.png differ diff --git a/data/scripts/colors.js b/data/scripts/colors.js index 98b29b0f..c74ddb61 100644 --- a/data/scripts/colors.js +++ b/data/scripts/colors.js @@ -9,7 +9,7 @@ function changeColor() { document.documentElement.style.setProperty("--shifting-color-1", "rgb(" + parseInt(colors[0] + regularAdjust) + "," + parseInt(colors[1] + regularAdjust) + "," + parseInt(colors[2] + regularAdjust) + ")") var lightColors = indexToColor(currentColorIndex + lightLead) document.documentElement.style.setProperty("--shifting-color-1-light", "rgb(" + parseInt(lightColors[0] + lightAdjust) + "," + parseInt(lightColors[1] + lightAdjust) + "," + parseInt(lightColors[2] + lightAdjust) + ")") - currentColorIndex += colorJumpSize = 153 / 120 //The second number is how many seconds it takes to do a full loop + currentColorIndex += 153 / 360 //The second number is how many seconds it takes to do a full loop } function indexToColor(colorIndex) { var red = 0, green = 0, blue = 0 diff --git a/data/scripts/main.js b/data/scripts/main.js index f73a87a0..d087211d 100644 --- a/data/scripts/main.js +++ b/data/scripts/main.js @@ -3,10 +3,9 @@ //============================================// /* Test things! */ function testFunction() { - // console.log("test function begin"); - // cardMaster.innerHTML += frameList[0].cardMasterElement("Full"); - // console.log("test function end"); - // cardMasterUpdated(); + cardMaster.appendChild(frameList[0].cardMasterElement("Full")); + cardMasterUpdated(); + console.log("First frame manually loaded") } @@ -21,6 +20,7 @@ function initiate() { window.maskList = []; window.selectedFrame = -1; window.selectedMask = ""; + window.updateTextDelay = setTimeout(rewriteText, 500); for (var i = 0; i < maskNameList.length; i++) { var imageSource = "data/images/masks/" + maskNameList[i].replace(" ", "") + ".png"; maskList[i] = new Image(); @@ -87,7 +87,7 @@ function loadImageCSV() { frameList[frameList.length] = new frameImage(splitIndividualImageCSV[0], "data/images/" + splitIndividualImageCSV[1], splitIndividualImageCSV[2]); } for (var i = 0; i < frameList.length; i++) { - document.getElementById("framePicker").innerHTML += frameList[i].framePickerElement(); + document.getElementById("framePicker").appendChild(frameList[i].framePickerElement()); } //I don't like these here, because even though they run, it doesn't populate the mask options // document.getElementsByClassName("frameOption")[0].classList.add("frameOptionSelected"); @@ -123,10 +123,19 @@ class frameImage { } } cardMasterElement(targetMask) { - return "
" + this.displayName + " (" + targetMask + ")x
"; + var tempElement = document.createElement("div"); + tempElement.id = "frameIndex" + frameList.indexOf(this); + tempElement.classList.add("cardMasterElement"); + tempElement.innerHTML = this.displayName + " (" + targetMask + ") x"; + return tempElement } framePickerElement(targetElement) { - return "
"; + var tempElement = document.createElement("div"); + tempElement.id = "frameIndex" + frameList.indexOf(this); + tempElement.classList.add("frameOption"); + tempElement.onclick = frameOptionClicked; + tempElement.innerHTML = "" + return tempElement; } } @@ -153,6 +162,7 @@ function frameOptionClicked(event) { } document.getElementsByClassName("maskOption")[0].classList.add("maskOptionSelected"); selectedMask = document.getElementsByClassName("maskOption")[0].id.replace("maskName", ""); + document.getElementById("selectedFramePreview").innerHTML = "Selected: " + frameList[selectedFrame].displayName + " frame with a " + selectedMask + " mask"; } } function maskOptionClicked(event) { @@ -167,11 +177,13 @@ function maskOptionClicked(event) { } clickedElement.classList.add("maskOptionSelected"); selectedMask = clickedElement.id.replace("maskName", ""); + document.getElementById("selectedFramePreview").innerHTML = "Selected: " + frameList[selectedFrame].displayName + " frame with a " + selectedMask + " mask"; } function addFrameToCardMaster(right = "") { //Takes the stored selectedFrame and selectedMask to add the frame w/ mask to the card master! if (selectedFrame > -1 && selectedMask != "") { - cardMaster.innerHTML = frameList[selectedFrame].cardMasterElement(selectedMask + right) + cardMaster.innerHTML; + //In order to both keep input values and insert new frames before old ones, they must be added like so: + cardMaster.insertBefore(frameList[selectedFrame].cardMasterElement(selectedMask + right), cardMaster.children[0]); cardMasterUpdated(); } } @@ -183,10 +195,11 @@ function deleteCardMasterElement(event) { /* Card Master Cool Stuff! */ function cardMasterUpdated() { - console.log("The card master is updating!"); + // console.log("The card master is updating!"); frameFinalContext.clearRect(0, 0, cardWidth, cardHeight); for (var i = cardMaster.children.length - 1; i >= 0; i--) { var targetChild = cardMaster.children[i]; + var opacityToDraw = targetChild.children[0].value / 100; var frameToDraw = frameList[parseInt(targetChild.id.replace("frameIndex", ""))]; var maskName = targetChild.innerHTML.slice(targetChild.innerHTML.indexOf("(") + 1, targetChild.innerHTML.indexOf(")")); var rightHalf = false; @@ -200,13 +213,18 @@ function cardMasterUpdated() { frameMaskContext.globalCompositeOperation = "source-over"; frameMaskContext.clearRect(0, 0, cardWidth, cardHeight); frameMaskContext.drawImage(maskList[maskImageIndex], 0, 0, cardWidth, cardHeight); + frameMaskContext.globalCompositeOperation = "source-in"; if (rightHalf) { - frameMaskContext.globalCompositeOperation = "source-in" frameMaskContext.drawImage(maskList[0], 0, 0, cardWidth, cardHeight) } - frameMaskContext.globalCompositeOperation = "source-in"; frameMaskContext.drawImage(frameToDraw.image, frameToDraw.xList[maskIndex], frameToDraw.yList[maskIndex], frameToDraw.widthList[maskIndex], frameToDraw.heightList[maskIndex]); + if (targetChild.children[1].checked == true) { + frameFinalContext.globalCompositeOperation = "destination-out"; + } + frameFinalContext.globalAlpha = opacityToDraw; frameFinalContext.drawImage(frameMaskCanvas, 0, 0, cardWidth, cardHeight); + frameFinalContext.globalAlpha = 1; + frameFinalContext.globalCompositeOperation = "source-over"; } updateBottomInfoCanvas(); } @@ -214,15 +232,9 @@ function cardMasterUpdated() { /* Overall card stuff */ function cardImageUpdated() { - // //clear it -// cardContext.fillStyle = "black" -// cardContext.fillRect(0, 0, cardWidth, cardHeight) -// //draw the art, frame, text, mana symbols, set symbol, watermark... - - -// //clear the corners - //Clear the canvas - cardFinalContext.clearRect(0, 0, cardWidth, cardHeight); + //Clear the canvases + cardFinalContext.fillStyle = "black"; + cardFinalContext.fillRect(0, 0, cardWidth, cardHeight); displayContext.clearRect(0, 0, cardWidth, cardHeight); //Draw the art, frame, text, bottom info, mana cost, watermark, and set symbol cardFinalContext.drawImage(cardArt, version.artX + getValue("inputCardArtX"), version.artY + getValue("inputCardArtY"), cardArt.width * getValue("inputCardArtZoom") / 100, cardArt.height * getValue("inputCardArtZoom") / 100) @@ -284,7 +296,11 @@ function changeWhichText() { } function updateText() { version.textList[whichTextIndex][1] = document.getElementById("inputText").value - textContext.clearRect(0, 0, cardWidth, cardHeight) + clearTimeout(updateTextDelay) + updateTextDelay = setTimeout(rewriteText, 250); +} +function rewriteText() { + textContext.clearRect(0, 0, cardWidth, cardHeight) for (var i = 0; i < version.textList.length; i ++) { textContext.writeText(version.textList[i][1], version.textList[i][2], version.textList[i][3], version.textList[i][4], version.textList[i][5], version.textList[i][6], version.textList[i][7], version.textList[i][8], version.textList[i][9]) } @@ -338,208 +354,15 @@ function loadScript(scriptPath){ +/* + Directly taken (with small edits) from previous version. + sort these!!! +*/ - -// //Define some variables -// var cardWidth = 750, cardHeight = 1050 -// var version = {} - -// var initiated = false -// var suggestedColor = "White" - -// //Make all the canvases and their contexts -// var mainCanvas = document.getElementById("mainCanvas") -// mainCanvas.width = cardWidth -// mainCanvas.height = cardHeight -// var mainContext = mainCanvas.getContext("2d") -// var canvasList = ["card", "mask", "image", "text", "paragraph", "line", "transparent", "crop", "bottomInfo", "setSymbol", "watermark", "temp"] -// for (var i = 0; i < canvasList.length; i++) { -// window[canvasList[i] + "Canvas"] = document.createElement("canvas") -// window[canvasList[i] + "Canvas"].width = cardWidth -// window[canvasList[i] + "Canvas"].height = cardHeight -// window[canvasList[i] + "Context"] = window[canvasList[i] + "Canvas"].getContext("2d") -// } -// //Create the arrays that keeps track of what parts of the card are what -// var cardMasterTypes = [] -// var cardMasterImages = [] -// //var cardMasterOpacity = [] -// var cardMasterOpacityValue = [] -// //Mana symbol Array setup -// var manaSymbolCodeList = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "w", "u", "b", "r", "g", "2w", "2u", "2b", "2r", "2g", "pw", "pu", "pb", "pr", "pg", "wu", "wb", "ub", "ur", "br", "bg", "rg", "rw", "gw", "gu", "x", "s", "c", "t","untap", "e", "y", "z", "1/2", "inf", "chaos", "plane", "l+", "l-", "l0", "oldtap", "artistbrush", "bar"] -// var manaSymbolImageList = [] -// //Manually create a few important images -// var cardArt = new Image(), setSymbol = new Image(), watermark = new Image() -// cardArt.crossOrigin = "anonymous" -// setSymbol.crossOrigin = "anonymous" -// watermark.crossOrigin = "anonymous" -// cardArt.onload = function() { -// updateCardCanvas() -// } -// setSymbol.onload = function() { -// updateSetSymbolCanvas() -// } -// watermark.onload = function() { -// updateWatermarkCanvas() -// } -// //Load the mana symbol images -// loadManaSymbolImages() -// //Load the CSV full of image data -// loadImageSpreadsheet() - - -// //============================================// -// // Functions // -// //============================================// -// var nameArray = [] -// //Load the CSV full of image data -// function loadImageSpreadsheet() { -// var xhttp = new XMLHttpRequest() -// xhttp.onreadystatechange = function() { -// if (this.readyState == 4) { -// var rawText = xhttp.responseText.split("\n") -// for (var i = 0; i < rawText.length; i ++) { -// for (var n = 0; n < rawText[0].split(",").length; n++) { -// if (i == 0) { -// window[rawText[0].split(",")[n].trim() + "Array"] = [] -// } else { -// window[rawText[0].split(",")[n].trim() + "Array"][i - 1] = rawText[i].split(",")[n].trim() -// } -// } -// if (i != 0) { -// nameArray[i - 1] = versionArray[i - 1] + colorArray[i - 1] + typeArray[i - 1] -// } -// if (i == rawText.length - 1) { -// init() -// } -// } -// } -// } -// xhttp.open("GET", "data/images/imageSpreadsheet.csv", true) -// xhttp.send() -// } -// //After the csv has been loaded, the init function runs. -// function init() { -// //Loads the base version (m15) -// changeVersionTo("m15") -// //Loads all the masks -// for (var i = 0; i < colorArray.length; i ++) { -// if (colorArray[i] == "Mask") { -// loadImage(i) -// } -// } -// //Runs any tests. This should not do anything when published. -// setTimeout(testFunction, 100) -// initiated = true -// textCodeTutorial() -// //Checks cookies! -// setTimeout(checkCookies, 100) -// } -// //Loads an image. Only actually loads images the first time each image is loaded, otherwise assigns it. -// function loadImage(index, target = "none") { -// if (window[nameArray[index]] == undefined) { -// window[nameArray[index]] = new customImage(index, target) -// } else { -// addToCardMaster(index, target) -// } -// } -// //Special image object -// function customImage(index, target) { -// this.loaded = false -// this.index = index -// this.image = new Image() -// this.image.src = "data/images/" + nameArray[index] + ".png" -// this.image.onload = function() { -// window[nameArray[index]].loaded = true -// addToCardMaster(index, target) -// } -// } -// //Adds an image to the card master. Replaces the previous one if it already existed -// function addToCardMaster(index, target) { -// if (target == "preview") { -// document.getElementById("imgPreview").src = window[nameArray[index]].image.src -// return -// } -// if (document.getElementById("checkboxSecondary").checked) { -// target += "Secondary" -// } -// if ((target == typeArray[index]) || (secondaryArray[index] && target.replace("Secondary", "")) == typeArray[index] || (typeArray[index] == "Full")) { -// if (cardMasterTypes.includes(target)) { -// cardMasterImages[cardMasterTypes.indexOf(target)] = window[nameArray[index]] -// } else { -// cardMasterImages[cardMasterTypes.length] = window[nameArray[index]] -// cardMasterTypes[cardMasterTypes.length] = target -// } -// cardMasterUpdated() -// } -// } -// //Runs through all the assigned card images and draws them in -// function cardMasterUpdated() { -// imageContext.clearRect(0, 0, cardWidth, cardHeight) -// for (var i = 0; i < version.typeOrder.length; i ++) { -// if (cardMasterTypes.includes(version.typeOrder[i])) { -// imageContext.mask(cardMasterTypes.indexOf(version.typeOrder[i])) -// } -// } -// } -// //Custom function that draws onto a canvas using masks -// CanvasRenderingContext2D.prototype.mask = function(cardMasterIndex) { -// maskContext.clearRect(0, 0, cardWidth, cardHeight) -// maskContext.globalCompositeOperation = "source-over" -// if (cardMasterTypes[cardMasterIndex].includes("Secondary")) { -// maskContext.drawImage(window[nameArray[nameArray.indexOf("noneMaskSecondary")]].image, 0, 0, cardWidth, cardHeight) -// maskContext.globalCompositeOperation = "source-in" -// } -// var maskToUse = window[versionArray[cardMasterImages[cardMasterIndex].index] + "Mask" + cardMasterTypes[cardMasterIndex].replace("Secondary", "")] -// if (maskToUse != undefined) { -// maskContext.drawImage(maskToUse.image, xArray[maskToUse.index] * cardWidth, yArray[maskToUse.index] * cardHeight, widthArray[maskToUse.index] * cardWidth, heightArray[maskToUse.index] * cardHeight) -// maskContext.globalCompositeOperation = "source-in" -// } -// var mainImageIndex = cardMasterImages[cardMasterIndex].index -// maskContext.drawImage(cardMasterImages[cardMasterIndex].image, xArray[mainImageIndex] * cardWidth, yArray[mainImageIndex] * cardHeight, widthArray[mainImageIndex] * cardWidth, heightArray[mainImageIndex] * cardHeight) -// this.globalAlpha = cardMasterOpacityValue[version.typeOrder.indexOf(cardMasterTypes[cardMasterIndex].replace("Secondary", ""))] / 100 -// this.drawImage(maskCanvas, 0, 0, cardWidth, cardHeight) -// this.globalAlpha = 1 -// if (cardMasterTypes[cardMasterIndex].includes("RareStamp")) { -// this.drawImage(window[nameArray[nameArray.indexOf("noneMaskStamp")]].image, version.rareStampX, version.rareStampY, version.rareStampWidth, version.rareStampHeight) -// } -// updateImageCanvas() -// } -// //All the canvas functions -// function updateImageCanvas() { -// // imageContext.globalCompositeOperation = "destination-out" -// // for (var i = 0; i < cardMasterOpacity.length; i ++) { -// // imageContext.globalAlpha = 1 - cardMasterOpacityValue[i] / 100 -// // opacityImage = window[version.currentVersion + "Mask" + cardMasterOpacity[i]].image -// // imageContext.drawImage(opacityImage, 0, 0, cardWidth, cardHeight) -// // } -// // imageContext.globalAlpha = 1 -// // imageContext.globalCompositeOperation = "source-over" -// updateBottomInfoCanvas() -// } -// function updateTextCanvas() { -// //post processing? -// updateCardCanvas() -// } -// var currentlyWritingText = false -// //Rewrites all the text! -// function updateText() { -// if (!currentlyWritingText) { -// currentlyWritingText = true -// setTimeout(updateTextInnerShell, 100) -// } -// } -// function updateTextInnerShell() { -// version.textList[whichTextIndex][1] = document.getElementById("inputText").value -// textContext.clearRect(0, 0, cardWidth, cardHeight) -// for (var i = 0; i < version.textList.length; i ++) { -// var waitUntilIAmDone = textContext.writeText(version.textList[i][1], version.textList[i][2], version.textList[i][3], version.textList[i][4], version.textList[i][5], version.textList[i][6], version.textList[i][7], version.textList[i][8], version.textList[i][9]) -// updateTextCanvas() -// } -// } //figures out the placing of the set symbol function updateSetSymbol() { setSymbolContext.clearRect(0, 0, cardWidth, cardHeight) @@ -603,131 +426,6 @@ function updateWatermark() { } cardImageUpdated() } -// //Does the bottom info function! This can be different depending on the version. - -// function updateCardCanvas() { -// if (!initiated) { -// return -// } -// //clear it -// cardContext.fillStyle = "black" -// cardContext.fillRect(0, 0, cardWidth, cardHeight) -// //draw the art, frame, text, mana symbols, set symbol, watermark... -// cardContext.drawImage(cardArt, version.artX + getValue("inputCardArtX"), version.artY + getValue("inputCardArtY"), cardArt.width * getValue("inputCardArtZoom") / 100, cardArt.height * getValue("inputCardArtZoom") / 100) -// cardContext.drawImage(imageCanvas, 0, 0, cardWidth, cardHeight) -// cardContext.drawImage(watermarkCanvas, 0, 0, cardWidth, cardHeight) -// cardContext.drawImage(textCanvas, 0, 0, cardWidth, cardHeight) -// cardContext.drawImage(bottomInfoCanvas, 0, 0, cardWidth, cardHeight) -// cardContext.drawManaCost(document.getElementById("inputManaCost").value, version.manaCostX, version.manaCostY, version.manaCostDiameter, version.manaCostDistance, version.manaCostDirection) -// cardContext.drawImage(setSymbolCanvas, 0, 0, cardWidth, cardHeight) -// //clear the corners -// cardContext.globalCompositeOperation = "destination-out" -// cardContext.drawImage(window[nameArray[nameArray.indexOf("noneMaskCorners")]].image, 0, 0, cardWidth, cardHeight) -// cardContext.globalCompositeOperation = "source-over" -// //paste it to the visible canvas -// mainContext.clearRect(0, 0, cardWidth, cardHeight) -// mainContext.drawImage(cardCanvas, 0, 0, cardWidth, cardHeight) -// currentlyWritingText = false -// } -// //Loads an image in from user input -// function userLoadImage() { -// loadImage(getSelectedTab("tabSelectColor"), "preview") -// } -// //Enters an image from user input -// function userEnterImage() { -// loadImage(getSelectedTab("tabSelectColor"), getSelectedTab("frameType")) -// } -// //Removes an image from user input -// function userRemoveImage() { -// var targetToRemove = getSelectedTab("frameType") -// if (document.getElementById("checkboxSecondary").checked) { -// targetToRemove += "Secondary" -// } -// if (cardMasterTypes.includes(targetToRemove) && targetToRemove != "Full") { -// cardMasterImages.splice(cardMasterTypes.indexOf(targetToRemove), 1) -// cardMasterTypes.splice(cardMasterTypes.indexOf(targetToRemove), 1) -// cardMasterUpdated() -// } -// } -// //Loads a script -// function loadScript(scriptPath){ -// var script = document.createElement("script") -// script.setAttribute("type","text/javascript") -// script.setAttribute("src", scriptPath) -// if (typeof script != "undefined") { -// document.getElementsByTagName("head")[0].appendChild(script) -// } -// } -// //Adjusts values to the card size -// function cwidth(inputWidth) { -// return inputWidth / 750 * cardWidth -// } -// function cheight(inputHeight) { -// return inputHeight / 1050 * cardHeight -// } -// //shortcut for parseInt(document.getElementById("").value) - -// //Changes the version -// function changeVersionTo(versionToChangeTo) { -// loadScript("data/versions/" + versionToChangeTo + "Version.js") -// } -// function finishChangingVersion() { -// hideShowFrameTypes() -// for (var i = 0; i < version.textList.length; i ++) { -// document.getElementById("inputWhichTextTabs").innerHTML += "
" + version.textList[i][0] + "
" -// if (i == 0) { -// document.getElementsByClassName("tabButton text")[0].classList.add("activeTab") -// } -// } -// updateText() -// updateBottomInfoCanvas() -// updateSetSymbolCanvas() -// } -// function hideShowFrameTypes() { -// document.getElementById("frameType").innerHTML = "" -// document.getElementById("inputImageTypeOpacity").innerHTML = "" -// for (var i = 0; i < version.typeOrder.length; i ++) { -// if (!version.typeOrder[i].includes("Secondary") && (!version.typesAdvanced.includes(version.typeOrder[i]) || document.getElementById("checkboxAdvanced").checked)) { -// tabSelectAddOption("frameType", version.typeOrder[i], version.typeOrder[i]) -// document.getElementById("inputImageTypeOpacity").innerHTML += "" -// // cardMasterOpacity[cardMasterOpacity.length] = version.typeOrder[i] -// cardMasterOpacityValue[cardMasterOpacityValue.length] = 100 -// } -// } -// document.getElementsByClassName("frameType")[0].className += " activeTab" -// hideShowColors(true) -// loadOpacityValue() -// } -// //Hides and shows the options in inputImageColor to match the selected type -// function hideShowColors(enter = false) { -// document.getElementById("tabSelectColor").innerHTML = "" -// var activeTab = false -// for (var i = 0; i < versionArray.length; i ++) { -// if (versionArray[i] == version.currentVersion && (typeArray[i] == getSelectedTab("frameType").replace("Secondary", "") || (typeArray[i] == "Full" && version.typeNotFull.includes(getSelectedTab("frameType")) == false)) && colorArray[i] != "Mask" && (document.getElementById("checkboxAdvanced").checked || advancedArray[i] == "FALSE")) { -// tabSelectAddOption("tabSelectColor", displayNameArray[i], i) -// if (displayNameArray[i] == suggestedColor) { -// document.getElementsByClassName("tabSelectColor")[document.getElementsByClassName("tabSelectColor").length - 1].className += " activeTab" -// activeTab = true -// } -// } -// } -// if (!activeTab && document.getElementsByClassName("tabSelectColor").length > 0) { -// document.getElementsByClassName("tabSelectColor")[0].className += " activeTab" -// } -// if (enter) { -// userEnterImage() -// } -// userLoadImage() -// } -// //Loads the opacity value -// function loadOpacityValue() { -// document.getElementById("inputOpacityValue").value = cardMasterOpacityValue[version.typeOrder.indexOf(document.getElementById("inputImageTypeOpacity").value)] || 100 -// } -// function opacityValueUpdated() { -// cardMasterOpacityValue[version.typeOrder.indexOf(document.getElementById("inputImageTypeOpacity").value)] = document.getElementById("inputOpacityValue").value -// cardMasterUpdated() -// } - //Custom text function! This acts on any codes and makes things look nice :) CanvasRenderingContext2D.prototype.writeText = function(text = "", textX = 0, textY = 0, textWidth = cardWidth, textHeight = cardHeight, textFont = "belerenbsc", inputTextSize = 38, textColor="black", other="") { @@ -896,17 +594,8 @@ CanvasRenderingContext2D.prototype.drawManaCost = function(text, symbolsX, symbo } } } -// //Changes the textarea content to whichever text is currently selected for editing -// var whichTextIndex = 0 -// function changeWhichText() { -// for (var i = 0; i < version.textList.length; i ++) { -// if (version.textList[i][0] == document.getElementById("inputWhichText").value) { -// whichTextIndex = i -// } -// } -// document.getElementById("inputText").value = version.textList[whichTextIndex][1] -// } -// //Removes all the white pixels in an image + +//Removes all the white pixels in an image var whiteThreshold = 250 function whiteToTransparent(targetImage, source = targetImage.src) { //Create image, size canvas, draw image @@ -1010,7 +699,8 @@ function inputCardArtName(cardArtNameInput) { cardArtUrlList[i] = savedArtList[i].split('","border_crop":')[0] } for (i = 0; i < savedArtList.length; i ++) { - cardArtArtistList[i] = savedArtList[i].slice(savedArtList[i].indexOf('"artist":"') + 10, savedArtList[i].indexOf('","artist_ids":')) + cardArtArtistList[i] = savedArtList[i].slice(savedArtList[i].indexOf('"artist":"') + 10, savedArtList[i].indexOf('","artist_id')); + // cardArtArtistList[i] = cardArtArtistList[i].slice(0, cardArtArtistList[i].indexOf('","artist_id')) } inputCardArtNameNumber(1) } else if (this.readyState == 4 && this.status == 404) { @@ -1022,8 +712,8 @@ function inputCardArtName(cardArtNameInput) { } function inputCardArtNameNumber(cardArtNameNumberInput) { cardArt.src = cardArtUrlList[cardArtNameNumberInput - 1] - // document.getElementById("inputInfoArtist").value = cardArtArtistList[cardArtNameNumberInput - 1] - // updateBottomInfoCanvas() + document.getElementById("inputInfoArtist").value = cardArtArtistList[cardArtNameNumberInput - 1] + updateBottomInfoCanvas() } //Downloads the image! function downloadCardImage(linkElement) { @@ -1036,36 +726,16 @@ function downloadCardImage(linkElement) { event.preventDefault() alert("You must properly credit an artist before downloading") } - var cardImageData = cardCanvas.toDataURL() + var cardImageData = cardFinalCanvas.toDataURL() if (cardImageData == undefined) { alert("Sorry, it seems that you cannot download your card. Please try using a different browser/device.") } linkElement.href = cardImageData } -// //Toggles the visibility of tooltips -// function toggleTooltips(revealed = true) { -// var tooltipList = document.getElementsByClassName("tooltiptext") -// for (var i = 0; i < tooltipList.length; i ++) { -// if (revealed) { -// tooltipList[i].classList.remove("hidden") -// } else { -// tooltipList[i].classList.add("hidden") -// } -// } -// setCookie("tooltipsToggled", revealed + "") -// } - -// //DELETE: (for testing purposes only) -// function testFunction() { -// loadScript("data/scripts/setCodeList.js") -// } - - - // function setCookie(cookieName, cookieValue, cookieTime = (5 * 365 * 24 * 60 * 60 * 1000)) { //years*days*hours*minutes*seconds*milliseconds // var tempDate = new Date(); // tempDate.setTime(tempDate.getTime() + cookieTime); @@ -1110,74 +780,31 @@ function downloadCardImage(linkElement) { -// function tabSelect(event, selectSection) { -// var tabSelectButtons = document.getElementsByClassName(selectSection) -// for (var i = 0; i < tabSelectButtons.length; i++) { -// tabSelectButtons[i].className = tabSelectButtons[i].className.replace(" activeTab", "") -// } -// event.target.className += " activeTab" -// if (selectSection == "frameType") { -// hideShowColors() -// } else if (selectSection == "tabSelectColor") { -// userLoadImage() -// suggestedColor = displayNameArray[getSelectedTab("tabSelectColor")] -// } -// } -// function getSelectedTab(selectSection) { -// var tabSelectButtons = document.getElementsByClassName(selectSection) -// for (var i = 0; i < tabSelectButtons.length; i++) { -// if (tabSelectButtons[i].className.includes("activeTab")) { -// return tabSelectButtons[i].id -// } -// } -// } -// function tabSelectAddOption(tabSection, displayName, tabValue) { -// document.getElementById(tabSection).innerHTML += "
" + displayName + "
" -// } - - -// function textCodeTutorial() { -// var textCodeTutorialString = `line-skips to the next line -// _linenospace-skips to the next line, but doesn't add spacing -// _bar-skips to the next line, and adds the flavor text bar -// _flavor-skips to the next line, adds the flavor text bar, and italicizes the following text -// _i-italicizes the following text -// _/i-removes italics from the following text -// _fontsize#-changes the font size to # pixels -// _fontcolor#-changes the color to #. Can use color names, or hex codes -// _left-justifies text to the left -// _center-justifies text to the center -// _right-justifies text to the right -// _up#-moves the following text # pixels up -// _down#-moves the following text # pixels down -// _left#-moves the following text # pixels left -// _right#-moves the following text # pixels right -// _SYMBOL-creates a mana symbol, where SYMBOL can be: w, u, b, r, g, 1, 2, 3, etc...` -// var textCodeTutorialArray = textCodeTutorialString.split("_") -// for (var i = 0; i < textCodeTutorialArray.length; i ++) { -// document.getElementById("textCodeTutorial").innerHTML += "
{" + textCodeTutorialArray[i].split("-")[0] + "}
" + textCodeTutorialArray[i].split("-")[1] + "
" -// } -// } - -// function advancedBordersClicked() { -// hideShowFrameTypes() -// setCookie("advancedBorders", document.getElementById("checkboxAdvanced").checked + "") -// } - - +function textCodeTutorial() { + var textCodeTutorialString = `line-skips to the next line + _linenospace-skips to the next line, but doesn't add spacing + _bar-skips to the next line, and adds the flavor text bar + _flavor-skips to the next line, adds the flavor text bar, and italicizes the following text + _i-italicizes the following text + _/i-removes italics from the following text + _fontsize#-changes the font size to # pixels + _fontcolor#-changes the color to #. Can use color names, or hex codes + _left-justifies text to the left + _center-justifies text to the center + _right-justifies text to the right + _up#-moves the following text # pixels up + _down#-moves the following text # pixels down + _left#-moves the following text # pixels left + _right#-moves the following text # pixels right + _SYMBOL-creates a mana symbol, where SYMBOL can be: w, u, b, r, g, 1, 2, 3, etc...` + var textCodeTutorialArray = textCodeTutorialString.split("_") + for (var i = 0; i < textCodeTutorialArray.length; i ++) { + document.getElementById("textCodeTutorial").innerHTML += "
{" + textCodeTutorialArray[i].split("-")[0] + "}
" + textCodeTutorialArray[i].split("-")[1] + "
" + } +} // //textCodeTutorial() - - -// /*To do list: -// watermarks - - - - - -// possibly border color? -// */ +textCodeTutorial() \ No newline at end of file diff --git a/data/site/newStyles.css b/data/site/newStyles.css index 777dcad3..5afc4738 100644 --- a/data/site/newStyles.css +++ b/data/site/newStyles.css @@ -328,8 +328,8 @@ footer a:hover { .textarea { width: 100%; - min-height: 12em; - max-height: 36em; + min-height: 8em; + max-height: 24em; resize: vertical; } .textTabButton { @@ -349,4 +349,33 @@ footer a:hover { padding: 0px 0.2em; outline: none; width: 100%; +} +.inputOpacity { + font: 1em mplantin; + background-color: var(--light-color); + border: 1px solid #aaa; + border-radius: 0.2em; + padding: 0px 0.2em; + outline: none; + width: 2.9em; +} + + + +#textCodeTutorial { + display: grid; + grid-template-columns: 6.5em auto; + /*padding: 0.5em;*/ +} +#textCodeTutorial > div { + padding: 0.25em 0; + background-color: var(--clear-mid); +} +#textCodeTutorial > div:nth-child(4n), #textCodeTutorial > div:nth-child(4n - 1) { + background-color: var(--clear-light); +} + + +input[type="checkbox"], .frameOption, .maskOption, .button { + cursor: pointer; } \ No newline at end of file diff --git a/data/versions/m15.js b/data/versions/m15.js index f5514ef4..cf99e7fe 100644 --- a/data/versions/m15.js +++ b/data/versions/m15.js @@ -14,10 +14,10 @@ version.manaCostY = scale(62) version.manaCostDiameter = scale(36) version.manaCostDistance = scale(-38) version.manaCostDirection = "horizontal" -version.rareStampX = scale(340) -version.rareStampY = scale(965) -version.rareStampWidth = scale(70) -version.rareStampHeight = scale(38) +// version.rareStampX = scale(340) +// version.rareStampY = scale(965) +// version.rareStampWidth = scale(70) +// version.rareStampHeight = scale(38) version.watermarkWidth = scale(520) version.watermarkHeight = scale(250) version.watermarkY = scale(815) diff --git a/test.html b/test.html index 20dd4380..87a78ff2 100644 --- a/test.html +++ b/test.html @@ -35,6 +35,7 @@ +
No frame selected