Created
October 28, 2013 12:08
-
-
Save kozie/7195761 to your computer and use it in GitHub Desktop.
Create Blue Transparent Base64 Img URL
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
var e = document.createElement("canvas") | |
var c = e.getContext("2d"); | |
e.width = 1 | |
e.height = 1 | |
var d = c.getImageData(0, 0, 1, 1); | |
d.data[0] = 0; // R | |
d.data[1] = 92; // G | |
d.data[2] = 170; // B | |
d.data[3] = 222; // A | |
c.putImageData(d, 0, 0, 0, 0, 1, 1) | |
e.toDataURL() | |
// "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQIW2NkiFl1DwADUAHmsr7HFwAAAABJRU5ErkJggg==" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment