Add logo to main menu

This commit is contained in:
asraelite 2018-03-02 19:37:24 +00:00
parent cfe9c55c9a
commit 435b24cb6a
15 changed files with 135 additions and 40 deletions

View file

@ -3,7 +3,7 @@ const defaultOptions = {
}
export default class GuiElement {
constructor(x, y, w, h, options) {
constructor(x, y, w, h, options = {}) {
this.x = x;
this.y = y;
this.w = w;
@ -11,7 +11,9 @@ export default class GuiElement {
this.children = new Set();
this.parent = null;
this.options = Object.assign(options, defaultOptions);
this.type = 'element';
this.options = Object.assign({}, defaultOptions, options);
}
append(element) {
@ -22,4 +24,20 @@ export default class GuiElement {
clear() {
this.children.clear();
}
get shape() {
return [this.x, this.y, this.w, this.h];
}
posRelative({x = null, xc = 0, y = null, yc = 0, w = null, h = null}) {
if (x !== null) {
this.x = (this.parent.w * x) - (this.w * xc);
}
if (y !== null)
this.y = (this.parent.h * y) - (this.h * yc);
if (w !== null)
this.w = this.parent.w * w;
if (h !== null)
this.h = this.parent.h * h;
}
}