From b895548bda61f0693fbaee88f4694386c2d1913d Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Tue, 16 May 2023 15:13:10 +0200 Subject: [PATCH] drawing test image into canvas (full) idk if I won't remake this somehow differently --- index.html | 5 ++++- res/script.js | 16 +++++++++++++++- res/style.css | 11 ++++++++++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 869db54..b0d0d65 100644 --- a/index.html +++ b/index.html @@ -5,11 +5,14 @@ + Fabrika Hrádek Tour -
+
+ This browser doesn't seem to support canvas. sorry idk +
\ No newline at end of file diff --git a/res/script.js b/res/script.js index 20d1990..7d85c7b 100644 --- a/res/script.js +++ b/res/script.js @@ -1,4 +1,18 @@ function load_panorama() { - document.getElementById("panorama").style.backgroundImage = "./img/test.jpg" //NOT WORKING + console.log(window.width); + var ctx = document.getElementById('panorama').getContext('2d'); + var img = new Image(); + var width_buffer; + + 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); + }; + + img.src = './res/img/test.jpg'; } \ No newline at end of file diff --git a/res/style.css b/res/style.css index 1dc2acb..cab738e 100644 --- a/res/style.css +++ b/res/style.css @@ -1 +1,10 @@ -/*stuff*/ \ No newline at end of file +#panorama +{ + display: inline; +} + +#panorama_div +{ + width: 100%; + text-align:center; +} \ No newline at end of file