electrify electrocute
This commit is contained in:
parent
fd2fbd58cb
commit
662f3b00ca
@ -22,7 +22,7 @@ class Electrify extends Component {
|
||||
version="1.1"
|
||||
id="electrify"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 128 128">
|
||||
viewBox="0 0 500 500">
|
||||
<defs>
|
||||
<filter id="electrifyFilter">
|
||||
<feGaussianBlur in="SourceGraphic" stdDeviation="5" />
|
||||
@ -34,13 +34,15 @@ class Electrify extends Component {
|
||||
</defs>
|
||||
<path
|
||||
class='blue'
|
||||
transform="translate(53.86742,49.72374)"
|
||||
filter='url("#electrifyFilter")'
|
||||
d='M10,64 L10,64 L20,64 L30,64 L40,64 L50,64 L60,64 L70,64 L80,64 L90,64 L100,64 L110,64'
|
||||
d="M 440,200 L 407,320 L 320,407 L 200,440 L 80,407 L -7,320 L -40,200 L -7,80 L 80,-7 L 200,-40 L 320,-7 L 407,80 L 440,200"
|
||||
/>
|
||||
<path
|
||||
class='white'
|
||||
transform="translate(53.86742,49.72374)"
|
||||
d="M 440,200 L 407,320 L 320,407 L 200,440 L 80,407 L -7,320 L -40,200 L -7,80 L 80,-7 L 200,-40 L 320,-7 L 407,80 L 440,200"
|
||||
filter='url("#electrifyFilter")'
|
||||
d='M10,64 L10,64 L20,64 L30,64 L40,64 L50,64 L60,64 L70,64 L80,64 L90,64 L100,64 L110,64'
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
@ -56,24 +58,30 @@ class Electrify extends Component {
|
||||
easing: 'easeInOutSine',
|
||||
}));
|
||||
|
||||
const path = () => `M10,64
|
||||
L10,${anime.random(34, 94)}
|
||||
L20,${anime.random(34, 94)}
|
||||
L30,${anime.random(34, 94)}
|
||||
L40,${anime.random(34, 94)}
|
||||
L50,${anime.random(34, 94)}
|
||||
L60,${anime.random(34, 94)}
|
||||
L70,${anime.random(34, 94)}
|
||||
L80,${anime.random(34, 94)}
|
||||
L90,${anime.random(34, 94)}
|
||||
L100,${anime.random(34, 94)}
|
||||
L110,64
|
||||
const path = () => {
|
||||
const startX = anime.random(420, 440);
|
||||
const startY = anime.random(180, 200);
|
||||
return `
|
||||
M ${startX},${startY}
|
||||
L ${anime.random(387, 407)},${anime.random(300, 320)}
|
||||
L ${anime.random(300, 320)},${anime.random(387, 407)}
|
||||
L ${anime.random(180, 200)},${anime.random(420, 440)}
|
||||
L ${anime.random(60, 80)},${anime.random(387, 407)}
|
||||
L ${anime.random(-27, 7)},${anime.random(300, 320)}
|
||||
L ${anime.random(-20, -40)},${anime.random(180, 200)}
|
||||
L ${anime.random(-27, 7)},${anime.random(60, 80)}
|
||||
L ${anime.random(60, 80)},${anime.random(-27, 7)}
|
||||
L ${anime.random(180, 200)},${anime.random(-20, -40)}
|
||||
L ${anime.random(300, 320)},${anime.random(-27, 7)}
|
||||
L ${anime.random(387, 407)},${anime.random(60, 80)}
|
||||
L ${startX},${startY}
|
||||
`;
|
||||
};
|
||||
|
||||
this.animations.push(anime({
|
||||
targets: ['#electrify path'],
|
||||
d: times(10, path),
|
||||
easing: 'easeOutExpo',
|
||||
easing: 'easeInOutSine',
|
||||
loop: true,
|
||||
duration: TIMES.TARGET_MAIN_DURATION / 5,
|
||||
}));
|
||||
|
||||
102
client/src/components/anims/electrocute.jsx
Normal file
102
client/src/components/anims/electrocute.jsx
Normal file
@ -0,0 +1,102 @@
|
||||
const preact = require('preact');
|
||||
const { Component } = require('preact');
|
||||
const times = require('lodash/times')
|
||||
|
||||
const anime = require('animejs').default;
|
||||
|
||||
const { TIMES } = require('../../constants');
|
||||
|
||||
// shamelessly lifted from teh anime docs
|
||||
// https://animejs.com/documentation/#svgAttr
|
||||
|
||||
class Electrify extends Component {
|
||||
constructor() {
|
||||
super();
|
||||
this.animations = [];
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<svg
|
||||
class='skill-animation blue'
|
||||
version="1.1"
|
||||
id="electrify"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 128 128">
|
||||
<defs>
|
||||
<filter id="electrifyFilter">
|
||||
<feGaussianBlur in="SourceGraphic" stdDeviation="5" />
|
||||
<feMerge>
|
||||
<feMergeNode />
|
||||
<feMergeNode in="SourceGraphic" />
|
||||
</feMerge>
|
||||
</filter>
|
||||
</defs>
|
||||
<path
|
||||
class='blue'
|
||||
filter='url("#electrifyFilter")'
|
||||
d='M10,64 L10,64 L20,64 L30,64 L40,64 L50,64 L60,64 L70,64 L80,64 L90,64 L100,64 L110,64'
|
||||
/>
|
||||
<path
|
||||
class='white'
|
||||
filter='url("#electrifyFilter")'
|
||||
d='M10,64 L10,64 L20,64 L30,64 L40,64 L50,64 L60,64 L70,64 L80,64 L90,64 L100,64 L110,64'
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.animations.push(anime({
|
||||
targets: ['#electrify'],
|
||||
opacity: [
|
||||
{ value: 1, delay: TIMES.TARGET_FADE_IN_DELAY, duration: TIMES.TARGET_FADE_IN_DURATION },
|
||||
{ value: 0, delay: TIMES.TARGET_FADE_OUT_DELAY, duration: TIMES.FADE_OUT_DURATION },
|
||||
],
|
||||
easing: 'easeInOutSine',
|
||||
}));
|
||||
|
||||
const path = () => `M10,64
|
||||
L10,${anime.random(34, 94)}
|
||||
L20,${anime.random(34, 94)}
|
||||
L30,${anime.random(34, 94)}
|
||||
L40,${anime.random(34, 94)}
|
||||
L50,${anime.random(34, 94)}
|
||||
L60,${anime.random(34, 94)}
|
||||
L70,${anime.random(34, 94)}
|
||||
L80,${anime.random(34, 94)}
|
||||
L90,${anime.random(34, 94)}
|
||||
L100,${anime.random(34, 94)}
|
||||
L110,64
|
||||
`;
|
||||
|
||||
this.animations.push(anime({
|
||||
targets: ['#electrify path'],
|
||||
d: times(10, path),
|
||||
easing: 'easeInOutSine',
|
||||
loop: true,
|
||||
duration: TIMES.TARGET_MAIN_DURATION / 5,
|
||||
}));
|
||||
|
||||
this.animations.push(anime({
|
||||
targets: ['#electrify path.white'],
|
||||
strokeWidth: [2, 1],
|
||||
easing: 'easeInOutSine',
|
||||
direction: 'alternate',
|
||||
loop: true,
|
||||
duration: TIMES.TARGET_MAIN_DURATION,
|
||||
}));
|
||||
}
|
||||
|
||||
// this is necessary because
|
||||
// skipping / timing / unmounting race conditions
|
||||
// can cause the animations to cut short, this will ensure the values are reset
|
||||
// because preact will recycle all these components
|
||||
componentWillUnmount() {
|
||||
for (let i = this.animations.length - 1; i >= 0; i--) {
|
||||
this.animations[i].reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Electrify;
|
||||
Loading…
x
Reference in New Issue
Block a user