import {HmiComponent} from "../../hmi";

export let RectComponent: HmiComponent = {
  id: "rect",
  name: "矩形",
  icon: "/assets/hmi/rect.svg",
  group: "基础组件",
  drawer: "rect",

  color: true,
  stroke: true,

  create() {
    //@ts-ignore
    this.element = this.$container.rect(this.$properties.width, this.$properties.height)
  },

  setup(props: any): void {
    //@ts-ignore
    let p = this.$properties
    if (props.hasOwnProperty("fill"))//@ts-ignore
      this.element.fill(p.fill)
    if (props.hasOwnProperty("color") || props.hasOwnProperty("stroke"))//@ts-ignore
      this.element.stroke({color:p.color, width:p.stroke})
    if (props.hasOwnProperty("width") || props.hasOwnProperty("height"))//@ts-ignore
      this.element.size(p.width, p.height)
  }
}
