optimized drawing the image
This commit is contained in:
parent
b895548bda
commit
d03e9d5519
@ -1,17 +1,15 @@
|
|||||||
function load_panorama()
|
function load_panorama()
|
||||||
{
|
{
|
||||||
console.log(window.width);
|
let ctx = document.getElementById('panorama').getContext('2d');
|
||||||
var ctx = document.getElementById('panorama').getContext('2d');
|
let img = new Image();
|
||||||
var img = new Image();
|
const width = 5000;
|
||||||
var width_buffer;
|
|
||||||
|
ctx.canvas.width = width;
|
||||||
|
ctx.canvas.height = width / 2;
|
||||||
|
|
||||||
img.onload = function()
|
img.onload = function()
|
||||||
{
|
{
|
||||||
width_buffer = 5000;
|
ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, width, width / 2);
|
||||||
|
|
||||||
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);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
img.src = './res/img/test.jpg';
|
img.src = './res/img/test.jpg';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user