Retina canvas w. resize

Developer
Size
1,882 Kb
Views
38,456

How do I make an retina canvas w. resize?

What is a retina canvas w. resize? How do you make a retina canvas w. resize? This script and codes were developed by Erik Terwan on 04 July 2022, Monday.

Retina canvas w. resize Previews

Retina canvas w. resize - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Retina canvas w. resize</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <canvas id="canvas"></canvas> <script src="js/index.js"></script>
</body>
</html>

Retina canvas w. resize - Script Codes CSS Codes

body
{ background: #000; overflow: hidden;
}
canvas
{ width: 100%; height: 100%; position: absolute; left: 0; top: 0;
}

Retina canvas w. resize - Script Codes JS Codes

(function(){ var canvas = document.getElementById('canvas'), ctx = canvas.getContext('2d'), w = canvas.width = window.innerWidth, h = canvas.height = window.innerHeight, density = 1; function setup() { window.addEventListener('resize', resize); density = window.devicePixelRatio != undefined ? window.devicePixelRatio : 1.0; canvas.width = w * density;	canvas.height = h * density;	ctx.scale(density,density); draw(); } function draw() { ctx.fillStyle = '#fff'; ctx.fillRect(50,50,20,20); window.requestAnimationFrame(draw); } function resize() { w = canvas.width = window.innerWidth; h = canvas.height = window.innerHeight; canvas.width = w * density;	canvas.height = h * density; ctx.scale(density, density); } setup();
})();
Retina canvas w. resize - Script Codes
Retina canvas w. resize - Script Codes
Home Page Home
Developer Erik Terwan
Username erikterwan
Uploaded July 04, 2022
Rating 3
Size 1,882 Kb
Views 38,456
Do you need developer help for Retina canvas w. resize?

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!

Erik Terwan (erikterwan) Script Codes
Create amazing Facebook ads with AI!

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!