Add logo to main menu
This commit is contained in:
parent
cfe9c55c9a
commit
435b24cb6a
15 changed files with 135 additions and 40 deletions
26
js/gui/image.mjs
Normal file
26
js/gui/image.mjs
Normal file
|
@ -0,0 +1,26 @@
|
|||
import * as gui from './index.mjs';
|
||||
import GuiElement from './element.mjs';
|
||||
|
||||
export class GuiImage extends GuiElement {
|
||||
constructor(src, x, y, w, h) {
|
||||
w = w || src.width;
|
||||
h = h || src.height;
|
||||
super(x, y, w, h);
|
||||
this.type = 'image';
|
||||
this.image = src;
|
||||
this.imgRatio = src.width / src.height;
|
||||
}
|
||||
|
||||
scaleImage({ w = null, h = null }) {
|
||||
if (w !== null && h === null) {
|
||||
this.w = w;
|
||||
this.h = w / this.imgRatio;
|
||||
} else if (h !== null && w === null) {
|
||||
this.h = h;
|
||||
this.w = h / this.imgRatio;
|
||||
} else if ( h !== null && w !== null) {
|
||||
this.w = w;
|
||||
this.h = h;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue