index.vue
2.86 KB
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
<template>
<!-- 10
0,2 54,2 60,4 75,4 81,6 216,6 225,4 240,4 245.3,2 300,2
90,8 210,8
20
0,4 54,4 60,8 75,8 81,12 216,12 225,8 240,8 245.3,4 300,4
90,16 210,16
30
0,6 54,6 60,12 75,12 81,18 216,18 225,12 240,12 245.3,6 300,6
90,24 210,24
40
0,8 54,8 60,16 75,16 81,24 216,24 225,16 240,16 245.3,8 300,8 -->
<!-- 200 200
60,160 140,160 -->
<div class="go-animat">
<div class="go-svg" :style="{ marginLeft: animat.x + 'px', marginTop: animat.y + 'px' }">
<svg :width="w" :height="h">
<polyline
fill="transparent"
stroke-width="3"
:points="`0,${h / 5} ${w / 5.555555555555556},${h / 5} ${w / 5},${h/2.5} ${w / 4},${h/2.5} ${w / 3.703703703703704},${h/1.666666666666667} ${
w / 1.388888888888889
},${h/1.666666666666667} ${w / 1.333333333333333},${h/2.5} ${w / 1.25},${h/2.5} ${w / 1.219512195121951},${h / 5} ${w},${h / 5}`"
:stroke="animat.colors[0]"
>
<animate
attributeName="stroke-dasharray"
attributeType="XML"
:from="`0, 969.031002232793, 0, 969.031002232793`"
:to="`0, 0, 1938.062004465586, 0`"
dur="3s"
begin="0s"
calcMode="spline"
keyTimes="0;1"
keySplines="0.4,1,0.49,0.98"
repeatCount="indefinite"
></animate>
</polyline>
<polyline
fill="transparent"
stroke-width="2"
:points="`${w / 3.333333333333333},${h/1.25} ${w / 1.428571428571429},${h/1.25}`"
:stroke="animat.colors[1]"
>
<animate
attributeName="stroke-dasharray"
attributeType="XML"
from="0, 384, 0, 384"
to="0, 0, 768, 0"
dur="3s"
begin="0s"
calcMode="spline"
keyTimes="0;1"
keySplines=".4,1,.49,.98"
repeatCount="indefinite"
></animate>
</polyline>
</svg>
</div>
<div class="go-text" :style="{ top: animat.textPos.y + '%', left: animat.textPos.x + '%' }">
<n-gradient-text :size="animat.size" :gradient="animat.gradient">
{{ animat.text }}
</n-gradient-text>
</div>
</div>
</template>
<script setup lang="ts">
import { PropType, toRefs } from 'vue'
import { CreateComponentType } from '@/packages/index.d'
const props = defineProps({
chartConfig: {
type: Object as PropType<CreateComponentType>,
required: true
}
})
const { w, h } = toRefs(props.chartConfig.attr)
const { animat } = toRefs(props.chartConfig.option)
</script>
<style lang="scss" scoped>
.go-animat {
width: v-bind('w+"px"');
height: v-bind('h+"px"');
display: flex;
justify-content: center;
align-items: center;
position: relative;
.go-svg {
}
.go-text {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
}
</style>