ultrawidify/js/modules/Zoom.js

63 lines
1.2 KiB
JavaScript
Raw Normal View History

// računa približevanje ter računa/popravlja odmike videa
class Zoom {
2018-05-12 02:51:58 +02:00
// internal variables
2018-05-12 02:51:58 +02:00
// functions
2018-05-18 23:26:20 +02:00
constructor(videoData) {
2018-05-12 02:51:58 +02:00
this.scale = 1;
this.scaleStep = 0.1;
2018-05-12 02:51:58 +02:00
this.minScale = 0.5; // not accurate, actually slightly less
this.maxScale = 8; // not accurate, actually slightly more
2018-05-18 23:26:20 +02:00
this.conf = videoData;
2018-05-12 02:51:58 +02:00
}
2018-05-12 02:51:58 +02:00
reset(){
this.scale = 1;
}
zoomIn(){
this.scale += this.scaleStep;
if (this.scale >= this.maxScale) {
this.scale = this.maxScale;
}
2018-05-12 02:51:58 +02:00
}
zoomOut(){
this.scale -= this.scaleStep;
if (this.scale <= this.minScale) {
this.scale = this.minScale;
}
}
zoomStep(amount){
this.scale += amount;
if (this.scale <= this.minScale) {
this.scale = this.minScale;
}
if (this.scale >= this.maxScale) {
this.scale = this.maxScale;
}
2018-05-12 02:51:58 +02:00
}
setZoom(scale){
if(scale < this.minScale) {
this.scale = this.minScale;
} else if (scale > this.maxScale) {
this.scale = this.maxScale;
} else {
this.scale = scale;
}
2018-05-12 02:51:58 +02:00
}
applyZoom(videoDimensions){
videoDimensions.xFactor *= this.scale;
videoDimensions.yFactor *= this.scale;
2018-05-12 02:51:58 +02:00
}
}