if(Debug.debug) console.log("Loading: ArDetect"); var _ard_console_stop = "background: #000; color: #f41"; var _ard_console_start = "background: #000; color: #00c399"; // global-ish variables var _ard_oldAr; var _ard_currentAr; var _ard_setup_timer; var _ard_timer // kjer vzemamo vzorce za blackbox/stuff. 9 vzorcev. Če spremenimo velikost vzorca, moramo spremeniti tudi vrednosti v tej tabeli // vrednosti v tabeli so na osminskih intervalih od [0, - 4]. // we sample these lines in blackbox/stuff. 9 samples. If we change the canvas sample size, we have to correct these values as well // samples are every eighth between [0, - 4]. var _ard_sampleLines = [ 0, 360, 720, 1080, 1440, 1800, 2160, 2520, 2876]; var _ard_sampleCols = [ 128, 256, 384, 512, 640, 768, 896, 1024, 1125 ]; var _ard_canvasWidth; var _ard_canvasHeight; var _ard_canvasDrawWindowHOffset = 0; // **** FUNCTIONS **** // var _arSetup = function(cwidth, cheight){ if(Debug.debug) console.log("%c[ArDetect::_ard_setup] Starting automatic aspect ratio detection", _ard_console_start); this._halted = false; var existingCanvas = document.getElementById("uw_ArDetect_canvas"); if(existingCanvas){ if(Debug.debug) console.log("[ArDetect::_ard_setup] existing canvas found. REMOVING KEBAB removing kebab\n\n\n\n(im hungry and you're not authorized to have it)"); existingCanvas.remove(); if(Debug.debug) console.log("[ArDetect::_ard_setup] canvas removed"); } var vid = document.getElementsByTagName("video")[0]; if(vid === undefined){ _ard_setup_timer = setTimeout(_arSetup, 1000); return; } // imamo video, pa tudi problem. Ta problem bo verjetno kmalu popravljen, zato setup začnemo hitreje kot prej // we have a video, but also a problem. This problem will prolly be fixed very soon, so setup is called with // less delay than before if(vid.videoWidth === 0 || vid.videoHeight === 0){ _ard_setup_timer = setTimeout(_arSetup, 100); return; } var canvas = document.createElement("canvas"); canvas.style.position = "absolute"; //todo: change those values to push canvas off-screen _ard_canvasWidth = cwidth ? cwidth : Settings.arDetect.hSamples; _ard_canvasHeight = cheight ? cheight : Settings.arDetect.vSamples; if(Debug.showArDetectCanvas){ canvas.style.left = "200px"; canvas.style.top = "780px"; canvas.style.zIndex = 10000; } else{ canvas.style.left = "-20000px"; canvas.style.top = "-1080px"; canvas.style.zIndex = -10000; } canvas.id = "uw_ArDetect_canvas"; var test = document.getElementsByTagName("body")[0]; test.appendChild(canvas); var context = canvas.getContext("2d"); // do setup once // tho we could do it for every frame if(cwidth && cheight){ var canvasWidth = cwidth; var canvasHeight = cheight; var canvasScaleFactor = cheight / vid.videoHeight; } else{ var canvasScaleFactor = _ard_canvasWidth / vid.videoWidth; var canvasWidth = vid.videoWidth * canvasScaleFactor; var canvasHeight = vid.videoHeight * canvasScaleFactor; } canvas.width = canvasWidth; canvas.height = canvasHeight; // init oldAr to physical