optimized drawing the image

This commit is contained in:
Václav Šmejkal 2023-05-16 15:15:23 +02:00
parent b895548bda
commit d03e9d5519
Signed by: ENGO150
GPG Key ID: F6D6DF86242C5A59

View File

@ -1,17 +1,15 @@
function load_panorama()
{
console.log(window.width);
var ctx = document.getElementById('panorama').getContext('2d');
var img = new Image();
var width_buffer;
let ctx = document.getElementById('panorama').getContext('2d');
let img = new Image();
const width = 5000;
ctx.canvas.width = width;
ctx.canvas.height = width / 2;
img.onload = function()
{
width_buffer = 5000;
ctx.canvas.width=width_buffer;
ctx.canvas.height=width_buffer / 2;
ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, width_buffer, width_buffer / 2);
ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, width, width / 2);
};
img.src = './res/img/test.jpg';