Scaling feature is added. Resolves #5
This commit is contained in:
parent
db10d318f5
commit
ad46b4a476
|
@ -32,13 +32,11 @@ class Display {
|
|||
let offset;
|
||||
this.source = new Dimensions(width, height);
|
||||
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()));
|
||||
offset = this.screen.height - this.display.height;
|
||||
this.offset = { x: 0, y: Math.round(offset / 2) };
|
||||
}
|
||||
else {
|
||||
console.log('b');
|
||||
this.display = new Dimensions(Math.floor(this.source.getRatio() * this.screen.height), this.screen.height);
|
||||
offset = this.screen.width - this.display.width;
|
||||
this.offset = { x: Math.round(offset / 2), y: 0 };
|
||||
|
|
|
@ -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,CAAC;IAEM,UAAU,CAAE,CAAU;QAC5B,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;IAEM,UAAU,CAAE,CAAU;QAC5B,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;IAEM,QAAQ,CAAE,KAAc;QAC9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,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"}
|
|
@ -291,7 +291,6 @@ class Sequence {
|
|||
const screen = this.display.getScreen();
|
||||
let totalX;
|
||||
let totalY;
|
||||
let updated = false;
|
||||
if (x !== 0) {
|
||||
if (current.x + x < 0) {
|
||||
return;
|
||||
|
@ -301,7 +300,6 @@ class Sequence {
|
|||
return;
|
||||
}
|
||||
this.display.setOffsetX(current.x + x);
|
||||
updated = true;
|
||||
}
|
||||
if (y !== 0) {
|
||||
if (current.y + y < 0) {
|
||||
|
@ -312,18 +310,14 @@ class Sequence {
|
|||
return;
|
||||
}
|
||||
this.display.setOffsetY(current.y + y);
|
||||
updated = true;
|
||||
}
|
||||
if (updated) {
|
||||
this.updateClientsOnDisplay();
|
||||
}
|
||||
}
|
||||
updateSize(width, height) {
|
||||
const current = this.display.getOutgoingPosition();
|
||||
const screen = this.display.getScreen();
|
||||
let totalX;
|
||||
let totalY;
|
||||
let updated = false;
|
||||
if (width !== 0) {
|
||||
if (current.w + width < 1) {
|
||||
return;
|
||||
|
@ -333,7 +327,6 @@ class Sequence {
|
|||
return;
|
||||
}
|
||||
this.display.setWidth(current.w + width);
|
||||
updated = true;
|
||||
}
|
||||
if (height !== 0) {
|
||||
if (current.h + height < 1) {
|
||||
|
@ -344,17 +337,39 @@ class Sequence {
|
|||
return;
|
||||
}
|
||||
this.display.setHeight(current.h + height);
|
||||
updated = true;
|
||||
}
|
||||
if (updated) {
|
||||
this.updateClientsOnDisplay();
|
||||
}
|
||||
}
|
||||
updateScale(scale) {
|
||||
const source = this.display.getSource();
|
||||
const current = this.display.getDimensions();
|
||||
const offset = this.display.getOffset();
|
||||
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() {
|
||||
const start = Date.now();
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -52,12 +52,10 @@ export class Display {
|
|||
let offset : number;
|
||||
this.source = new Dimensions(width, height);
|
||||
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()));
|
||||
offset = this.screen.height - this.display.height;
|
||||
this.offset = { x: 0, y : Math.round(offset / 2) };
|
||||
} else {
|
||||
console.log('b')
|
||||
this.display = new Dimensions(Math.floor(this.source.getRatio() * this.screen.height), this.screen.height);
|
||||
offset = this.screen.width - this.display.width;
|
||||
this.offset = { x: Math.round(offset / 2), y : 0 };
|
||||
|
|
|
@ -352,7 +352,6 @@ export class Sequence {
|
|||
const screen : Dimensions = this.display.getScreen();
|
||||
let totalX : number;
|
||||
let totalY : number;
|
||||
let updated : boolean = false;
|
||||
if (x !== 0) {
|
||||
if (current.x + x < 0) {
|
||||
return;
|
||||
|
@ -362,7 +361,6 @@ export class Sequence {
|
|||
return;
|
||||
}
|
||||
this.display.setOffsetX(current.x + x);
|
||||
updated = true;
|
||||
}
|
||||
if (y !== 0) {
|
||||
if (current.y + y < 0) {
|
||||
|
@ -373,19 +371,15 @@ export class Sequence {
|
|||
return;
|
||||
}
|
||||
this.display.setOffsetY(current.y + y);
|
||||
updated = true;
|
||||
}
|
||||
if (updated) {
|
||||
this.updateClientsOnDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
public updateSize (width : number, height : number) {
|
||||
const current : fdOutgoingPosition = this.display.getOutgoingPosition();
|
||||
const screen : Dimensions = this.display.getScreen();
|
||||
let totalX : number;
|
||||
let totalY : number;
|
||||
let updated : boolean = false;
|
||||
if (width !== 0) {
|
||||
if (current.w + width < 1) {
|
||||
return;
|
||||
|
@ -395,7 +389,6 @@ export class Sequence {
|
|||
return;
|
||||
}
|
||||
this.display.setWidth(current.w + width);
|
||||
updated = true;
|
||||
}
|
||||
if (height !== 0) {
|
||||
if (current.h + height < 1) {
|
||||
|
@ -406,18 +399,40 @@ export class Sequence {
|
|||
return;
|
||||
}
|
||||
this.display.setHeight(current.h + height);
|
||||
updated = true;
|
||||
}
|
||||
if (updated) {
|
||||
this.updateClientsOnDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
public updateScale (scale : number) {
|
||||
const source : Dimensions = this.display.getSource();
|
||||
const current : Dimensions = this.display.getDimensions();
|
||||
const offset : Offset = this.display.getOffset();
|
||||
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 () {
|
||||
|
|
Loading…
Reference in New Issue