2018-05-06 21:32:18 +02:00
|
|
|
// računa približevanje ter računa/popravlja odmike videa
|
|
|
|
|
|
|
|
|
|
|
|
class Zoom {
|
2018-05-12 02:51:58 +02:00
|
|
|
// internal variables
|
2018-05-06 21:32:18 +02:00
|
|
|
|
|
|
|
|
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;
|
2018-05-24 20:50:37 +02:00
|
|
|
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-06 21:32:18 +02:00
|
|
|
|
2018-05-12 02:51:58 +02:00
|
|
|
reset(){
|
|
|
|
this.scale = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
zoomIn(){
|
2018-05-24 20:50:37 +02:00
|
|
|
this.scale += this.scaleStep;
|
|
|
|
|
|
|
|
if (this.scale >= this.maxScale) {
|
|
|
|
this.scale = this.maxScale;
|
|
|
|
}
|
2018-05-12 02:51:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
zoomOut(){
|
2018-05-24 20:50:37 +02:00
|
|
|
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-06 21:32:18 +02:00
|
|
|
}
|
2018-05-12 02:51:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
applyZoom(videoDimensions){
|
2018-05-24 23:29:30 +02:00
|
|
|
videoDimensions.xFactor *= this.scale;
|
|
|
|
videoDimensions.yFactor *= this.scale;
|
2018-05-12 02:51:58 +02:00
|
|
|
}
|
2018-05-06 21:32:18 +02:00
|
|
|
}
|