Work chasing down errors in display

This commit is contained in:
Matt McWilliams 2024-10-22 16:31:04 -04:00
parent 582a95202e
commit 3c88de83b8
7 changed files with 16 additions and 10 deletions

View File

@ -10,6 +10,7 @@ class Display {
private parentElement : HTMLUListElement;
private canvas : HTMLCanvasElement;
private ctx : CanvasRenderingContext2D;
private img : HTMLImageElement;
private screen : any;
private sequence : boolean = false;
@ -106,11 +107,11 @@ class Display {
}
public updateImage() {
const img : any = new Image;
img.onload = function () {
this.ctx.drawImage(img, this.displayOffsetX, this.displayOffsetY, this.displayWidth, this.displayHeight);
this.img = new Image;
this.img.onload = function () {
this.ctx.drawImage(this.img, this.displayOffsetX, this.displayOffsetY, this.displayWidth, this.displayHeight);
}.bind(this);
img.src = `/${this.displayWidth}/${this.displayHeight}/image.jpg?cacheBreaker=${+new Date()}`;
this.img.src = `/${this.displayWidth}/${this.displayHeight}/image.jpg?cacheBreaker=${+new Date()}`;
}
public update (msg : Message) {

View File

@ -32,11 +32,13 @@ 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.source.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 };

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,MAA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EC;AAED,MAAM,CAAC,OAAO,GAAG,EAAE,OAAO,EAAG,UAAU,EAAE,CAAC"}

View File

@ -52,10 +52,12 @@ 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.source.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 };

View File

@ -8,6 +8,7 @@ declare class Display {
private parentElement;
private canvas;
private ctx;
private img;
private screen;
private sequence;
private offsetX;

View File

@ -86,11 +86,11 @@ class Display {
this.updateImage();
}
updateImage() {
const img = new Image;
img.onload = function () {
this.ctx.drawImage(img, this.displayOffsetX, this.displayOffsetY, this.displayWidth, this.displayHeight);
this.img = new Image;
this.img.onload = function () {
this.ctx.drawImage(this.img, this.displayOffsetX, this.displayOffsetY, this.displayWidth, this.displayHeight);
}.bind(this);
img.src = `/${this.displayWidth}/${this.displayHeight}/image.jpg?cacheBreaker=${+new Date()}`;
this.img.src = `/${this.displayWidth}/${this.displayHeight}/image.jpg?cacheBreaker=${+new Date()}`;
}
update(msg) {
}

File diff suppressed because one or more lines are too long