mirror of
https://github.com/Investigamer/cardconjurer.git
synced 2025-07-26 21:04:58 -05:00
better svgs
This commit is contained in:
@@ -175,7 +175,7 @@
|
||||
<div class="autoGrid">
|
||||
<input type="file" accept="image/*" onchange="uploadImage(event, watermark)" placeholder="Via File Upload">
|
||||
<input type="text" placeholder="Via URL" onchange="watermark.src = 'https://cors-anywhere.herokuapp.com/' + this.value">
|
||||
<input type="text" placeholder="Via Set Code" onchange="watermark.src = 'https://cors-anywhere.herokuapp.com/http://gatherer.wizards.com/Handlers/Image.ashx?type=symbol&set=' + this.value + '&size=large'">
|
||||
<input type="text" placeholder="Via Set Code" onchange="cropSVG(this.value, watermark)">
|
||||
<select id="inputWatermarkPrimary" onchange="watermarkUpdated()">
|
||||
<option value="none">None</option>
|
||||
<option value="default">Default</option>
|
||||
|
@@ -1103,6 +1103,25 @@ function artistNameUpdated(artistName) {
|
||||
bottomInfoUpdated()
|
||||
}
|
||||
|
||||
//svg cropper
|
||||
function cropSVG(set, targetImage) {
|
||||
xhttp = new XMLHttpRequest()
|
||||
xhttp.open('GET', 'https://raw.githubusercontent.com/andrewgioia/keyrune/4073ac89bb943978c29be504275e6f3160a07255/svg/' + set + '.svg', true)
|
||||
xhttp.overrideMimeType('image/svg+xml')
|
||||
xhttp.onload = function(event) {
|
||||
if (this.readyState == 4 && this.status == 200) {
|
||||
var svg = document.body.appendChild(xhttp.responseXML.documentElement)
|
||||
var box = svg.getBBox(svg)
|
||||
svg.setAttribute('viewBox', [box.x, box.y, box.width, box.height].join(' '))
|
||||
svg.setAttribute('width', box.width)
|
||||
svg.setAttribute('height', box.height)
|
||||
targetImage.src = 'data:image/svg+xml,'+encodeURIComponent(svg.outerHTML)
|
||||
svg.remove()
|
||||
}
|
||||
}
|
||||
xhttp.send()
|
||||
}
|
||||
|
||||
//Must run last:
|
||||
initialize()
|
||||
|
||||
|
Reference in New Issue
Block a user