Scaler no longer static
This commit is contained in:
parent
c442f9e01c
commit
08b10220e1
@ -278,8 +278,10 @@ class ArDetector {
|
||||
var trueHeight = this.canvas.height - letterbox;
|
||||
|
||||
if(this.fallbackMode){
|
||||
if(edge.top > 1 && edge.top <= ExtensionConf.arDetect.fallbackMode.noTriggerZonePx )
|
||||
if(edges.top > 1 && edges.top <= ExtensionConf.arDetect.fallbackMode.noTriggerZonePx ){
|
||||
console.log("Edge is in the no-trigger zone. Aspect ratio change is not triggered.")
|
||||
return;
|
||||
}
|
||||
|
||||
// varnostno območje, ki naj ostane črno (da lahko v fallback načinu odkrijemo ožanje razmerja stranic).
|
||||
// x2, ker je safetyBorderPx definiran za eno stran.
|
||||
|
@ -15,9 +15,9 @@ class Resizer {
|
||||
this.video = videoData.video;
|
||||
|
||||
|
||||
this.scaler = new Scaler();
|
||||
this.stretcher = new Stretcher();
|
||||
this.zoom = new Zoom();
|
||||
this.scaler = new Scaler(this.conf);
|
||||
this.stretcher = new Stretcher(this.conf);
|
||||
this.zoom = new Zoom(this.conf);
|
||||
|
||||
// load up default values
|
||||
this.correctedVideoDimensions = {};
|
||||
@ -58,7 +58,7 @@ class Resizer {
|
||||
this.videoData.destroy();
|
||||
}
|
||||
|
||||
var dimensions = Scaler.calculateCrop(ar, this.video, this.conf.player.dimensions);
|
||||
var dimensions = this.scaler.calculateCrop(ar, this.video, this.conf.player.dimensions);
|
||||
|
||||
if(! dimensions || dimensions.error){
|
||||
if(Debug.debug){
|
||||
|
@ -6,10 +6,11 @@ class Scaler {
|
||||
// internal variables
|
||||
|
||||
// functions
|
||||
constructor() {
|
||||
constructor(videoData) {
|
||||
this.conf = videoData;
|
||||
}
|
||||
|
||||
static modeToAr(mode, video, playerDimensions){
|
||||
modeToAr(mode, video, playerDimensions){
|
||||
// Skrbi za "stare" možnosti, kot na primer "na širino zaslona", "na višino zaslona" in "ponastavi".
|
||||
// Približevanje opuščeno.
|
||||
// handles "legacy" options, such as 'fit to widht', 'fit to height' and 'reset'. No zoom tho
|
||||
@ -17,9 +18,9 @@ class Scaler {
|
||||
|
||||
if (!video) {
|
||||
if(Debug.debug){
|
||||
console.log("[Scaler.js::modeToAr] No video??",video)
|
||||
console.log("[Scaler.js::modeToAr] No video??",video, "killing videoData");
|
||||
}
|
||||
|
||||
this.conf.destroy();
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -56,12 +57,14 @@ class Scaler {
|
||||
return null;
|
||||
}
|
||||
|
||||
static calculateCrop(mode, video, playerDimensions) {
|
||||
calculateCrop(mode, video, playerDimensions) {
|
||||
|
||||
|
||||
if(!video || video.videoWidth == 0 || video.videoHeight == 0){
|
||||
if(Debug.debug)
|
||||
console.log("[Scaler::calculateCrop] ERROR — no video detected.")
|
||||
console.log("[Scaler::calculateCrop] ERROR — no video detected.");
|
||||
|
||||
this.conf.destroy();
|
||||
return {error: "no_video"};
|
||||
}
|
||||
|
||||
@ -69,7 +72,7 @@ class Scaler {
|
||||
// if 'ar' is string, we'll handle that in legacy wrapper
|
||||
var ar = 0;
|
||||
if(isNaN(mode)){
|
||||
ar = Scaler.modeToAr(mode);
|
||||
ar = this.modeToAr(mode);
|
||||
} else {
|
||||
ar = mode;
|
||||
}
|
||||
|
@ -9,8 +9,8 @@ class Stretcher {
|
||||
|
||||
|
||||
// functions
|
||||
constructor() {
|
||||
|
||||
constructor(videoData) {
|
||||
this.conf = videoData;
|
||||
}
|
||||
|
||||
static conditionalStretch(videoDimensions, maxDifferencePercent){
|
||||
|
@ -6,11 +6,12 @@ class Zoom {
|
||||
|
||||
|
||||
// functions
|
||||
constructor() {
|
||||
constructor(videoData) {
|
||||
this.scale = 1;
|
||||
this.scaleStep = 1.2;
|
||||
this.minScale = 0.5; // not accurate, actually slightly less
|
||||
this.maxScale = 8; // not accurate, actually slightly more
|
||||
this.conf = videoData;
|
||||
}
|
||||
|
||||
reset(){
|
||||
|
Loading…
Reference in New Issue
Block a user