From 5949e057f025e2ece5e58d61cb3748ff252ee7db Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Tue, 16 May 2023 21:52:42 +0200 Subject: [PATCH] made turn_left working (sorta) I need to make it infinite, the it will be perfect --- res/script.js | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/res/script.js b/res/script.js index 644bbd6..822a5cf 100644 --- a/res/script.js +++ b/res/script.js @@ -1,16 +1,38 @@ +const WIDTH = 1000; +const ASPECT_RATIO = 1/2; + +//CANVAS SHIT +let ctx; +let canvas; +let img; //THE PANORAMA IMAGE + +//CURRENT IMAGE STATE +let x1 = WIDTH / 2; +let x2; + function load_panorama() { - let ctx = document.getElementById('panorama').getContext('2d'); - let img = new Image(); - const width = 5000; + canvas = document.getElementById('panorama'); + ctx = canvas.getContext('2d'); + img = new Image(); //IMAGE - ctx.canvas.width = width; - ctx.canvas.height = width / 2; + ctx.canvas.height = WIDTH / 2; + ctx.canvas.width = WIDTH / 2; img.onload = function() { - ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, width, width / 2); + x2 = img.width; + ctx.drawImage(img, x1, 0, x2, img.height, 0, 0, WIDTH, WIDTH * ASPECT_RATIO); //DRAW A HALF OF img }; img.src = './res/img/test.jpg'; +} + +function turn_left() //TODO: MOVE THE RIGHT PART TO LEFT +{ + //MOVE AN 8th TO LEFT + x1 -= WIDTH / 8; + x2 -= WIDTH / 8; + + ctx.drawImage(img, x1, 0, img.width - WIDTH / 8, img.height, 0, 0, WIDTH, WIDTH * ASPECT_RATIO); //DRAW } \ No newline at end of file