added aspect ratio to every point

This commit is contained in:
Václav Šmejkal 2023-05-28 16:16:56 +02:00
parent 7b88652257
commit d56cda9572
Signed by: ENGO150
GPG Key ID: 4A57E86482968843
2 changed files with 13 additions and 10 deletions

View File

@ -75,12 +75,15 @@ function check_param()
{ {
let params = new URLSearchParams(window.location.search); let params = new URLSearchParams(window.location.search);
img_url = params.get("img"); img_url = params.get("img");
x = params.get("aspect_x");
y = params.get("aspect_y");
if (img_url == null) if (img_url == null || x == null || y == null)
{ {
alert("This link seems to be corrupted!"); alert("This link seems to be corrupted!");
open("../index.html", "_self"); open("../index.html", "_self");
} }
img_url = 'http://207.180.212.190/fht/fabrika_imgs/' + img_url + '.jpg'; //TODO: Change img_url = 'http://207.180.212.190/fht/fabrika_imgs/' + img_url + '.jpg'; //TODO: Change
ASPECT_RATIO = x / y;
} }

View File

@ -1,6 +1,6 @@
const points = const points =
[ [
[1240, 625, "1;2"] [1240, 625, "1;2", 9, 16]
]; ];
const tolerance = 3; const tolerance = 3;
@ -16,30 +16,30 @@ window.onload = function()
{ {
if if
( (
(Math.abs(x - points[i][0]) <= tolerance || -Math.abs(x - points[i][0]) >= tolerance) && ((Math.abs(x - points[i][0]) <= tolerance || -Math.abs(x - points[i][0]) >= tolerance) &&
(Math.abs(y - points[i][1]) <= tolerance || -Math.abs(y - points[i][1]) >= tolerance) (Math.abs(y - points[i][1]) <= tolerance || -Math.abs(y - points[i][1]) >= tolerance))
) )
{ {
move(points[i][2]); move(points[i][2], points[i][3], points[i][4]);
break; break;
} }
} }
} }
} }
function open_panorama(img) function open_panorama(img, x, y)
{ {
open("./res/panorama.html?img=" + img, "_self"); open("./res/panorama.html?img=" + img + "&aspect_x=" + x + "&aspect_y=" + y, "_self");
} }
function move(img) function move(img, x, y)
{ {
if (!img.includes(";")) if (!img.includes(";"))
{ {
open_panorama(img); open_panorama(img, x, y);
} else } else
{ {
let imgs = img.split(";"); let imgs = img.split(";");
open_panorama(imgs[Math.floor(Math.random() * imgs.length)]); open_panorama(imgs[Math.floor(Math.random() * imgs.length)], x, y);
} }
} }