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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
| <template>
| <g :transform="transform">
| <polygon :points="points" stroke="none" :fill="color" />
| <line :y1="y1" :y2="y2" :stroke-width="lineWidth" :stroke="color"></line>
| </g>
| </template>
|
| <script>
| export default {
| name: "",
| props: {
| len: {
| type: Number,
| default: 20,
| },
| offset: {
| type: Array,
| default() {
| return [0, 0];
| },
| },
| color: {
| type: String,
| default: "#f59a23",
| },
| lineWidth: {
| type: [Number, String],
| default: 2,
| },
| // 方向为二极管导通方向 三角形指向
| direct: {
| type: String,
| default: "left",
| validator: (v) => ["left", "right", "top", "bottom"].includes(v),
| },
| },
| computed: {
| y1() {
| let len = this.len;
| return len / -2;
| },
| y2() {
| let len = this.len;
| return len / 2;
| },
| points() {
| let lineWidth = this.lineWidth;
| let len = this.len;
| let len2 = len / 2;
| return [
| [lineWidth, 0],
| [lineWidth + Math.cos((30 * Math.PI) / 180) * len, len2],
| [lineWidth + Math.cos((30 * Math.PI) / 180) * len, -len2],
| ].join(",");
| },
| transform() {
| let { offset, direct, lineWidth, len } = this;
| let rotate = "";
| switch (direct) {
| case "left":
| rotate = "";
| break;
| case "right":
| rotate = `rotate(180 0 0) translate(-${lineWidth + Math.cos((30 * Math.PI) / 180) * len} 0)`;
| break;
| case "top":
| rotate = "rotate(90 0 0)";
| break;
| case "bottom":
| rotate = `rotate(270 0 0) translate(-${lineWidth + Math.cos((30 * Math.PI) / 180) * len} 0)`;
| break;
| }
| return `translate(${offset.join(",")}) ${rotate}`;
| },
| },
| data() {
| return {};
| },
| watch: {},
| components: {},
| methods: {},
|
| mounted() {},
| };
| </script>
|
| <style scoped lang="less">
| // .g-rect-fill {
| // fill: none;
| // // stroke-width: 5;
| // stroke-linejoin: round;
| // stroke-linecap: round;
| // stroke-dashoffset: -100;
| // // stroke-dasharray: 3, 900;
| // }
| // .move {
| // stroke-width: 7;
| // // stroke-dasharray: 43, 87;
| // stroke-dasharray: 23, 107;
| // animation: lineMove 1.8s cubic-bezier(0.05, 0.1, 0.8, 1) infinite;
| // }
| // .move1 {
| // stroke-width: 5;
| // stroke-dasharray: 23, 107;
| // animation: lineMove 1.8s cubic-bezier(0, 0, 1, 1) infinite;
| // }
| // .move-dis {
| // stroke-width: 7;
| // stroke-dasharray: 23, 107;
| // animation: lineMoveDis 1.8s cubic-bezier(0.05, 0.1, 0.8, 1) infinite;
| // }
| // .move-dis1 {
| // stroke-width: 5;
| // stroke-dasharray: 23, 107;
| // animation: lineMoveDis 1.8s cubic-bezier(0, 0, 1, 1) infinite;
| // // &.line1 {
| // // animation: lineMoveDis1 1.8s cubic-bezier(0, 0, 1, 1) infinite;
| // // }
| // }
|
| // @keyframes lineMove {
| // 0% {
| // // stroke-dashoffset: -850;
| // stroke-dashoffset: -260;
| // }
| // 100% {
| // stroke-dashoffset: 0;
| // }
| // }
| // @keyframes lineMoveDis {
| // 0% {
| // // stroke-dashoffset: -850;
| // stroke-dashoffset: 260;
| // }
| // 100% {
| // stroke-dashoffset: 0;
| // }
| // }
| </style>
|
|