improcket/js/gui/element.mjs
2018-03-02 17:23:19 +00:00

25 lines
446 B
JavaScript

const defaultOptions = {
draw: true // Whether the element itself will be rendered.
}
export default class GuiElement {
constructor(x, y, w, h, options) {
this.x = x;
this.y = y;
this.w = w;
this.h = h;
this.children = new Set();
this.parent = null;
this.options = Object.assign(options, defaultOptions);
}
append(element) {
this.children.add(element);
element.parent = this;
}
clear() {
this.children.clear();
}
}