import { deprecation } from '../../../utils/logging/deprecation.mjs';
import { Container } from '../../scene/Container.mjs';
import { GraphicsContext } from './GraphicsContext.mjs';
import { GraphicsView } from './GraphicsView.mjs';

class Graphics extends Container {
  constructor(options) {
    if (options instanceof GraphicsContext) {
      options = { context: options };
    }
    super({
      view: new GraphicsView(options?.context),
      label: "Graphics",
      ...options
    });
    this.allowChildren = false;
  }
  get context() {
    return this.view.context;
  }
  set context(context) {
    this.view.context = context;
  }
  _callContextMethod(method, args) {
    this.view.context[method](...args);
    return this;
  }
  fill(...args) {
    return this._callContextMethod("fill", args);
  }
  stroke(...args) {
    return this._callContextMethod("stroke", args);
  }
  texture(...args) {
    return this._callContextMethod("texture", args);
  }
  beginPath(...args) {
    return this._callContextMethod("beginPath", args);
  }
  cut(...args) {
    return this._callContextMethod("cut", args);
  }
  arc(...args) {
    return this._callContextMethod("arc", args);
  }
  arcTo(...args) {
    return this._callContextMethod("arcTo", args);
  }
  arcToSvg(...args) {
    return this._callContextMethod("arcToSvg", args);
  }
  bezierCurveTo(...args) {
    return this._callContextMethod("bezierCurveTo", args);
  }
  closePath(...args) {
    return this._callContextMethod("closePath", args);
  }
  ellipse(...args) {
    return this._callContextMethod("ellipse", args);
  }
  circle(...args) {
    return this._callContextMethod("circle", args);
  }
  path(...args) {
    return this._callContextMethod("path", args);
  }
  lineTo(...args) {
    return this._callContextMethod("lineTo", args);
  }
  moveTo(...args) {
    return this._callContextMethod("moveTo", args);
  }
  quadraticCurveTo(...args) {
    return this._callContextMethod("quadraticCurveTo", args);
  }
  rect(...args) {
    return this._callContextMethod("rect", args);
  }
  roundRect(...args) {
    return this._callContextMethod("roundRect", args);
  }
  poly(...args) {
    return this._callContextMethod("poly", args);
  }
  star(...args) {
    return this._callContextMethod("star", args);
  }
  svg(...args) {
    return this._callContextMethod("svg", args);
  }
  restore(...args) {
    return this._callContextMethod("restore", args);
  }
  save(...args) {
    return this._callContextMethod("save", args);
  }
  getTransform(...args) {
    return this._callContextMethod("getTransform", args);
  }
  resetTransform(...args) {
    return this._callContextMethod("resetTransform", args);
  }
  rotateTransform(...args) {
    return this._callContextMethod("rotate", args);
  }
  scaleTransform(...args) {
    return this._callContextMethod("scale", args);
  }
  setTransform(...args) {
    return this._callContextMethod("setTransform", args);
  }
  transform(...args) {
    return this._callContextMethod("transform", args);
  }
  translateTransform(...args) {
    return this._callContextMethod("translate", args);
  }
  clear(...args) {
    return this._callContextMethod("clear", args);
  }
  get fillStyle() {
    return this.view.context.fillStyle;
  }
  set fillStyle(value) {
    this.view.context.fillStyle = value;
  }
  get strokeStyle() {
    return this.view.context.strokeStyle;
  }
  set strokeStyle(value) {
    this.view.context.strokeStyle = value;
  }
  // v7 deprecations
  /**
   * @param color
   * @param alpha
   * @deprecated since 8.0.0
   */
  beginFill(color, alpha) {
    deprecation("8.0.0", "Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");
    this.endFill();
    this.context.fillStyle = { color, alpha };
    return this;
  }
  /**
   * @deprecated since 8.0.0
   */
  endFill() {
    deprecation("8.0.0", "Graphics#endFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");
    this.context.fill();
    return this;
  }
  /**
   * @param {...any} args
   * @deprecated since 8.0.0
   */
  drawCircle(...args) {
    deprecation("8.0.0", "Graphics#drawCircle has been renamed to Graphics#circle");
    return this._callContextMethod("circle", args);
  }
  /**
   * @param {...any} args
   * @deprecated since 8.0.0
   */
  drawEllipse(...args) {
    deprecation("8.0.0", "Graphics#drawEllipse has been renamed to Graphics#ellipse");
    return this._callContextMethod("ellipse", args);
  }
  /**
   * @param {...any} args
   * @deprecated since 8.0.0
   */
  drawPolygon(...args) {
    deprecation("8.0.0", "Graphics#drawPolygon has been renamed to Graphics#poly");
    return this._callContextMethod("poly", args);
  }
  /**
   * @param {...any} args
   * @deprecated since 8.0.0
   */
  drawRect(...args) {
    deprecation("8.0.0", "Graphics#drawRect has been renamed to Graphics#rect");
    return this._callContextMethod("rect", args);
  }
  /**
   * @param {...any} args
   * @deprecated since 8.0.0
   */
  drawRoundedRect(...args) {
    deprecation("8.0.0", "Graphics#drawRoundedRect has been renamed to Graphics#roundRect");
    return this._callContextMethod("roundRect", args);
  }
  /**
   * @param {...any} args
   * @deprecated since 8.0.0
   */
  drawStar(...args) {
    deprecation("8.0.0", "Graphics#drawStar has been renamed to Graphics#star");
    return this._callContextMethod("star", args);
  }
}

export { Graphics };
//# sourceMappingURL=Graphics.mjs.map
