diff --git a/data/scripts/whiteToTransparent.js b/data/scripts/whiteToTransparent.js new file mode 100644 index 00000000..1d08d266 --- /dev/null +++ b/data/scripts/whiteToTransparent.js @@ -0,0 +1,56 @@ + +var transparentCanvas = document.createElement("canvas") +var transparentContext = transparentCanvas.getContext("2d") +//transparentCanvas.onload = function() { + //document.body.appendChild(transparentCanvas) //For testing purposes only +//} +transparentCanvas.onload = function() { + alert("WHAT") +} +//document.body.appendChild(transparentCanvas) +//Function that auto the image +function whiteToTransparent(url, destination) { + //Create image, size canvas, draw image + var imgTempSetSymbol = new Image() + imgTempSetSymbol.crossOrigin = "anonymous" + imgTempSetSymbol.src = url + imgTempSetSymbol.onload = function() { + if (imgTempSetSymbol.width > 0 && imgTempSetSymbol.height > 0) { + transparentCanvas.width = imgTempSetSymbol.width + transparentCanvas.height = imgTempSetSymbol.height + transparentCanvas.drawImage(imgTempSetSymbol, 0, 0) + //declare variables + var width = transparentCanvas.width + var height = transparentCanvas.height + var pix = {x:[], y:[]} + var imageData = transparentContext.getImageData(0,0,transparentCanvas.width,transparentCanvas.height) + var x, y, index + //Go through every pixel and + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) { + //(y * width + x) * 4 + 3 calculates the index at which the alpha value of the pixel at x, y is given + index = (y * width + x) * 4 + 3 + if (imageData.data[index] > 0) { + //pix is the image object that stores two arrays of x and y coordinates. These stored coordinates are all the visible pixels + pix.x.push(x) + pix.y.push(y) + } + } + } + //sorts the arrays numerically + pix.x.sort(function(a,b){return a-b}) + pix.y.sort(function(a,b){return a-b}) + var n = pix.x.length - 1 + //Finds the difference between the leftmost and rightmost visible pixels, and the topmost and bottommost pixels, cuts out a section of the canvas + width = pix.x[n] - pix.x[0] + height = pix.y[n] - pix.y[0] + var transparentImage = transparentContext.getImageData(pix.x[0], pix.y[0], width + 1, height + 1) + //Resizes the canvas and draws image + transparentCanvas.width = width + 1 + transparentCanvas.height = height + 1 + transparentContext.putImageData(transparentImage, 0, 0) + //Saves the newly image to the given image + destination.src = transparentCanvas.toDataURL() + } + } +} diff --git a/index.html b/index.html index 25866054..f4e1340a 100644 --- a/index.html +++ b/index.html @@ -6,7 +6,8 @@ - + +
Card Conjurer
@@ -18,8 +19,21 @@
Card Border
+ + + + + + + + + Border - @@ -27,30 +41,61 @@
Color -
- Second Color +
+ +
+
- Third Color +
+ +
+
- Power/Toughness - +
+ +
+
Border (Advanced)
- Legendary -
- Nyx -
- Miracle -
- Rare Stamp -
- Flip Icon +
+
+ +
+
+ +
+
+ +
+
+ +
+ -
- Flip Tip - -
- Flipped (Darker) -
- Silver Border -
+ +
+ +
+ +
+ +
+
+ +
Border Color -
- Foil -
- Color Identity - +
+ +
+
+ +
+
Name, Mana Cost, Type
Name - +
Mana Cost - +
Type - +
@@ -93,16 +152,16 @@
Rules Text
- +
Rules Text Font Size - +
Pixels Between Paragraphs - +
Shift All Text Down - +
@@ -111,71 +170,80 @@ Image
- +
Image Zoom - +
Image Left - +
Image Up - +
Bottom Information
Other Info - +
Card Number - +
Rarity - +
Set Abbreviation - +
Language - +
Artist Credit - +
- Make Artist Credit font black +
+ +
Set Symbol and Watermark
- Set Symbol -
+
+ +
Set Code - +
Set Symbol Rarity - +
Custom Set Symbol
- +
Scale Set Symbol - +

- - Watermark -
+
+ +

- +
Watermark Color
- @@ -185,16 +253,19 @@
- Second Watermark Color -
- +
+ +
+
Download/Options
Frame Rate - + Download
@@ -204,11 +275,11 @@
Use the following codes to get the respective symbol in the card's mana cost and rules text. In the mana cost, make sure to include spaces in between the codes, and in the rules text include '<' before each code and '>' after.
-
+
When selecting the card's color, use 'Second Color' for hybrid cards, and 'Third Color' for non-hybrid two-colored cards.
-
+
Check out some samples!
@@ -254,12 +325,23 @@ font-family: mplantini; src: url("data/fonts/mplantin-i.ttf"); } +/*Color Palette*/ +:root { + --title-text-color: rgb(100, 200, 50); /*TITLE*/ + --main-text-color: rgb(150, 150, 150); /*REGULAR*/ + --input-text-color: rgb(100, 200, 50); /*INPUTS*/ + --dark-text-color: rgb(96, 96, 96); /*DARK*/ + --hover-text-color: rgb(100, 200, 50); /*HOVER*/ + --section-background-color: rgba(0, 0, 0, 0.5); /*BACKGROUND*/ + --section-border-color: rgba(128, 255, 128, 0.1); /*BORDER*/ +} /*Applies to most elements (with rows and columns)*/ * { text-align: center; font-family: belerenb; font-size: 22px; - color: rgb(128, 128, 128); + color: var(--main-text-color); + user-select: none; } .row { margin-bottom: 5; @@ -278,21 +360,21 @@ } /*Style for sections, togglers, and togglees*/ .section { - border: 1px solid rgba(128, 255, 128, 0.1); - background-color: rgba(0, 0, 0, 0.5); + border: 1px solid var(--section-border-color); + background-color: var(--section-background-color); padding: 0px; } .toggler { width: 100%; } .toggler:hover { - color: rgb(128, 255, 128); + color: var(--hover-text-color); } .togglee { width: 100%; text-align: left; border-width: 1px; - border-color: rgba(128, 255, 128, 0.1); + border-color: var(--section-border-color); border-style: dashed solid solid solid; display: none; } @@ -300,25 +382,48 @@ display: block; } /*Specific input element styles*/ -input[type="text"], input[type="number"], textarea { +.input { text-align: left; - color: black; + border: none; + background-color: var(--section-border-color); + color: var(--input-text-color); width: 99%; } input[type="color"] { + border: none; + background-color: var(--section-border-color); padding-top: 0px; padding-bottom: 0px; } -select, option { - color: black; - width: 100%; +/*Custom checkboxes!*/ +.checkbox { + top: 4px; + position: relative; +} +.checkbox label { + display: inline-block; + width: 20px; + height: 20px; + border-radius: 100%; + position: absolute; + top: 0px; + left: 0px; + z-index: 1; + background: var(--section-border-color); +} +.checkbox input[type=checkbox]:checked + label { + background: var(--title-text-color); +} +.checkbox input { + opacity: 0; +} +.checkbox div { + white-space: pre; + position: absolute; + top: -8px; + left: 18px; } /*List of all mana symbols and their associated codes*/ -#symbolList { - border: 1px solid rgba(128, 255, 128, 0.1); - background-color: rgba(0, 0, 0, 0.5); - padding-bottom: 10px; -} #symbolList img { padding: 0px; position: relative; @@ -329,12 +434,17 @@ select, option { /*Other*/ .title { text-align: center; - color: rgb(128,255,128); + color: var(--title-text-color); font-family: belerenbsc; font-size: 60px; + position: sticky; + top: 0px; + z-index: 1; + background-color: var(--section-background-color); + border: 1px solid var(--section-border-color); } .info, .info * { - color: rgb(96,96,96); + color: var(--dark-text-color); font-family: belerenbsc; font-size: 16px; } @@ -347,16 +457,16 @@ html { } /*Hyperlinks*/ a:link { - color: rgb(128,128,128); + color: var(--main-text-color); } a:visited { - color: rgb(128,128,128); + color: var(--main-text-color); } a:hover { - color: rgb(128,255,128); + color: var(--hover-text-color); } a:active { - color: rgb(128,255,128); + color: var(--hover-text-color); } @@ -757,7 +867,7 @@ function drawPicture() { //Draw Set Symbol function drawSetSymbol() { //scales the set symbol so that it fits in the correct area and centers it - if (imgSetSymbol.src != "" && document.getElementById("checkboxSetSymbol").checked == true) { + if (imgSetSymbol.width > 0 && document.getElementById("checkboxSetSymbol").checked == true) { var height = setSymbolHeight var width = imgSetSymbol.width * (height / imgSetSymbol.height) if (width > setSymbolWidth) { @@ -1019,7 +1129,6 @@ function drawText(text, xCoord, yCoord) { //Make things go back to normal :) card.textAlign="left" } - //Toggles the visibility of predetermined sections of the input boxes function toggleSection(target) { for (i = 0; i < target.parentElement.parentElement.childNodes.length; i++) { @@ -1030,7 +1139,6 @@ function toggleSection(target) { } target.parentElement.childNodes[3].classList.toggle("shown") } - //Resizes anything that may need to be resized function resizeThings() { if (window.innerWidth > 809 + 300 && cardWidth <= 749) { @@ -1051,27 +1159,16 @@ function resizeThings() { } document.getElementById("symbolList").innerHTML = symbolList } - -//Loads the set symbol from my seperate repository +//Loads the set symbol from the gatherer site function loadSetSymbol() { - imgSetSymbol.crossOrigin = "Anonymous" - imgSetSymbol.src = "https://raw.githubusercontent.com/ImKyle4815/MTG-Set-Symbols/master/setSymbols/" + document.getElementById("setSymbolCode").value.toUpperCase() + "_" + document.getElementById("setSymbolRarity").value.toUpperCase() + ".png" + imgSetSymbol.cropped = false + imgSetSymbol.src = "https://cors-anywhere.herokuapp.com/http://gatherer.wizards.com/Handlers/Image.ashx?type=symbol&set=" + document.getElementById("setSymbolCode").value.toUpperCase() + "&size=large&rarity=" + document.getElementById("setSymbolRarity").value.toUpperCase() } - //Loads an image from URL function imageURL(input, targetImage) { targetImage.cropped = false targetImage.src = "https://cors-anywhere.herokuapp.com/" + input.value } - -//Best for last - downloads the image! -function downloadCardImage(linkElement) { - var cardImageData = canvas.toDataURL() - if (cardImageData == undefined) { - alert("Sorry, it seems that you cannot download your card. Please try using a different browser/device.") - } - linkElement.href = cardImageData -} //Randomizes the sample cards at the bottom of the page. Runs it here too randomizeSampleCards(6) function randomizeSampleCards(count) { @@ -1087,5 +1184,13 @@ function randomizeSampleCards(count) { document.getElementById("sampleCardB").src = "sampleCards/sample-card-" + cardNumbers[1] + ".png" document.getElementById("sampleCardC").src = "sampleCards/sample-card-" + cardNumbers[2] + ".png" } +//Best for last - downloads the image! +function downloadCardImage(linkElement) { + var cardImageData = canvas.toDataURL() + if (cardImageData == undefined) { + alert("Sorry, it seems that you cannot download your card. Please try using a different browser/device.") + } + linkElement.href = cardImageData +} - + \ No newline at end of file