mirror of
https://github.com/Investigamer/cardconjurer.git
synced 2025-07-26 21:04:58 -05:00
983 lines
37 KiB
HTML
983 lines
37 KiB
HTML
<!DOCTYPE html5>
|
|
<html>
|
|
<head>
|
|
<title>Card Conjurer - Custom Magic Card Maker</title>
|
|
<script src="data/scripts/loadScript.js"></script>
|
|
<script src="data/scripts/loadImage.js"></script>
|
|
<script src="data/scripts/loadColors.js"></script>
|
|
<script src="data/scripts/mask.js"></script>
|
|
<!--<script src="data/scripts/autocrop.js"></script> This is no longer required, but possibly could be in the future -->
|
|
<div class="title">Card Conjurer</div>
|
|
</head>
|
|
<!-- <img src="data/background.png"></img> -->
|
|
<body onresize="resizeThings()" onload="resizeThings()">
|
|
<div class="row">
|
|
<div class="column"><canvas id="canvas" width="749" height="1044"></canvas></div>
|
|
<div class="column" id="optionsColumn">
|
|
<!--OPTIONS-->
|
|
<div class="section">
|
|
<div class="toggler" onclick="toggleSection(this)">Card Border</div>
|
|
<div class="togglee shown">
|
|
Border
|
|
<select id="borderSelection" onchange="changeBorder()">
|
|
<option value="m15/">M15</option>
|
|
<option value="8th/">8th</option>
|
|
</select>
|
|
<br/>
|
|
Color
|
|
<select id="colorSelection" onchange="updateColor()">
|
|
<option value="white">White</option>
|
|
</select>
|
|
<br/>
|
|
<input type="checkbox" id="checkboxSecondColor" onchange="updateColor()">Second Color <select id="secondColorSelection" onchange="updateColor()"></select></input>
|
|
<br/>
|
|
<input type="checkbox" id="checkboxThirdColor" onchange="updateColor()">Third Color <select id="thirdColorSelection" onchange="updateColor()"></select></input>
|
|
<br/>
|
|
<input type="checkbox" id="checkboxCreature" onchange="updateColor()">Power/Toughness
|
|
<input id="inputPowerToughness" value="" type="text"></input>
|
|
</div>
|
|
</div>
|
|
<div class="section">
|
|
<div class="toggler" onclick="toggleSection(this)">Border (Advanced)</div>
|
|
<div class="togglee">
|
|
<input type="checkbox" id="checkboxLegendary" onchange="updateColor()">Legendary</input>
|
|
<br/>
|
|
<input type="checkbox" id="checkboxNyx" onchange="updateColor()">Nyx</input>
|
|
<br/>
|
|
<input type="checkbox" id="checkboxMiracle" onchange="updateColor()">Miracle</input>
|
|
<br/>
|
|
<input type="checkbox" id="checkboxRareStamp" onchange="updateColor()">Rare Stamp</input>
|
|
<br/>
|
|
<input type="checkbox" id="checkboxFlipIcon" onchange="updateColor()">Flip Icon <select id="inputFlipIcon" onchange="updateColor()">
|
|
<option value="blank.png">Blank</option>
|
|
<option value="day.png">Day</option>
|
|
<option value="night.png">Night</option>
|
|
<option value="compass.png">Compass</option>
|
|
<option value="moon.png">Moon</option>
|
|
<option value="eldrazi.png">Eldrazi</option>
|
|
<option value="planeswalker.png">Planeswalker</option>
|
|
</select></input>
|
|
<br/>
|
|
<input type="checkbox" id="checkboxFlipTip" onchange="updateColor()">Flip Tip
|
|
<input id="inputFlipTip" value="" type="text"></input>
|
|
<br/>
|
|
<input type="checkbox" id="checkboxFlippedDark" onchange="updateColor()">Flipped (Darker)</input>
|
|
<br/>
|
|
<input type="checkbox" id="checkboxSilverBorder">Silver Border</input>
|
|
<br/>
|
|
<input type="color" id="inputColor"> Border Color</input>
|
|
<br/>
|
|
<input type="checkbox" id="checkboxFoil">Foil</input>
|
|
</div>
|
|
</div>
|
|
<div class="section">
|
|
<div class="toggler" onclick="toggleSection(this)">Name, Mana Cost, Type</div>
|
|
<div class="togglee">
|
|
Name
|
|
<input id="inputName" type="text"></input>
|
|
<br/>
|
|
Mana Cost
|
|
<input id="inputCost" type="text"></input>
|
|
<br/>
|
|
Type
|
|
<input id="inputType" type="text"></input>
|
|
</div>
|
|
</div>
|
|
<div class="section">
|
|
<div class="toggler" onclick="toggleSection(this)">Rules Text</div>
|
|
<div class="togglee">
|
|
Rules Text
|
|
<br/>
|
|
<textarea id="inputText" rows="5" cols="40" style="width: 99%; resize: vertical; height: 100px"></textarea>
|
|
<br/>
|
|
Rules Text Font Size
|
|
<input id="textSize" type="number" min="0" max="100" value="37" step="0.5"></input>
|
|
<br/>
|
|
Pixels Between Paragraphs
|
|
<input id="textShift" type="number" min="0" max="300" value="13"></input>
|
|
<br/>
|
|
Shift All Text Down
|
|
<input id="textDown" type="number" min="0" max="300" value="0"></input>
|
|
</div>
|
|
</div>
|
|
<div class="section">
|
|
<div class="toggler" onclick="toggleSection(this)">Card Art</div>
|
|
<div class="togglee">
|
|
Image
|
|
<input type="file" accept="image/*" onchange="loadImage(event, imgArt, true)" id="inputPicture"></input>
|
|
<br/>
|
|
Image Zoom
|
|
<input id="imageSize" type="number" value="100" step="0.1"></input>
|
|
<br/>
|
|
Image Left
|
|
<input id="imageLeft" type="number" value="0" step="1"></input>
|
|
<br/>
|
|
Image Up
|
|
<input id="imageUp" type="number" value="0" step="1"></input>
|
|
</div>
|
|
</div>
|
|
<div class="section">
|
|
<div class="toggler" onclick="toggleSection(this)">Bottom Information</div>
|
|
<div class="togglee">
|
|
Other Info
|
|
<input id="inputInfo" value="Not A Real Card" type="text"></input>
|
|
<br/>
|
|
Card Number
|
|
<input id="inputNumber" value="001/001" type="text"></input>
|
|
<br/>
|
|
Rarity
|
|
<input id="inputRarity" value="C" type="text"></input>
|
|
<br/>
|
|
Set Abbreviation
|
|
<input id="inputSet" value="MTG" type="text"></input>
|
|
<br/>
|
|
Language
|
|
<input id="inputLanguage" value="EN" type="text"></input>
|
|
<br/>
|
|
Artist Credit
|
|
<input id="inputArtist" value="" type="text"></input>
|
|
<br/>
|
|
<input id="checkboxArtistColor" type="checkbox">Make Artist Credit font black</input>
|
|
</div>
|
|
</div>
|
|
<div class="section">
|
|
<div class="toggler" onclick="toggleSection(this)">Set Symbol and Watermark</div>
|
|
<div class="togglee">
|
|
<input type="checkbox" id="checkboxSetSymbol" checked="true">Set Symbol</input>
|
|
<br>
|
|
Set Code
|
|
<input type="text" onchange="loadSetSymbol()" value="HM" id="setSymbolCode"></input>
|
|
<br>
|
|
Set Symbol Rarity
|
|
<input type="text" onchange="loadSetSymbol()" value="C" id="setSymbolRarity"></input>
|
|
<br>
|
|
Custom Set Symbol
|
|
<input type="file" accept="image/*" onchange="loadImage(event, imgSetSymbol, true)" id="inputSetSymbol"></input>
|
|
<br/>
|
|
Scale Set Symbol
|
|
<input id="setSymbolSize" type="number" value="100" step="0.5"></input>
|
|
<br/><br/>
|
|
<input type="checkbox" id="checkboxWatermark" checked="true"></input>
|
|
Watermark
|
|
<br/>
|
|
<input type="file" accept="image/*" onchange="loadImage(event, imgWatermark, true)" id="inputWatermark"></input>
|
|
<br/>
|
|
Watermark Color
|
|
<br/>
|
|
<select id="watermarkColorSelection">
|
|
<option value="#afa360">White</option>
|
|
<option value="#04527c">Blue</option>
|
|
<option value="#494949">Black</option>
|
|
<option value="#a3280d">Red</option>
|
|
<option value="#0f4f14">Green</option>
|
|
<option value="#7f5f00">Gold</option>
|
|
<option value="#616b72">Artifact/Colorless</option>
|
|
</select>
|
|
<br/>
|
|
<input type="checkbox" id="checkboxSecondWatermarkColor"> Second Watermark Color
|
|
<br/>
|
|
<select id="secondWatermarkColorSelection"></select></input>
|
|
</div>
|
|
</div>
|
|
<div class="section">
|
|
<div class="toggler" onclick="toggleSection(this)">Download/Options</div>
|
|
<div class="togglee">
|
|
Frame Rate
|
|
<input type="number" id="inputFPS" value="10" min="0" onchange="window.clearInterval(cardClockInterval); cardClockInterval = setInterval(cardClock, 1000 / document.getElementById('inputFPS').value)"></input>
|
|
<div onclick="downloadCardImage()" id="downloadCardImage" href="" download="card.jpg">Download</div>
|
|
</div>
|
|
</div>
|
|
<!--END-->
|
|
</div>
|
|
</div>
|
|
<div class="row text">
|
|
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.<br/>
|
|
<div class="column" style="width: 100px">
|
|
w - <img id="w"><br/>
|
|
u - <img id="u"><br/>
|
|
b - <img id="b"><br/>
|
|
r - <img id="r"><br/>
|
|
g - <img id="g"><br/>
|
|
</div>
|
|
<div class="column" style="width: 100px">
|
|
pw - <img id="pw"><br/>
|
|
pu - <img id="pu"><br/>
|
|
pb - <img id="pb"><br/>
|
|
pr - <img id="pr"><br/>
|
|
pg - <img id="pg"><br/>
|
|
</div>
|
|
<div class="column" style="width: 100px">
|
|
2w - <img id="2w"><br/>
|
|
2u - <img id="2u"><br/>
|
|
2b - <img id="2b"><br/>
|
|
2r - <img id="2r"><br/>
|
|
2g - <img id="2g"><br/>
|
|
</div>
|
|
<div class="column" style="width: 100px">
|
|
w - <img id="wu"><br/>
|
|
u - <img id="wb"><br/>
|
|
b - <img id="ub"><br/>
|
|
r - <img id="ur"><br/>
|
|
g - <img id="br"><br/>
|
|
</div>
|
|
<div class="column" style="width: 100px">
|
|
w - <img id="bg"><br/>
|
|
u - <img id="rg"><br/>
|
|
b - <img id="rw"><br/>
|
|
r - <img id="gw"><br/>
|
|
g - <img id="gu"><br/>
|
|
</div>
|
|
<div class="column" style="width: 100px">
|
|
0 - <img id="0"><br/>
|
|
1 - <img id="1"><br/>
|
|
2 - <img id="2"><br/>
|
|
3 - <img id="3"><br/>
|
|
4 - <img id="4"><br/>
|
|
</div>
|
|
<div class="column" style="width: 100px">
|
|
5 - <img id="5"><br/>
|
|
6 - <img id="6"><br/>
|
|
7 - <img id="7"><br/>
|
|
8 - <img id="8"><br/>
|
|
9 - <img id="9"><br/>
|
|
</div>
|
|
<div class="column" style="width: 100px">
|
|
10 - <img id="10"><br/>
|
|
11 - <img id="11"><br/>
|
|
12 - <img id="12"><br/>
|
|
13 - <img id="13"><br/>
|
|
14 - <img id="14"><br/>
|
|
</div>
|
|
<div class="column" style="width: 100px">
|
|
15 - <img id="15"><br/>
|
|
16 - <img id="16"><br/>
|
|
17 - <img id="17"><br/>
|
|
18 - <img id="18"><br/>
|
|
19 - <img id="19"><br/>
|
|
</div>
|
|
<div class="column" style="width: 120px">
|
|
20 - <img id="20"><br/>
|
|
c - <img id="c"><br/>
|
|
x - <img id="x"><br/>
|
|
t - <img id="t"><br/>
|
|
untap - <img id="untap"><br/>
|
|
</div>
|
|
<div class="column" style="width: 120px">
|
|
snow - <img id="snow"><br/>
|
|
e - <img id="e"><br/>
|
|
<br/>
|
|
<br/>
|
|
<br/>
|
|
</div>
|
|
<br/><br/><br/><br/><br/><br/><br/> <!-- Not quite sure why I needed so many linebreaks here! -->
|
|
When selecting the card's color, use 'Second Color' for hybrid cards, and 'Third Color' for non-hybrid two-colored cards.
|
|
</div>
|
|
<div class="info">For Terms of Use and Disclaimer, see <a href="https://github.com/ImKyle4815/CardConjurer" target="_blank">the Github page</a>.</div>
|
|
</body>
|
|
|
|
|
|
|
|
<!--CSS-->
|
|
<style>
|
|
@font-face {
|
|
font-family: relaymedium;
|
|
src: url("data/fonts/relay-medium.ttf");
|
|
}
|
|
@font-face {
|
|
font-family: belerenb;
|
|
src: url("data/fonts/beleren-b.ttf");
|
|
}
|
|
@font-face {
|
|
font-family: belerenbsc;
|
|
src: url("data/fonts/beleren-bsc.ttf");
|
|
}
|
|
@font-face {
|
|
font-family: matrixbsc;
|
|
src: url("data/fonts/matrix-bsc.ttf");
|
|
}
|
|
@font-face {
|
|
font-family: matrix;
|
|
src: url("data/fonts/matrix.ttf");
|
|
}
|
|
@font-face {
|
|
font-family: matrixb;
|
|
src: url("data/fonts/matrix-b.ttf");
|
|
}
|
|
@font-face {
|
|
font-family: mplantin;
|
|
src: url("data/fonts/mplantin.ttf");
|
|
}
|
|
@font-face {
|
|
font-family: mplantini;
|
|
src: url("data/fonts/mplantin-i.ttf");
|
|
}
|
|
.title {
|
|
text-align: center;
|
|
color: rgb(128,255,128);
|
|
font-family: belerenbsc;
|
|
font-size: 60px;
|
|
}
|
|
.info {
|
|
text-align: center;
|
|
color: rgb(96,96,96);
|
|
font-family: belerenbsc;
|
|
font-size: 16px;
|
|
}
|
|
.section {
|
|
border: 1px solid rgb(128, 255, 128);
|
|
background-color: rgba(0, 0, 0, 0.5);
|
|
}
|
|
.toggler {
|
|
text-align: center;
|
|
color: rgb(255, 255, 255);
|
|
font-family: belerenbsc;
|
|
font-size: 20px;
|
|
width: 100%;
|
|
padding: 5px;
|
|
|
|
}
|
|
.toggler:hover {
|
|
color: rgb(128, 255, 128);
|
|
}
|
|
.togglee {
|
|
width: calc(100% - 12px);
|
|
padding: 5px;
|
|
border-width: 1px;
|
|
border-color: rgb(128, 255, 128);
|
|
border-style: dashed solid solid solid;
|
|
font-size: 20px;
|
|
color: rgb(255,255,255);
|
|
font-family: belerenbsc;
|
|
display: none;
|
|
}
|
|
.shown {
|
|
display: block;
|
|
}
|
|
.shown * {
|
|
font-family: mplantin;
|
|
font-size: 20px;
|
|
}
|
|
input[type="text"] {
|
|
width: 99%;
|
|
}
|
|
input[type="number"] {
|
|
width: 99%;
|
|
}
|
|
select {
|
|
width: 100%;
|
|
}
|
|
.column {
|
|
float: left;
|
|
}
|
|
.row:after{
|
|
content: "";
|
|
display: table;
|
|
clear: both;
|
|
}
|
|
.text {
|
|
padding: 10px;
|
|
text-align: left;
|
|
color: rgb(128, 128, 128);
|
|
font-family: beleren;
|
|
font-size: 25px;
|
|
}
|
|
.text img {
|
|
position: relative;
|
|
top: 8px;
|
|
width: 30px;
|
|
padding: 0px 0px 0px 0px !important;
|
|
margin: 0px;
|
|
}
|
|
body {
|
|
color: rgb(255,255,255);
|
|
font-family: mplantin;
|
|
font-size: 18px;
|
|
}
|
|
html {
|
|
background:url(data/background.png) no-repeat center center fixed;
|
|
-webkit-background-size: cover;
|
|
-moz-background-size: cover;
|
|
-o-background-size: cover;
|
|
background-size: cover;
|
|
}
|
|
canvas {
|
|
float: left;
|
|
padding: 10px;
|
|
}
|
|
a:link {
|
|
color: rgb(128,128,128);
|
|
}
|
|
|
|
a:visited {
|
|
color: rgb(128,128,128);
|
|
}
|
|
|
|
a:hover {
|
|
color: rgb(128,255,128);
|
|
}
|
|
|
|
a:active {
|
|
color: rgb(128,255,128);
|
|
}
|
|
</style>
|
|
|
|
|
|
|
|
<script crossorigin="anonymous">
|
|
//Load the initial border (m15)
|
|
changeBorder()
|
|
//set up initial variables
|
|
var borderPath
|
|
var secondColor
|
|
var thirdColor
|
|
var titleRightShift = 0
|
|
//set up canvas
|
|
var canvas = document.getElementById("canvas")
|
|
var card = canvas.getContext("2d")
|
|
//Load dynamic images
|
|
var dynamicImageList = ["borderColor", "secondBorderColor", "thirdBorderColor", "borderCreature", "borderLegendary", "secondBorderLegendary", "borderRareStamp", "secondBorderRareStamp", "art", "setSymbol", "watermark", "multiMask", "rareStampMask", "frameMask", "legendFrameMask", "borderMask", "borderNyx", "secondBorderNyx", "borderMiracle", "secondBorderMiracle", "borderFlipIcon", "borderFlipCircle", "borderFlipTip", "borderFlippedDark", "secondBorderFlippedDark"]
|
|
for (i = 0; i < dynamicImageList.length; i ++) {
|
|
var imgName = "img" + dynamicImageList[i].charAt(0).toUpperCase() + dynamicImageList[i].slice(1)
|
|
window[imgName] = new Image()
|
|
}
|
|
//Load static images
|
|
var staticImageList = ["artistBrush", "foil", "stampGradient", "multiGradient", "rareStamp", "cardMask", "artMask", "bar"]
|
|
for (i = 0; i < staticImageList.length; i ++) {
|
|
var imgName = "img" + staticImageList[i].charAt(0).toUpperCase() + staticImageList[i].slice(1)
|
|
window[imgName] = new Image()
|
|
//window[imgName].crossOrigin = "use-credentials"
|
|
window[imgName].src = "data/borders/" + staticImageList[i] + ".png"
|
|
}
|
|
//Mana symbol Array setup
|
|
var manaSymbolCode = ["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", "snow", "c", "t","untap", "e"]
|
|
var manaSymbolImages = new Array()
|
|
for (var i = 0; i < manaSymbolCode.length; i++) {
|
|
manaSymbolImages[i] = new Image()
|
|
manaSymbolImages[i].src = "data/manaSymbols/" + i + ".png"
|
|
if (document.getElementById(manaSymbolCode[i]) != null) {
|
|
document.getElementById(manaSymbolCode[i]).src = "data/manaSymbols/" + i + ".png"
|
|
}
|
|
}
|
|
//load first set symbol
|
|
loadSetSymbol()
|
|
//fill second watermark dropdown menu
|
|
document.getElementById("secondWatermarkColorSelection").innerHTML = document.getElementById("watermarkColorSelection").innerHTML
|
|
|
|
//Runs ten times every second (main loop)
|
|
function cardClock() {
|
|
//Insures that the corners of the final image are transparent
|
|
card.globalCompositeOperation = "source-over"
|
|
drawMask(document.getElementById("inputColor").value, 0, 0, canvas.width, canvas.height, imgCardMask, false, false)
|
|
card.globalCompositeOperation = "source-atop"
|
|
//Draws the card image, then...
|
|
drawPicture()
|
|
//redraws the colored border in case the image is too big.
|
|
drawMask(document.getElementById("inputColor").value, 0, 0, canvas.width, canvas.height, imgCardMask, imgArtMask, false)
|
|
//draws the card frames
|
|
drawBorder()
|
|
//draws the set symbol, mana cost, and watermark
|
|
drawSetSymbol()
|
|
drawManaCost()
|
|
drawWatermark()
|
|
//writes all the text. name, type, rules...
|
|
writeText()
|
|
//m15 and 8th edition have different info at the bottom of the cards and require completely different functions
|
|
if (m15Info == true) {
|
|
bottomInfoM15()
|
|
}
|
|
if (eighthInfo == true) {
|
|
bottomInfo8th()
|
|
}
|
|
//A shiny foil overlay!
|
|
if(document.getElementById("checkboxFoil").checked == true) {
|
|
card.drawImage(imgFoil, 0, 0, canvas.width, canvas.height)
|
|
}
|
|
//These are for pinpointing coordinates while adjusting values for new border types
|
|
//Vertical Line
|
|
// card.beginPath()
|
|
// card.moveTo(688, 0)
|
|
// card.lineTo(688, 1044)
|
|
// card.stroke()
|
|
//Horizontal Line
|
|
//card.beginPath()
|
|
//card.moveTo(0, setSymbolY)
|
|
//card.lineTo(749, setSymbolY)
|
|
//card.stroke()
|
|
}
|
|
var cardClockInterval = setInterval(cardClock, 1000 / document.getElementById("inputFPS").value)
|
|
|
|
|
|
//The two following functions load different types of borders
|
|
function changeBorder() {
|
|
//the loadScript function is located in data/scripts/loadScript.js. It sets values to variables such as set symbol coordinates or title font
|
|
loadScript("data/borders/defaultBorder.js")
|
|
}
|
|
function updateBorder() {
|
|
//This is a seperate function to insure that the border.js file finishes running before running a few last commands
|
|
document.getElementById("colorSelection").value = "white"
|
|
imgMultiMask.src = borderPath + "multiMask.png"
|
|
imgFrameMask.src = borderPath + "frameMask.png"
|
|
if (m15Info == true) {
|
|
imgLegendFrameMask.src = borderPath + "legendFrameMask.png"
|
|
imgRareStampMask.src = borderPath + "rareStampMask.png"
|
|
imgBorderMask.src = borderPath + "borderMask.png"
|
|
} else if (eighthInfo == true) {
|
|
imgBorderMask.src = borderPath + "frameMask.png"
|
|
}
|
|
updateColor()
|
|
}
|
|
//Loads the images for the card frame, power toughness box, and rare stamp
|
|
function updateColor() {
|
|
borderPath = "data/borders/" + document.getElementById("borderSelection").value
|
|
secondColor = document.getElementById("checkboxSecondColor").checked
|
|
thirdColor = document.getElementById("checkboxThirdColor").checked
|
|
var firstColorPath = borderPath + document.getElementById("colorSelection").value
|
|
var secondColorPath = borderPath + document.getElementById("secondColorSelection").value
|
|
var thirdColorPath = borderPath + document.getElementById("thirdColorSelection").value
|
|
var altframe = ""
|
|
if (document.getElementById("checkboxFlippedDark").checked == true && flipBorder == true) {
|
|
altframe = "dark"
|
|
} else {
|
|
altframe = ""
|
|
}
|
|
imgBorderColor.src = firstColorPath + "/frame.png"
|
|
imgSecondBorderColor.src = secondColorPath + "/frame.png"
|
|
imgThirdBorderColor.src = thirdColorPath + "/frame.png"
|
|
if (thirdColor == true) {
|
|
imgBorderCreature.src = thirdColorPath + "/" + altframe + "pt.png"
|
|
} else if (secondColor == true) {
|
|
imgBorderCreature.src = secondColorPath + "/" + altframe + "pt.png"
|
|
} else {
|
|
imgBorderCreature.src = firstColorPath + "/" + altframe + "pt.png"
|
|
}
|
|
if (legendaryBorder == true) {
|
|
imgBorderLegendary.src = firstColorPath + "/legendary.png"
|
|
imgSecondBorderLegendary.src = secondColorPath + "/legendary.png"
|
|
}
|
|
if (stampBorder == true) {
|
|
imgBorderRareStamp.src = firstColorPath + "/stamp.png"
|
|
imgSecondBorderRareStamp.src = secondColorPath + "/stamp.png"
|
|
}
|
|
if (nyxBorder == true) {
|
|
if (thirdColor == true) {
|
|
imgBorderNyx.src = thirdColorPath + "/nyx.png"
|
|
} else {
|
|
imgBorderNyx.src = firstColorPath + "/nyx.png"
|
|
imgSecondBorderNyx.src = secondColorPath + "/nyx.png"
|
|
}
|
|
}
|
|
if (miracleBorder == true) {
|
|
if (thirdColor == true) {
|
|
imgBorderMiracle.src = thirdColorPath + "/" + altframe + "miracle.png"
|
|
} else {
|
|
imgBorderMiracle.src = firstColorPath + "/" + altframe + "miracle.png"
|
|
imgSecondBorderMiracle.src = secondColorPath + "/" + altframe + "miracle.png"
|
|
}
|
|
}
|
|
if (flipBorder == true) {
|
|
if (thirdColor == true) {
|
|
imgBorderFlippedDark.src = thirdColorPath + "/flippedDark.png"
|
|
} else {
|
|
imgBorderFlippedDark.src = firstColorPath + "/flippedDark.png"
|
|
imgSecondBorderFlippedDark.src = secondColorPath + "/flippedDark.png"
|
|
}
|
|
if (secondColor == true) {
|
|
imgBorderFlipTip.src = secondColorPath + "/flipTip.png"
|
|
} else {
|
|
imgBorderFlipTip.src = firstColorPath + "/flipTip.png"
|
|
}
|
|
imgBorderFlipCircle.src = firstColorPath + "/flipCircle.png"
|
|
imgBorderFlipIcon.src = "data/borders/icons/" + document.getElementById("inputFlipIcon").value
|
|
}
|
|
}
|
|
//Draw Picture
|
|
function drawPicture() {
|
|
//scales the card art and draws it
|
|
var imageScale = document.getElementById("imageSize").value * 0.01
|
|
var imageLeftShift = parseInt(document.getElementById("imageLeft").value)
|
|
var imageUpShift = parseInt(document.getElementById("imageUp").value)
|
|
if (imgArt.width > 0) {
|
|
//drawMask(imgArt, 58 - imageLeftShift, 118 - imageUpShift, imgArt.width * imageScale, imgArt.height * imageScale, imgArtMask, false, false)
|
|
}
|
|
card.drawImage(imgArt, 58 - imageLeftShift, 118 - imageUpShift, imgArt.width * imageScale, imgArt.height * imageScale)
|
|
}
|
|
//Draw Border
|
|
function drawBorder() {
|
|
//These if else statements check to see whether or not to draw different parts of the card, like the legendary border or rare stamp, and draws them in the appropriate order such that when multiple border colors are used the gradients overlap correctly
|
|
//MAIN CARD FRAME
|
|
drawMask(imgBorderColor, 0, 0, canvas.width, canvas.height, imgFrameMask, false, false)
|
|
if (secondColor == true) {
|
|
drawMask(imgSecondBorderColor, 0, 0, canvas.width, canvas.height, imgFrameMask, imgMultiGradient, "reverseSecond")
|
|
}
|
|
if (thirdColor == true) {
|
|
drawMask(imgThirdBorderColor, 0, 0, canvas.width, canvas.height, imgFrameMask, imgMultiMask, false)
|
|
}
|
|
//Draws the silver border usually on un-cards
|
|
if (document.getElementById("checkboxSilverBorder").checked == true) {
|
|
drawMask("#a3aeb7", 0, 0, canvas.width, canvas.height, imgBorderMask, imgFrameMask, "reverseSecond")
|
|
}
|
|
//RARE STAMP
|
|
if (document.getElementById("checkboxRareStamp").checked == true && stampBorder == true) {
|
|
card.drawImage(imgBorderRareStamp, 329, rareStampY - 15, 90, 50)
|
|
|
|
if (document.getElementById("checkboxSecondColor").checked == true) {
|
|
drawMask(imgSecondBorderRareStamp, 329, rareStampY - 15, 90, 50, imgSecondBorderRareStamp, imgStampGradient, "reverseSecond")
|
|
}
|
|
//Draws over the rare stamp (part that's usually back) to match custom border color
|
|
drawMask(document.getElementById("inputColor").value, 329, rareStampY - 15, 90, 50, imgRareStampMask, false, false)
|
|
//This is when the holo stamp is drawn
|
|
card.drawImage(imgRareStamp, 340, rareStampY, 70, 37)
|
|
}
|
|
//NYX
|
|
if (document.getElementById("checkboxNyx").checked == true && nyxBorder == true) {
|
|
if (thirdColor == true) {
|
|
drawMask(imgBorderNyx, 0, 0, canvas.width, canvas.height, imgFrameMask, imgMultiMask, false)
|
|
} else {
|
|
drawMask(imgBorderNyx, 0, 0, canvas.width, canvas.height, imgFrameMask, false, false)
|
|
if (secondColor == true) {
|
|
drawMask(imgSecondBorderNyx, 0, 0, canvas.width, canvas.height, imgFrameMask, imgMultiGradient, "reverseSecond")
|
|
}
|
|
}
|
|
}
|
|
//MIRACLE
|
|
if (document.getElementById("checkboxMiracle").checked == true && miracleBorder == true) {
|
|
if (thirdColor == true) {
|
|
drawMask(imgBorderMiracle, 0, 0, canvas.width, canvas.height, imgFrameMask, false, false)
|
|
} else {
|
|
drawMask(imgBorderMiracle, 0, 0, canvas.width, canvas.height, imgFrameMask, false, false)
|
|
if (secondColor == true) {
|
|
drawMask(imgSecondBorderMiracle, 0, 0, canvas.width, canvas.height, imgFrameMask, imgMultiGradient, "reverseSecond")
|
|
}
|
|
}
|
|
}
|
|
//LEGENDARY
|
|
if (document.getElementById("checkboxLegendary").checked == true && legendaryBorder == true) {
|
|
drawMask(imgBorderLegendary, 0, 0, canvas.width, canvas.height, imgLegendFrameMask, false, false)
|
|
if (secondColor == true) {
|
|
drawMask(imgSecondBorderLegendary, 0, 0, canvas.width, canvas.height, imgLegendFrameMask, imgMultiGradient, "reverseSecond")
|
|
}
|
|
//redraws the custom-color border to match the legendary frame
|
|
drawMask(document.getElementById("inputColor").value, 0, 0, canvas.width, canvas.height, imgBorderMask, imgLegendFrameMask, "reverseSecond")
|
|
//redraws the silver border usually on un-cards to match the legendary frame
|
|
if (document.getElementById("checkboxSilverBorder").checked == true) {
|
|
drawMask("#a3aeb7", 0, 0, canvas.width, canvas.height, imgBorderMask, imgLegendFrameMask, "reverseSecond")
|
|
}
|
|
}
|
|
//FLIP CARDS
|
|
if (flipBorder == true) {
|
|
if (document.getElementById("checkboxFlippedDark").checked == true && flipBorder == true) {
|
|
if (thirdColor == true) {
|
|
drawMask(imgBorderFlippedDark, 0, 0, canvas.width, canvas.height, imgFrameMask, false, false)
|
|
} else {
|
|
drawMask(imgBorderFlippedDark, 0, 0, canvas.width, canvas.height, imgFrameMask, false, false)
|
|
if (secondColor == true) {
|
|
drawMask(imgSecondBorderFlippedDark, 0, 0, canvas.width, canvas.height, imgSecondBorderFlippedDark, imgMultiGradient, "reverseSecond")
|
|
}
|
|
}
|
|
}
|
|
if (document.getElementById("checkboxFlipIcon").checked == true) {
|
|
card.drawImage(imgBorderFlipCircle, 0, 0, canvas.width, canvas.height)
|
|
card.drawImage(imgBorderFlipIcon, 39, 51, 60, 60)
|
|
}
|
|
if (document.getElementById("checkboxFlipTip").checked == true) {
|
|
card.drawImage(imgBorderFlipTip, 0, 0, canvas.width, canvas.height)
|
|
card.fillStyle="#666"
|
|
canvas.style.letterSpacing = "0px"
|
|
card.font = "28px belerenb"
|
|
card.fillText(document.getElementById("inputFlipTip").value, 688 - card.measureText(document.getElementById("inputFlipTip").value).width, 880)
|
|
}
|
|
if (document.getElementById("checkboxFlipIcon").checked == true || document.getElementById("checkboxFlippedDark").checked == true) {
|
|
titleRightShift = 50
|
|
} else {
|
|
titleRightShift = 0
|
|
}
|
|
}
|
|
}
|
|
//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) {
|
|
var height = setSymbolHeight
|
|
var width = imgSetSymbol.width * (height / imgSetSymbol.height)
|
|
if (width > setSymbolWidth) {
|
|
width = setSymbolWidth
|
|
height = imgSetSymbol.height * (width / imgSetSymbol.width)
|
|
}
|
|
height *= document.getElementById("setSymbolSize").value / 100
|
|
width *= document.getElementById("setSymbolSize").value / 100
|
|
var y = setSymbolY - height / 2
|
|
var x = setSymbolRight - width
|
|
card.drawImage(imgSetSymbol, x, y, width, height)
|
|
}
|
|
}
|
|
//Draw Watermark
|
|
function drawWatermark() {
|
|
//The watermark is centered/scaled just like the set symbol
|
|
if (imgWatermark.src != "" && document.getElementById("checkboxWatermark").checked == true) {
|
|
var height = watermarkHeight
|
|
var width = imgWatermark.width * (height / imgWatermark.height)
|
|
if (width > watermarkWidth) {
|
|
width = watermarkWidth
|
|
height = imgWatermark.height * (width / imgWatermark.width)
|
|
}
|
|
var x = canvas.width / 2 - width / 2
|
|
var y = watermarkY - height / 2
|
|
//globalAlpha insures that the watermark is drawn partially transparent. This value may not be perfect but the watermark colors are calibrated to it
|
|
card.globalAlpha = 0.4
|
|
//if the following if statement is true, the watermark will be drawn in two halves of the chosen colors. Otherwise, a single watermark of the first chosen color is drawn.
|
|
if (document.getElementById("checkboxSecondWatermarkColor").checked == true) {
|
|
drawMask(document.getElementById("watermarkColorSelection").value, x, y, width, height, imgWatermark, imgMultiGradient, false)
|
|
drawMask(document.getElementById("secondWatermarkColorSelection").value, x, y, width, height, imgWatermark, imgMultiGradient, "reverseSecond")
|
|
} else {
|
|
drawMask(document.getElementById("watermarkColorSelection").value, x, y, width, height, imgWatermark, false, false)
|
|
}
|
|
card.globalAlpha = 1
|
|
}
|
|
}
|
|
//Mana cost
|
|
function drawManaCost() {
|
|
//the symbols string splits the mana cost input into an array of strings which is then put into a for loop that draws the appropriate set symbol then adjusts the xShift so the set symbols are spaced properly
|
|
card.fillStyle = "Black"
|
|
var symbols = document.getElementById("inputCost").value.split(" ")
|
|
var xShift = 0
|
|
for (n = symbols.length; n > -1; n--) {
|
|
if (manaSymbolCode.indexOf(symbols[n]) != -1) {
|
|
card.beginPath()
|
|
card.arc(manaCostX + xShift + manaCostRadius - 1, manaCostY + manaCostRadius + 3.5, manaCostRadius, 0, 6.29, false)
|
|
card.fill()
|
|
card.drawImage(manaSymbolImages[manaSymbolCode.indexOf(symbols[n])], manaCostX + xShift, manaCostY, manaCostRadius * 2, manaCostRadius * 2)
|
|
xShift -= 39
|
|
}
|
|
}
|
|
}
|
|
//Write Text
|
|
function writeText() {
|
|
//Draws the entered text onto the card, also draws the power/toughness box if necessary
|
|
//All use these:
|
|
card.textBaseline = "top"
|
|
if (flipBorder == true && document.getElementById("checkboxFlippedDark").checked == true) {
|
|
card.fillStyle = "White"
|
|
} else {
|
|
card.fillStyle = "Black"
|
|
}
|
|
//Title
|
|
canvas.style.letterSpacing = titleFontSpacing
|
|
card.font = titleFont
|
|
card.fillText(document.getElementById("inputName").value, titleX + titleRightShift, titleY)
|
|
//Type
|
|
canvas.style.letterSpacing = typeFontSpacing
|
|
card.font = typeFont
|
|
card.fillText(document.getElementById("inputType").value, typeX, typeY)
|
|
card.fillStyle = "Black"
|
|
//Rules Text
|
|
canvas.style.letterSpacing = textFontSpacing + "px"
|
|
card.font = document.getElementById("textSize").value + textFont
|
|
var text = document.getElementById("inputText").value
|
|
drawText(text, textX, textY)
|
|
//Power/Toughness
|
|
if (document.getElementById("checkboxCreature").checked == true) {
|
|
card.drawImage(imgBorderCreature, ptX, ptY, ptWidth, ptHeight)
|
|
canvas.style.letterSpacing = ptFontSpacing
|
|
card.font = ptFont
|
|
powerToughness = document.getElementById("inputPowerToughness").value
|
|
card.fillText(powerToughness, ptTextX - (card.measureText(powerToughness).width / 2), ptTextY)
|
|
}
|
|
}
|
|
//Bottom info on M15 cards
|
|
function bottomInfoM15() {
|
|
if (document.getElementById("checkboxArtistColor").checked == true) {
|
|
card.fillStyle = "black"
|
|
} else {
|
|
card.fillStyle = "white"
|
|
}
|
|
var shiftInfo = 442
|
|
canvas.style.letterSpacing = "0.8px"
|
|
card.font = "19.5px relaymedium"
|
|
var bottomLine = document.getElementById("inputSet").value + " \u00b7 " + document.getElementById("inputLanguage").value
|
|
card.fillText(bottomLine, 48, m15InfoY)
|
|
var artistBrushShift = card.measureText(bottomLine).width + 58
|
|
drawMask(card.fillStyle, artistBrushShift, m15InfoY + 5, 21, 13, imgArtistBrush, false, false)
|
|
canvas.style.letterSpacing = "1.3px"
|
|
card.font = "19.5px relaymedium"
|
|
card.fillText(document.getElementById("inputNumber").value, 49, m15InfoY - 20)
|
|
card.fillText(document.getElementById("inputRarity").value, artistBrushShift - 1, m15InfoY - 20)
|
|
if (442 < artistBrushShift + card.measureText(document.getElementById("inputRarity").value).width && document.getElementById("checkboxCreature").checked == false) {
|
|
shiftInfo = artistBrushShift + card.measureText(document.getElementById("inputRarity").value).width + 5
|
|
}
|
|
canvas.style.letterSpacing = "-0.1px"
|
|
card.font = "24px matrixbsc"
|
|
card.fillText(document.getElementById("inputArtist").value, artistBrushShift + 21, m15InfoY + 2)
|
|
if (442 < artistBrushShift + 21 + card.measureText(document.getElementById("inputArtist").value).width && document.getElementById("checkboxCreature").checked == true) {
|
|
shiftInfo = artistBrushShift + card.measureText(document.getElementById("inputArtist").value).width + 26
|
|
}
|
|
//This is where "CC —" is hardcoded. The only reason is to prevent users from easily typing in the trademark and copyright that's usually on real cards. It's also there so I can see if a card was created with my program, it makes me feel good :)
|
|
if (document.getElementById("inputInfo").value != "") {
|
|
canvas.style.letterSpacing = "0px"
|
|
card.font = "17px mplantin"
|
|
var bottomInfo = "CC \u2014 " + document.getElementById("inputInfo").value
|
|
if (bottomInfo == "CC \u2014 secretcode") {
|
|
var date = new Date()
|
|
var year = date.getFullYear()
|
|
bottomInfo = "\u2122 & \u00a9 " + year + " Wizards of the Coast"
|
|
}
|
|
if (document.getElementById("checkboxCreature").checked == true) {
|
|
card.fillText(bottomInfo, shiftInfo, m15InfoY + 3)
|
|
} else {
|
|
card.fillText(bottomInfo, shiftInfo, m15InfoY - 17)
|
|
}
|
|
}
|
|
}
|
|
//Bottom info on 8th edition cards
|
|
function bottomInfo8th() {
|
|
if (document.getElementById("checkboxArtistColor").checked == true) {
|
|
card.fillStyle = "black"
|
|
} else {
|
|
card.fillStyle = "white"
|
|
}
|
|
canvas.style.letterSpacing = "1px"
|
|
card.font = "25px matrixb"
|
|
card.fillText(document.getElementById("inputArtist").value, 116, eighthInfoY)
|
|
canvas.style.letterSpacing = "0.5px"
|
|
card.font = "16px mplantin"
|
|
card.fillText("CC \u2014 " + document.getElementById("inputInfo").value + " " + document.getElementById("inputNumber").value, 62, eighthInfoY + 31)
|
|
}
|
|
//Write the rules and flavor text!
|
|
function drawText(text, xCoord, yCoord) {
|
|
var x = xCoord
|
|
var lineSpace = parseInt(document.getElementById("textShift").value, 10)
|
|
var textSize = parseInt(document.getElementById("textSize").value, 10)
|
|
var y = yCoord + parseInt(document.getElementById("textDown").value, 10)
|
|
var textXShift = 0
|
|
var words = (text).split(" ")
|
|
var line = ""
|
|
var tempTextWidth = textWidth
|
|
for (wordIndex = 0; wordIndex < words.length; wordIndex ++) {
|
|
if (words[wordIndex].includes("<") == false || words[wordIndex].includes(">") == false) {
|
|
//Just a regular old word
|
|
testLine = line + words[wordIndex]
|
|
var lineWidth = card.measureText(testLine).width
|
|
if (lineWidth + textXShift + x > tempTextWidth && wordIndex > 0) {
|
|
//Word is too big
|
|
card.fillText(line, x + textXShift, y)
|
|
line = words[wordIndex] + " "
|
|
y += textSize + 1
|
|
textXShift = 0
|
|
} else {
|
|
//Word fits
|
|
line = testLine + " "
|
|
}
|
|
if (wordIndex + 1 == words.length) {
|
|
card.fillText(line, x + textXShift, y)
|
|
}
|
|
} else {
|
|
//Symbols and more!
|
|
var splitWord = words[wordIndex].split("<")
|
|
for (splitIndex = 0; splitIndex < splitWord.length; splitIndex ++) {
|
|
//Write what's there first!
|
|
card.fillText(line, x + textXShift, y)
|
|
textXShift += card.measureText(line).width
|
|
line = ""
|
|
if (splitWord[splitIndex].includes(">")) {
|
|
var plainWord = ""
|
|
var megaSplit = splitWord[splitIndex].split(">")
|
|
//series of if statements to determine an action based off of the given code
|
|
if (megaSplit[0] == "i") {
|
|
canvas.style.letterSpacing = textFontSpacing * 1/3 + "px"
|
|
card.font = textSize + textFont + "i"
|
|
} else if (megaSplit[0] == "/i") {
|
|
canvas.style.letterSpacing = textFontSpacing + "px"
|
|
card.font = "normal " + textSize + textFont
|
|
} else if (megaSplit[0] == "center") {
|
|
card.textAlign="center"
|
|
x = 749/2
|
|
tempTextWidth = textWidth * 1.5
|
|
} else if (megaSplit[0] == "right") {
|
|
card.textAlign="right"
|
|
tempTextWidth = textWidth * 1.9
|
|
x = 749 - xCoord
|
|
} else if (megaSplit[0] == "left") {
|
|
card.textAlign="left"
|
|
tempTextWidth = textWidth
|
|
x = xCoord
|
|
} else if (megaSplit[0] == "line") {
|
|
textXShift = 0
|
|
y += lineSpace + textSize + 1
|
|
} else if (megaSplit[0] == "lineNoSpace") {
|
|
textXShift = 0
|
|
y += textSize + 1
|
|
} else if (megaSplit[0] == "bar") {
|
|
card.drawImage(imgBar, canvas.width / 2 - imgBar.width / 2, y + textSize + lineSpace + 5)
|
|
textXShift = 0
|
|
y += 2 * lineSpace + textSize + 3
|
|
} else {
|
|
card.drawImage(manaSymbolImages[manaSymbolCode.indexOf(megaSplit[0])], x + textXShift + textSize * 0.054, y + textSize * 0.19, textSize * 0.77, textSize * 0.77)
|
|
textXShift += textSize * 0.84
|
|
}
|
|
if (megaSplit[1] != "") {
|
|
plainWord = megaSplit[1] + " "
|
|
} else if (splitIndex == splitWord.length - 1) {
|
|
line += " "
|
|
}
|
|
} else {
|
|
plainWord = splitWord[splitIndex]
|
|
}
|
|
if (plainWord != "") {
|
|
//After isolating the plain word, write it!
|
|
testLine = line + plainWord
|
|
var lineWidth = card.measureText(testLine).width
|
|
if (lineWidth + textXShift + x > tempTextWidth && wordIndex > 0) {
|
|
//Word is too big
|
|
card.fillText(line, x + textXShift, y)
|
|
line = plainWord
|
|
y += textSize + 1
|
|
textXShift = 0
|
|
} else {
|
|
//Word fits
|
|
line = testLine
|
|
}
|
|
if (wordIndex + 1 == words.length) {
|
|
card.fillText(line, x + textXShift, y)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//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++) {
|
|
var targetChild = target.parentElement.parentElement.childNodes[i].childNodes[3]
|
|
if (targetChild != undefined && targetChild.classList.contains("shown") == true) {
|
|
targetChild.classList.toggle("shown")
|
|
}
|
|
}
|
|
target.parentElement.childNodes[3].classList.toggle("shown")
|
|
}
|
|
|
|
//Resizes anything that may need to be resized
|
|
function resizeThings() {
|
|
if (window.innerWidth > 1100) {
|
|
document.getElementById("optionsColumn").style = "width: calc(100% - 777px)"
|
|
} else {
|
|
document.getElementById("optionsColumn").style = "width: 100%"
|
|
}
|
|
}
|
|
|
|
//runs the autocrop function for the chosen set symbol
|
|
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"
|
|
}
|
|
|
|
//Best for last - downloads the image!
|
|
function downloadCardImage(el) {
|
|
alert("This may not work because the canvas is 'tainted' - if you know how to avoid this please tell me")
|
|
var cardImageData = canvas.toDataURL()
|
|
el.href = cardImageData
|
|
}
|
|
</script>
|
|
<html>
|