Last active
January 31, 2017 16:35
-
-
Save westc/102515dee2c5320691e044886a2256f5 to your computer and use it in GitHub Desktop.
Turn my CW logo into a PNG
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(size) { | |
var data = '\ | |
<svg xmlns="http://www.w3.org/2000/svg" height="' + size + '" width="' + size + '">\ | |
<foreignObject width="100%" height="100%">\ | |
<div xmlns="http://www.w3.org/1999/xhtml">\ | |
<div style="position: absolute;\ | |
margin: 0.2em;\ | |
font-family: Tahoma;\ | |
font-size: ' + (size * 100 / 260) + 'px;\ | |
font-weight: bold;\ | |
transform: rotate(345deg);\ | |
color: #6CF;\ | |
background-color: #036;\ | |
text-align: center;\ | |
border-radius: 2em;\ | |
height: 2em;\ | |
line-height: 2em;\ | |
display: inline-block;\ | |
width: 2em;\ | |
padding: 0.1em;\ | |
box-shadow: inset 0 0 1em #000, 0 0 0.05em 0.1em #FFF, 0 0 0.1em 0.1em #000;\ | |
">CW</div>\ | |
</div>\ | |
</foreignObject>\ | |
</svg>'; | |
var img = new Image(); | |
img.onload = function() { | |
console.clear(); | |
var canvas = document.createElement('canvas'); | |
canvas.style.height = 0; | |
canvas.height = size; | |
canvas.width = size; | |
document.body.appendChild(canvas); | |
var ctx = canvas.getContext('2d'); | |
ctx.drawImage(img, 0, 0); | |
console.clear(); | |
console.log('Done ' + new Date); | |
location.href = canvas.toDataURL('image/png'); | |
}; | |
img.src = 'data:image/svg+xml;base64,' + window.btoa(data); | |
})(1024); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment