MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/jqv3dn/deleted_by_user/gd86n6b/?context=3
r/badcode • u/[deleted] • Nov 09 '20
[removed]
31 comments sorted by
View all comments
1
<!DOCTYPE html> <html><body><script> function LoadImage() { const request = new XMLHttpRequest(); request.onload = function() { const container = document.createElement("div"); container.style = "position: relative;"; document.body.appendChild(container); request.responseText.split(/\n/g).filter(line => line.length).forEach((line, lineIndex) => line.match(/(\[.*?\])/g).forEach((pixel, pixelIndex) => DrawPixel("#" + pixel.match(/[^\[\],]+/g).map(numberStr => numberStr.split("").reduce((prev, curr) => prev * 10 + + curr)).map(pixel => pixel.toString(16).padStart(2, "0")).join(""), lineIndex, pixelIndex, container))); }; request.open("GET", "https://gist.githubusercontent.com/Vusys/94fa0db1bb6ed4a61068233f27858382/raw/f04aaf13a14505cfaed5a6ec37a5e30c85dff377/pikachu.txt"); request.send(); } function DrawPixel(color, lineIndex, pixelIndex, container) { const canvas = document.createElement("canvas"); canvas.height = canvas.width = 2; const ctx = canvas.getContext("2d"); ctx.fillStyle = color; ctx.fillRect(0, 0, 2, 2); const image = new Image(); image.src = canvas.toDataURL(); image.style = "position: absolute; top: " + (lineIndex << 1) + "px; left: " + (pixelIndex << 1) + "px;"; container.appendChild(image); } LoadImage(); </script></body></html>
Save this as an html file, and open it in a browser to see the result!
Features:
View all comments
1
u/Kimbatt Nov 22 '20
Save this as an html file, and open it in a browser to see the result!
Features: