<template>
  <div v-resize="resizeHandler" class="dv-border-box-3">
    <svg class="dv-border-svg-container" :width="width" :height="height">
      <polygon
        :fill="backgroundColor"
        :points="`
          9, 7 ${width - 9}, 7 ${width - 9}, ${height - 7} 9, ${height - 7}
        `"
      />

      <circle :fill="colorRight" cx="5" cy="5" r="2" />
      <circle :fill="colorRight" :cx="width - 5" cy="5" r="2" />
      <circle :fill="colorRight" :cx="width - 5" :cy="height - 5" r="2" />
      <circle :fill="colorRight" cx="5" :cy="height - 5" r="2" />
      <polyline :stroke="colorLeft" :points="`10, 4 ${width - 10}, 4`" />
      <polyline
        :stroke="colorLeft"
        :points="`10, ${height - 4} ${width - 10}, ${height - 4}`"
      />
      <polyline :stroke="colorLeft" :points="`5, 70 5, ${height - 70}`" />
      <polyline
        :stroke="colorLeft"
        :points="`${width - 5}, 70 ${width - 5}, ${height - 70}`"
      />
      <polyline :stroke="colorLeft" :points="`3, 10, 3, 50`" />
      <polyline :stroke="colorLeft" :points="`7, 30 7, 80`" />
      <polyline :stroke="colorLeft" :points="`${width - 3}, 10 ${width - 3}, 50`" />
      <polyline :stroke="colorLeft" :points="`${width - 7}, 30 ${width - 7}, 80`" />
      <polyline
        :stroke="colorLeft"
        :points="`3, ${height - 10} 3, ${height - 50}`"
      />
      <polyline
        :stroke="colorLeft"
        :points="`7, ${height - 30} 7, ${height - 80}`"
      />
      <polyline
        :stroke="colorLeft"
        :points="`${width - 3}, ${height - 10} ${width - 3}, ${height - 50}`"
      />
      <polyline
        :stroke="colorLeft"
        :points="`${width - 7}, ${height - 30} ${width - 7}, ${height - 80}`"
      />
    </svg>
  </div>
</template>
<script>
export default {
  props:{
    backgroundColor:{
      type:String,default:'transparent',
    },
    colorRight:{
      type:String,default:'#11eefd',
    },
    colorLeft:{
      type:String,default:'#0078d2',
    },
  },
  data() {
    return {
      width: '150',
      height: '150',     
    }
  },
  methods:{
    resizeHandler(entry){
      const rect=entry.contentRect;
      this.width=rect.width;
      this.height=rect.height;
      console.log("--->",entry)
    }
  },
  mounted(){
    this.$nextTick(()=>{
      this.resizeHandler({contentRect:this.$el.getBoundingClientRect()});
    });
  }
}
</script>
<style lang="scss" scoped>
.dv-border-box-3 {
  // position: relative;
  width: 100%;
  height: 100%;
  // pointer-events: none;

  .dv-border-svg-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;

    & > polyline {
      fill: none;
      stroke-width: 1;
    }
  }
}
</style>
