Scaling feature is added. Resolves #5

This commit is contained in:
Matt McWilliams 2024-10-24 11:41:53 -04:00
parent db10d318f5
commit ad46b4a476
6 changed files with 58 additions and 32 deletions

View File

@ -32,13 +32,11 @@ class Display {
let offset; let offset;
this.source = new Dimensions(width, height); this.source = new Dimensions(width, height);
if (this.source.getRatio() > this.screen.getRatio()) { if (this.source.getRatio() > this.screen.getRatio()) {
console.log('a');
this.display = new Dimensions(this.screen.width, Math.floor(this.screen.width / this.source.getRatio())); this.display = new Dimensions(this.screen.width, Math.floor(this.screen.width / this.source.getRatio()));
offset = this.screen.height - this.display.height; offset = this.screen.height - this.display.height;
this.offset = { x: 0, y: Math.round(offset / 2) }; this.offset = { x: 0, y: Math.round(offset / 2) };
} }
else { else {
console.log('b');
this.display = new Dimensions(Math.floor(this.source.getRatio() * this.screen.height), this.screen.height); this.display = new Dimensions(Math.floor(this.source.getRatio() * this.screen.height), this.screen.height);
offset = this.screen.width - this.display.width; offset = this.screen.width - this.display.width;
this.offset = { x: Math.round(offset / 2), y: 0 }; this.offset = { x: Math.round(offset / 2), y: 0 };

View File

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/display/index.ts"],"names":[],"mappings":";;;AAEA,MAAa,UAAU;IAItB,YAAa,KAAc,EAAE,MAAe;QAC3C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,CAAC;IAEM,QAAQ;QACd,OAAO,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;IACjC,CAAC;CACD;AAZD,gCAYC;AAOD,MAAa,OAAO;IAQnB,YAAa,KAAc,EAAE,MAAe;QAC3C,IAAI,CAAC,MAAM,GAAG,IAAI,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAC5C,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAG,CAAC,EAAE,CAAA;IAC9B,CAA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AAK,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC;QACrD,CAAC;aAAM,CAAC;YACP,IAAI,CAAC,OAAO,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAC3G,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;YAChD,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,EAAG,CAAC,EAAG,CAAC,EAAE,CAAC;QACrD,CAAC;IACF,CAAC;IAEM,mBAAmB;QACzB,OAAO;YACN,CAAC,EAAG,IAAI,CAAC,OAAO,CAAC,KAAK;YACtB,CAAC,EAAG,IAAI,CAAC,OAAO,CAAC,MAAM;YACvB,CAAC,EAAG,IAAI,CAAC,MAAM,CAAC,CAAC;YACjB,CAAC,EAAG,IAAI,CAAC,MAAM,CAAC,CAAC;SACjB,CAAA;IACF,CAAC;IAEM,aAAa;QACnB,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAEM,SAAS;QACf,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAEM,SAAS;QACf,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAEM,SAAS;QACf,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;CACD;AAnED,0BAmEC;AAED,MAAM,CAAC,OAAO,GAAG,EAAE,OAAO,EAAG,UAAU,EAAE,CAAC"}

View File

@ -291,7 +291,6 @@ class Sequence {
const screen = this.display.getScreen(); const screen = this.display.getScreen();
let totalX; let totalX;
let totalY; let totalY;
let updated = false;
if (x !== 0) { if (x !== 0) {
if (current.x + x < 0) { if (current.x + x < 0) {
return; return;
@ -301,7 +300,6 @@ class Sequence {
return; return;
} }
this.display.setOffsetX(current.x + x); this.display.setOffsetX(current.x + x);
updated = true;
} }
if (y !== 0) { if (y !== 0) {
if (current.y + y < 0) { if (current.y + y < 0) {
@ -312,18 +310,14 @@ class Sequence {
return; return;
} }
this.display.setOffsetY(current.y + y); this.display.setOffsetY(current.y + y);
updated = true;
}
if (updated) {
this.updateClientsOnDisplay();
} }
this.updateClientsOnDisplay();
} }
updateSize(width, height) { updateSize(width, height) {
const current = this.display.getOutgoingPosition(); const current = this.display.getOutgoingPosition();
const screen = this.display.getScreen(); const screen = this.display.getScreen();
let totalX; let totalX;
let totalY; let totalY;
let updated = false;
if (width !== 0) { if (width !== 0) {
if (current.w + width < 1) { if (current.w + width < 1) {
return; return;
@ -333,7 +327,6 @@ class Sequence {
return; return;
} }
this.display.setWidth(current.w + width); this.display.setWidth(current.w + width);
updated = true;
} }
if (height !== 0) { if (height !== 0) {
if (current.h + height < 1) { if (current.h + height < 1) {
@ -344,17 +337,39 @@ class Sequence {
return; return;
} }
this.display.setHeight(current.h + height); this.display.setHeight(current.h + height);
updated = true;
}
if (updated) {
this.updateClientsOnDisplay();
} }
this.updateClientsOnDisplay();
} }
updateScale(scale) { updateScale(scale) {
const source = this.display.getSource();
const current = this.display.getDimensions(); const current = this.display.getDimensions();
const offset = this.display.getOffset(); const offset = this.display.getOffset();
const screen = this.display.getScreen(); const screen = this.display.getScreen();
console.dir(scale); let newWidth;
let newHeight;
let newOffsetX;
let newOffsetY;
if (source.getRatio() > screen.getRatio()) {
if (current.width + scale > screen.width || current.width + scale < 1) {
return;
}
newWidth = current.width + scale;
newHeight = Math.floor(newWidth / source.getRatio());
}
else {
if (current.height + scale > screen.height || current.height + scale < 1) {
return;
}
newHeight = current.height + scale;
newWidth = Math.floor(source.getRatio() * newHeight);
}
newOffsetX = Math.round((screen.width - newWidth) / 2);
newOffsetY = Math.round((screen.height - newHeight) / 2);
this.display.setWidth(newWidth);
this.display.setHeight(newHeight);
this.display.setOffsetX(newOffsetX);
this.display.setOffsetY(newOffsetY);
this.updateClientsOnDisplay();
} }
async frameRecord() { async frameRecord() {
const start = Date.now(); const start = Date.now();

File diff suppressed because one or more lines are too long

View File

@ -52,12 +52,10 @@ export class Display {
let offset : number; let offset : number;
this.source = new Dimensions(width, height); this.source = new Dimensions(width, height);
if (this.source.getRatio() > this.screen.getRatio()) { if (this.source.getRatio() > this.screen.getRatio()) {
console.log('a');
this.display = new Dimensions(this.screen.width, Math.floor(this.screen.width / this.source.getRatio())); this.display = new Dimensions(this.screen.width, Math.floor(this.screen.width / this.source.getRatio()));
offset = this.screen.height - this.display.height; offset = this.screen.height - this.display.height;
this.offset = { x: 0, y : Math.round(offset / 2) }; this.offset = { x: 0, y : Math.round(offset / 2) };
} else { } else {
console.log('b')
this.display = new Dimensions(Math.floor(this.source.getRatio() * this.screen.height), this.screen.height); this.display = new Dimensions(Math.floor(this.source.getRatio() * this.screen.height), this.screen.height);
offset = this.screen.width - this.display.width; offset = this.screen.width - this.display.width;
this.offset = { x: Math.round(offset / 2), y : 0 }; this.offset = { x: Math.round(offset / 2), y : 0 };

View File

@ -352,7 +352,6 @@ export class Sequence {
const screen : Dimensions = this.display.getScreen(); const screen : Dimensions = this.display.getScreen();
let totalX : number; let totalX : number;
let totalY : number; let totalY : number;
let updated : boolean = false;
if (x !== 0) { if (x !== 0) {
if (current.x + x < 0) { if (current.x + x < 0) {
return; return;
@ -362,7 +361,6 @@ export class Sequence {
return; return;
} }
this.display.setOffsetX(current.x + x); this.display.setOffsetX(current.x + x);
updated = true;
} }
if (y !== 0) { if (y !== 0) {
if (current.y + y < 0) { if (current.y + y < 0) {
@ -373,11 +371,8 @@ export class Sequence {
return; return;
} }
this.display.setOffsetY(current.y + y); this.display.setOffsetY(current.y + y);
updated = true;
}
if (updated) {
this.updateClientsOnDisplay();
} }
this.updateClientsOnDisplay();
} }
public updateSize (width : number, height : number) { public updateSize (width : number, height : number) {
@ -385,7 +380,6 @@ export class Sequence {
const screen : Dimensions = this.display.getScreen(); const screen : Dimensions = this.display.getScreen();
let totalX : number; let totalX : number;
let totalY : number; let totalY : number;
let updated : boolean = false;
if (width !== 0) { if (width !== 0) {
if (current.w + width < 1) { if (current.w + width < 1) {
return; return;
@ -395,7 +389,6 @@ export class Sequence {
return; return;
} }
this.display.setWidth(current.w + width); this.display.setWidth(current.w + width);
updated = true;
} }
if (height !== 0) { if (height !== 0) {
if (current.h + height < 1) { if (current.h + height < 1) {
@ -406,18 +399,40 @@ export class Sequence {
return; return;
} }
this.display.setHeight(current.h + height); this.display.setHeight(current.h + height);
updated = true;
}
if (updated) {
this.updateClientsOnDisplay();
} }
this.updateClientsOnDisplay();
} }
public updateScale (scale : number) { public updateScale (scale : number) {
const source : Dimensions = this.display.getSource();
const current : Dimensions = this.display.getDimensions(); const current : Dimensions = this.display.getDimensions();
const offset : Offset = this.display.getOffset(); const offset : Offset = this.display.getOffset();
const screen : Dimensions = this.display.getScreen(); const screen : Dimensions = this.display.getScreen();
console.dir(scale); let newWidth : number;
let newHeight : number;
let newOffsetX : number;
let newOffsetY : number;
if (source.getRatio() > screen.getRatio()) {
if (current.width + scale > screen.width || current.width + scale < 1) {
return;
}
newWidth = current.width + scale;
newHeight = Math.floor(newWidth / source.getRatio());
} else {
if (current.height + scale > screen.height || current.height + scale < 1) {
return;
}
newHeight = current.height + scale;
newWidth = Math.floor(source.getRatio() * newHeight);
}
newOffsetX = Math.round((screen.width - newWidth) / 2);
newOffsetY = Math.round((screen.height - newHeight) / 2);
this.display.setWidth(newWidth);
this.display.setHeight(newHeight);
this.display.setOffsetX(newOffsetX);
this.display.setOffsetY(newOffsetY);
this.updateClientsOnDisplay();
} }
private async frameRecord () { private async frameRecord () {