mana symbol improvements

This commit is contained in:
Kyle
2021-03-01 13:36:17 -08:00
parent 089cd9b150
commit d3cda1efe4
3 changed files with 78 additions and 0 deletions

View File

@@ -569,6 +569,7 @@ function writeText(textObject, targetContext) {
var textShadowOffsetY = scaleHeight(textObject.shadowY) || 0;
var textShadowBlur = scaleHeight(textObject.shadowBlur) || 0;
var textArcRadius = scaleHeight(textObject.arcRadius) || 0;
var manaSymbolColor = textObject.manaSymbolColor || null;
if (textArcRadius > 0) {
//Buffers the canvases accordingly
var canvasMargin = 300 + textArcRadius;
@@ -725,6 +726,8 @@ function writeText(textObject, targetContext) {
textArcRadius = parseInt(possibleCode.replace('arcradius', '')) || 0;
} else if (possibleCode.includes('arcstart')) {
textArcStart = parseFloat(possibleCode.replace('arcstart', '')) || 0;
} else if (possibleCode.includes('manacolor')) {
manaSymbolColor = possibleCode.replace('manacolor', '') || 'white';
} else if (possibleCode.includes('fixtextalign')) {
textAlign = realTextAlign;
} else if (findManaSymbolIndex(possibleCode.replace('/', '')) > -1 || findManaSymbolIndex(possibleCode.replace('/', '').split('').reverse().join('')) > -1) {
@@ -784,6 +787,8 @@ function writeText(textObject, targetContext) {
fakeShadowContext.drawImageArc(backImage, manaSymbolX, manaSymbolY, manaSymbolWidth, manaSymbolHeight, textArcRadius, textArcStart, currentX);
}
fakeShadowContext.drawImageArc(manaSymbol.image, manaSymbolX, manaSymbolY, manaSymbolWidth, manaSymbolHeight, textArcRadius, textArcStart, currentX);
} else if (manaSymbolColor) {
fakeShadowContext.fillImage(manaSymbol.image, manaSymbolX, manaSymbolY, manaSymbolWidth, manaSymbolHeight, manaSymbolColor);
} else {
if (manaSymbol.backs) {
fakeShadowContext.drawImage(backImage, manaSymbolX, manaSymbolY, manaSymbolWidth, manaSymbolHeight);
@@ -869,12 +874,26 @@ CanvasRenderingContext2D.prototype.drawImageArc = function(image, x, y, width, h
this.drawImage(image, 0, -radius, width, height);
this.restore();
}
CanvasRenderingContext2D.prototype.fillImage = function(image, x, y, width, height, color = 'white', margin = 10) {
var canvas = document.createElement('canvas');
canvas.width = width + margin * 2;
canvas.height = height + margin * 2;
var context = canvas.getContext('2d');
context.drawImage(image, margin, margin, width, height);
context.globalCompositeOperation = 'source-in';
context.fillStyle = pinlineColors(color);
context.fillRect(0, 0, width + margin * 2, height + margin * 2);
this.drawImage(canvas, x - margin, y - margin, width + margin * 2, height + margin * 2);
}
function widthToAngle(width, radius) {
return width / radius;
}
function curlyQuotes(input) {
return input.replace(/ '/g, ' ').replace(/^'/, '').replace(/' /g, ' ').replace(/'$/, '').replace(/ "/g, ' “').replace(/^"/, '“').replace(/" /g, '” ').replace(/\."/, '”').replace(/"$/, '”');
}
function pinlineColors(color) {
return color.replace('white', '#fcfeff').replace('blue', '#0075be').replace('black', '#272624').replace('red', '#ef3827').replace('green', '#007b43')
}
//ART TAB
function uploadArt(imageSource, otherParams) {
art.src = imageSource;

View File

@@ -0,0 +1,12 @@
//checks to see if it needs to run
if (!card.manaSymbols.includes('/js/frames/manaSymbolsOutline.js')) {
card.manaSymbols.push('/js/frames/manaSymbolsOutline.js');
}
if (findManaSymbolIndex('cw') == -1) {
loadManaSymbols([
'outline/outlinew', 'outline/outlineu', 'outline/outlineb', 'outline/outliner', 'outline/outlineg',
'outline/outlinec', 'outline/outlines', 'outline/outlinex', 'outline/outline0', 'outline/outline1',
'outline/outline2', 'outline/outline3', 'outline/outline4', 'outline/outline5', 'outline/outline6',
'outline/outline7', 'outline/outline8', 'outline/outline9'
]);
}

View File

@@ -0,0 +1,47 @@
//Create objects for common properties across available frames
var masks = [{src:'/img/frames/m15/regular/m15MaskPinline.png', name:'Pinline'}, {src:'/img/frames/m15/regular/m15MaskTitle.png', name:'Title'}, {src:'/img/frames/m15/regular/m15MaskType.png', name:'Type'}, {src:'/img/frames/m15/regular/m15MaskRules.png', name:'Rules'}, {src:'/img/frames/m15/regular/m15MaskFrame.png', name:'Frame'}, {src:'/img/frames/m15/regular/m15MaskBorder.png', name:'Border'}];
var bounds = {x:0.7573, y:0.8848, width:0.188, height:0.0733};
//defines available frames
availableFrames = [
{name:'White Frame', src:'/img/frames/m15/regular/m15FrameW.png', masks:masks},
{name:'Blue Frame', src:'/img/frames/m15/regular/m15FrameU.png', masks:masks},
{name:'Black Frame', src:'/img/frames/m15/regular/m15FrameB.png', masks:masks},
{name:'Red Frame', src:'/img/frames/m15/regular/m15FrameR.png', masks:masks},
{name:'Green Frame', src:'/img/frames/m15/regular/m15FrameG.png', masks:masks},
{name:'Multicolored Frame', src:'/img/frames/m15/regular/m15FrameM.png', masks:masks},
{name:'Artifact Frame', src:'/img/frames/m15/regular/m15FrameA.png', masks:masks},
{name:'Land Frame', src:'/img/frames/m15/regular/m15FrameL.png', masks:masks}
];
//disables/enables the "Load Frame Version" button
document.querySelector('#loadFrameVersion').disabled = false;
//defines process for loading this version, if applicable
document.querySelector('#loadFrameVersion').onclick = async function() {
//resets things so that every frame doesn't have to
await resetCardIrregularities();
//sets card version
card.version = 'mysticalArchive';
loadScript('/js/frames/manaSymbolsOutline.js');
//art bounds
card.artBounds = {x:0, y:0.1129, width:1, height:0.4429};
autoFitArt();
//set symbol bounds
card.setSymbolBounds = {x:0.9213, y:0.5910, width:0.12, height:0.0410, vertical:'center', horizontal: 'right'};
resetSetSymbol();
//watermark bounds
card.watermarkBounds = {x:0.5, y:0.7762, width:0.75, height:0.2305};
resetWatermark();
//text
loadTextOptions({
mana: {name:'Mana Cost', text:'', y:0.0613, width:0.9292, height:71/2100, oneLine:true, size:71/1638, align:'right', manaCost:true, manaSpacing:0, manaPrefix:'outline', manaSymbolColor:'white'},
title: {name:'Title', text:'', x:0.0854, y:0.0522, width:0.8292, height:0.0543, oneLine:true, font:'belerenb', size:0.0381},
type: {name:'Type', text:'', x:0.0854, y:0.5664, width:0.8292, height:0.0543, oneLine:true, font:'belerenb', size:0.0324},
rules: {name:'Rules Text', text:'', x:0.086, y:0.6303, width:0.828, height:0.2875, size:0.0362},
pt: {name:'Power/Toughness', text:'', x:0.7928, y:0.902, width:0.1367, height:0.0372, size:0.0372, font:'belerenbsc', oneLine:true, align:'center'}
});
}
//loads available frames
loadFramePack();
//Only for the main version as the webpage loads:
if (!card.text) {
document.querySelector('#loadFrameVersion').click();
}