he wei
2023-11-25 d043e9283165ac10757ab4bf536998bf42b98e9b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<template>
  <g :transform="'translate(' + offset.join(',') + ')'">
    <defs>
      <linearGradient id="color" x1="0%" y1="0%" x2="0%" y2="100%">
        <stop offset="0%" style="stop-color: #377add; stop-opacity: 1" />
        <stop offset="100%" style="stop-color: #4ec1fb; stop-opacity: 1" />
      </linearGradient>
    </defs>
    <!-- 圆角矩形 -->
    <path
      :d="createRoundRectPath(92, 80, 10)"
      stroke="none"
      fill="url(#color)"
    />
 
    <!-- 绘制标题 -->
    <text x="46" y="18" text-anchor="middle" fill="#fff" font-size="16">
      防雷保护器
    </text>
 
    <!-- 绘制图片 -->
    <image x="13" y="22" width="66" height="48" :xlink:href="img" />
  </g>
</template>
 
<script>
import img from "../images/bhq.png";
export default {
  name: "",
  props: {
    offset: {
      type: Array,
      default() {
        return [0, 0];
      },
    },
  },
  computed: {},
  data() {
    return {
      img,
    };
  },
  methods: {
    createRoundRectPath(w, h, r = 5, x = 0, y = 0) {
      let p0 = [x, y];
      let p1 = [x + w, y];
      let p2 = [x + w, y + h];
      let p3 = [x, y + h];
 
      let cp0 = [x + r, y];
      let cp1 = [x + w - r, y];
      let cp2 = [x + w, y + r];
      let cp3 = [x + w, y + h - r];
      let cp4 = [x + w - r, y + h];
      let cp5 = [x + r, y + h];
      let cp6 = [x, y + h - r];
      let cp7 = [x, y + r];
 
      return `M${cp0[0]},${cp0[1]}
        L ${cp1[0]} ${cp1[1]}
        C ${cp1[0]} ${cp1[1]}, ${p1[0]} ${p1[1]}, ${cp2[0]} ${cp2[1]}
        L ${cp3[0]} ${cp3[1]}
        C ${cp3[0]} ${cp3[1]}, ${p2[0]} ${p2[1]}, ${cp4[0]} ${cp4[1]}
        L ${cp5[0]} ${cp5[1]}
        C ${cp5[0]} ${cp5[1]}, ${p3[0]} ${p3[1]}, ${cp6[0]} ${cp6[1]}
        L ${cp7[0]} ${cp7[1]}
        C ${cp7[0]} ${cp7[1]}, ${p0[0]} ${p0[1]}, ${cp0[0]} ${cp0[1]}
        Z`;
    },
  },
 
  mounted() {},
};
</script>
 
<style scoped>
</style>