Last active
April 5, 2017 16:56
-
-
Save msfeldstein/c92f8f5005310275d7ffc60707a19845 to your computer and use it in GitHub Desktop.
console.image
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
/** | |
* Modified version of something Dubiously created by Adrian Cooney | |
* http://adriancooney.github.io | |
* adapted from https://github.com/adriancooney/console.snapshot | |
*/ | |
(function(console) { | |
function getBox(width, height) { | |
return { | |
string: "+", | |
style: "font-size: 1px; padding: " + Math.floor(height/2) + "px " + Math.floor(width/2) + "px; line-height: " + height + "px;" | |
} | |
} | |
/** | |
* Display an image in the console. | |
* @param {string} url base64 url of image | |
*/ | |
console.image = function(url, width, height) { | |
var dim = getBox(width, height); | |
console.log("%c" + dim.string, dim.style + "background: url(" + url + "); background-size: " + (width) + "px " + (height) + "px; color: transparent;"); | |
}; | |
})(console); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment