ujs/src/js/objects.js

53 lines
892 B
JavaScript

export class uLayer {
#name;
#objects;
constructor(name, objects) {
// TODO: check types
this.#name = name;
this.#objects = Array();
objects.forEach((object) => {
this.#objects.push(object);
});
}
add(object) {
this.#objects.push(object);
}
getName() {
return this.#name;
}
objects() {
return this.#objects;
}
}
class uObject {
constructor(x, y, w, h) {
this.x = x;
this.y = y;
this.width = w;
this.height = h;
}
}
export class uRect extends uObject {
constructor(x, y, w, h, fillColor = 'white') {
super(x, y, w, h);
this.fillColor = fillColor;
}
}
export class uStrokeRect extends uRect {
constructor(x, y, w, h, fillColor = 'white', strokeColor = 'black', strokeWidth = 1) {
super(x, y, w, h, fillColor);
this.strokeWidth = strokeWidth;
this.strokeColor = strokeColor;
}
}