import {Container, Graphics} from "pixi.js";

export default class ModalBackground extends Container {

  #fill = 0xffffff;
  #width = 100;
  #height = 100;
  #radius = 0;
  #graphics = null;

  constructor() {
    super();
    this.#graphics = new Graphics();
    this.addChild(this.#graphics);
  }

  set fill(color) {
    this.#fill = color;
    this.adjust();
  }

  set width(value) {
    this.#width = value;
    this.adjust();
  }

  get width() {
    return this.#width;
  }

  set height(value) {
    this.#height = value;
    this.adjust();
  }

  get height() {
    return this.#height;
  }

  set radius(value) {
    this.#radius = value;
    this.adjust();
  }

  adjust() {
    this.#graphics
      .clear()
      .beginFill(this.#fill)
      .drawRoundedRect(0, 0, this.#width, this.#height, this.#radius);
  }
}
