Created
May 12, 2022 23:00
-
-
Save idiomatic/366f99d3f928d1fd242816303f19c6a0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
console.image = function(url, scale) { | |
scale = scale || 1; | |
var img = new Image(); | |
img.onload = function() { | |
const width = this.width * scale; | |
const height = this.height * scale; | |
console.log("%c+", `font-size:1px; padding:${Math.floor(height/2)}px ${Math.floor(width/2)}px; line-height:${height}px; background: url(${url}); background-size:${width}px ${height}px; color: transparent;`); | |
}; | |
img.src = url; | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment