2019-08-22 14:41:07 +08:00
|
|
|
<template>
|
|
|
|
<div class="dv-decoration-9" :ref="ref">
|
|
|
|
<svg :width="`${svgWH[0]}px`" :height="`${svgWH[1]}px`" :style="`transform:scale(${svgScale[0]},${svgScale[1]});`">
|
|
|
|
<defs>
|
|
|
|
<polygon :id="polygonId" points="15, 46.5, 21, 47.5, 21, 52.5, 15, 53.5" />
|
|
|
|
</defs>
|
|
|
|
|
|
|
|
<circle
|
|
|
|
cx="50"
|
|
|
|
cy="50"
|
|
|
|
r="45"
|
|
|
|
fill="transparent"
|
2019-12-06 21:07:16 +08:00
|
|
|
:stroke="mergedColor[1]"
|
2019-08-22 14:41:07 +08:00
|
|
|
stroke-width="10"
|
|
|
|
stroke-dasharray="80, 100, 30, 100"
|
|
|
|
>
|
|
|
|
<animateTransform
|
|
|
|
attributeName="transform"
|
|
|
|
type="rotate"
|
|
|
|
values="0 50 50;360 50 50"
|
2019-12-06 21:07:16 +08:00
|
|
|
:dur="`${dur}s`"
|
2019-08-22 14:41:07 +08:00
|
|
|
repeatCount="indefinite"
|
|
|
|
/>
|
|
|
|
</circle>
|
|
|
|
|
|
|
|
<circle
|
|
|
|
cx="50"
|
|
|
|
cy="50"
|
|
|
|
r="45"
|
|
|
|
fill="transparent"
|
2019-12-06 21:07:16 +08:00
|
|
|
:stroke="mergedColor[0]"
|
2019-08-22 14:41:07 +08:00
|
|
|
stroke-width="6"
|
|
|
|
stroke-dasharray="50, 66, 100, 66"
|
|
|
|
>
|
|
|
|
<animateTransform
|
|
|
|
attributeName="transform"
|
|
|
|
type="rotate"
|
|
|
|
values="0 50 50;-360 50 50"
|
2019-12-06 21:07:16 +08:00
|
|
|
:dur="`${dur}s`"
|
2019-08-22 14:41:07 +08:00
|
|
|
repeatCount="indefinite"
|
|
|
|
/>
|
|
|
|
</circle>
|
|
|
|
|
|
|
|
<circle
|
|
|
|
cx="50"
|
|
|
|
cy="50"
|
|
|
|
r="38"
|
|
|
|
fill="transparent"
|
2019-12-06 21:07:16 +08:00
|
|
|
:stroke="fade(mergedColor[1] || defaultColor[1], 30)"
|
2019-08-22 14:41:07 +08:00
|
|
|
stroke-width="1"
|
|
|
|
stroke-dasharray="5, 1"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<use
|
|
|
|
v-for="(foo, i) in new Array(20).fill(0)"
|
|
|
|
:key="i"
|
|
|
|
:xlink:href="`#${polygonId}`"
|
2019-12-06 21:07:16 +08:00
|
|
|
:stroke="mergedColor[1]"
|
|
|
|
:fill="Math.random() > 0.4 ? 'transparent' : mergedColor[0]"
|
2019-08-22 14:41:07 +08:00
|
|
|
>
|
|
|
|
<animateTransform
|
|
|
|
attributeName="transform"
|
|
|
|
type="rotate"
|
|
|
|
values="0 50 50;360 50 50"
|
2019-12-06 21:07:16 +08:00
|
|
|
:dur="`${dur}s`"
|
|
|
|
:begin="`${i * dur / 20}s`"
|
2019-08-22 14:41:07 +08:00
|
|
|
repeatCount="indefinite"
|
|
|
|
/>
|
|
|
|
</use>
|
|
|
|
|
|
|
|
<circle
|
|
|
|
cx="50"
|
|
|
|
cy="50"
|
|
|
|
r="26"
|
|
|
|
fill="transparent"
|
2019-12-06 21:07:16 +08:00
|
|
|
:stroke="fade(mergedColor[1] || defaultColor[1], 30)"
|
2019-08-22 14:41:07 +08:00
|
|
|
stroke-width="1"
|
|
|
|
stroke-dasharray="5, 1"
|
|
|
|
/>
|
|
|
|
</svg>
|
|
|
|
|
|
|
|
<slot></slot>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import autoResize from '../../../mixin/autoResize'
|
|
|
|
|
2019-12-06 21:07:16 +08:00
|
|
|
import { deepMerge } from '@jiaminghi/charts/lib/util/index'
|
|
|
|
|
|
|
|
import { deepClone } from '@jiaminghi/c-render/lib/plugin/util'
|
|
|
|
|
|
|
|
import { fade } from '@jiaminghi/color'
|
|
|
|
|
2019-08-22 14:41:07 +08:00
|
|
|
export default {
|
|
|
|
name: 'DvDecoration9',
|
|
|
|
mixins: [autoResize],
|
2019-12-06 21:07:16 +08:00
|
|
|
props: {
|
|
|
|
color: {
|
|
|
|
type: Array,
|
|
|
|
default: () => ([])
|
|
|
|
},
|
|
|
|
dur: {
|
|
|
|
type: Number,
|
|
|
|
default: 3
|
|
|
|
}
|
|
|
|
},
|
2019-08-22 14:41:07 +08:00
|
|
|
data () {
|
2019-09-10 15:14:12 +08:00
|
|
|
const timestamp = Date.now()
|
2019-08-22 14:41:07 +08:00
|
|
|
return {
|
|
|
|
ref: 'decoration-9',
|
|
|
|
|
2019-09-10 15:14:12 +08:00
|
|
|
polygonId: `decoration-9-polygon-${timestamp}`,
|
2019-08-22 14:41:07 +08:00
|
|
|
|
|
|
|
svgWH: [100, 100],
|
|
|
|
|
2019-12-06 21:07:16 +08:00
|
|
|
svgScale: [1, 1],
|
|
|
|
|
|
|
|
defaultColor: ['rgba(3, 166, 224, 0.8)', 'rgba(3, 166, 224, 0.5)'],
|
|
|
|
|
|
|
|
mergedColor: []
|
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
color () {
|
|
|
|
const { mergeColor } = this
|
|
|
|
|
|
|
|
mergeColor()
|
2019-08-22 14:41:07 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
afterAutoResizeMixinInit () {
|
|
|
|
const { calcScale } = this
|
|
|
|
|
|
|
|
calcScale()
|
|
|
|
},
|
|
|
|
calcScale () {
|
|
|
|
const { width, height, svgWH } = this
|
|
|
|
|
|
|
|
const [w, h] = svgWH
|
|
|
|
|
|
|
|
this.svgScale = [width / w, height / h]
|
|
|
|
},
|
|
|
|
onResize () {
|
|
|
|
const { calcScale } = this
|
|
|
|
|
|
|
|
calcScale()
|
2019-12-06 21:07:16 +08:00
|
|
|
},
|
|
|
|
mergeColor () {
|
|
|
|
const { color, defaultColor } = this
|
|
|
|
|
|
|
|
this.mergedColor = deepMerge(deepClone(defaultColor, true), color || [])
|
|
|
|
},
|
|
|
|
fade
|
|
|
|
},
|
|
|
|
mounted () {
|
|
|
|
const { mergeColor } = this
|
|
|
|
|
|
|
|
mergeColor()
|
2019-08-22 14:41:07 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|