ASCII art
How do I make an ascii art?
Click to switch between original image and generated ascii . What is a ascii art? How do you make a ascii art? This script and codes were developed by Massimo on 17 September 2022, Saturday.
ASCII art - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>ASCII art</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <img id="image"/>
<canvas id="c"></canvas> <script src="js/index.js"></script>
</body>
</html>
ASCII art - Script Codes CSS Codes
body { margin: 0; overflow: hidden; background: #000;
}
body canvas, body img { position: absolute; left: 50%; top: 50%;
}
ASCII art - Script Codes JS Codes
var c = document.getElementById('c'), c_ = document.createElement('canvas'), ctx = c.getContext('2d'), ctx_ = c_.getContext('2d'), image = document.getElementById('image'), img, original = false, src = "https://images.moviepilot.com/" + "image/upload/c_fill,h_470,q_auto:" + "good,w_620/bnmdox19jjtoondtecuc.jpg", s = { 'scale': 10, 'font size': 10, 'color': '#fff' };
image.src = src;
image.style.display = 'none';
img = new Image();
img.crossOrigin = 'anonymous';
img.src = src;
img.onload = function() { c.width = img.width; c.height = img.height; c.style.marginLeft = image.style.marginLeft = -c.width/2 + 'px'; c.style.marginTop = image.style.marginTop = -c.height/2 + 'px'; c_.width = img.width = c.width / s.scale; c_.height = img.height = c.height / s.scale; draw();
}
function symbol(gs) { var s; if(gs > 230) { s = '.'; } else if(gs > 195) { s = ','; } else if(gs > 170) { s = ';'; } else if(gs > 155) { s = '*'; } else if(gs > 130) { s = 'o'; } else if(gs > 105) { s = '&'; } else if(gs > 80) { s = '8'; } else if(gs > 60) { s = '#'; } else { s = '@'; } return s;
}
function draw() { ctx_.drawImage(img, 0, 0, img.width, img.height); var imgData = ctx_.getImageData(0, 0, c_.width, c_.height), pixels = imgData.data; for(var y = 0; y < c_.height; y++) { for(var x = 0; x < c_.width; x++) { var index = 4*(x + y*c_.width), r = pixels[index + 0], g = pixels[index + 1], b = pixels[index + 2], greyscl = Math.round((r + g + b)/3); var symb = symbol(greyscl); ctx.fillStyle = s.color; ctx.font = s['font size'] + "px Courier New"; ctx.fillText(symb, x*s.scale, y*s.scale); } }
}
c.addEventListener('click', function() { original = !original; if(original) { ctx.clearRect(0, 0, c.width, c.height); image.style.display = 'block'; } else { image.style.display = 'none'; draw(); }
});
Developer | Massimo |
Username | _massimo |
Uploaded | September 17, 2022 |
Rating | 4.5 |
Size | 2,756 Kb |
Views | 56,672 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Pacman | 2,503 Kb |
Css preloader | 3,888 Kb |
Upside down cat | 5,464 Kb |
Bernard the polar bear | 4,070 Kb |
Underwater particles | 3,401 Kb |
Pathfinder | 5,360 Kb |
Css spirals | 5,074 Kb |
Fake 3D | 3,086 Kb |
Mandala drawing concept | 3,474 Kb |
Css tabs | 3,169 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
3d css cube | Semenchenko | 4,578 Kb |
Wikipedia viewer | Chpecson | 2,865 Kb |
RPG Style Text Dialogue | Odylic | 2,635 Kb |
Jstam.com Home Page | Jstam | 10,558 Kb |
Ripples in water | Nobitagit | 2,704 Kb |
Tile Animation Thing | Frxnz | 4,332 Kb |
Carousel Test | Sbirchall | 1,509 Kb |
Flat UI - Checkbox FIX | ARS | 2,663 Kb |
A Pen by Markku Lehmonen | SharpDal | 7,804 Kb |
Fullscreen audio play button | 72 | 2,148 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!