blast and text colours
This commit is contained in:
@@ -1,100 +1,72 @@
|
||||
const preact = require('preact');
|
||||
const { Component } = require('preact');
|
||||
const anime = require('animejs').default;
|
||||
const times = require('lodash/times');
|
||||
|
||||
const { TIMES } = require('../../constants');
|
||||
const { randomPoints } = require('../../utils');
|
||||
const { TIMES, COLOURS } = require('../../constants');
|
||||
|
||||
const duration = TIMES.TARGET_DURATION_MS;
|
||||
|
||||
|
||||
function projectile(x, y, radius, colour) {
|
||||
return (
|
||||
<circle
|
||||
cx={x}
|
||||
cy={y}
|
||||
r={radius}
|
||||
fill="url(#grad1)"
|
||||
stroke-width="2"
|
||||
stroke={colour}
|
||||
filter="url(#explosion)"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
class AttackCharge extends Component {
|
||||
constructor(props) {
|
||||
class Blast extends Component {
|
||||
constructor() {
|
||||
super();
|
||||
this.team = props.team;
|
||||
this.animations = [];
|
||||
const points = randomPoints(8, 60, { x: 0, y: 0, width: 300, height: 400 });
|
||||
this.charges = points.map(coord => projectile(coord[0], coord[1], 20, '#00aabb'));
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<svg
|
||||
class={'skill-animation'}
|
||||
id='blast'
|
||||
class="skill-animation"
|
||||
version="1.1"
|
||||
id="blast"
|
||||
transform-box='fill-box'
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 300 400">
|
||||
// {this.charges}
|
||||
viewBox="0 0 300 300">
|
||||
<defs>
|
||||
<radialGradient id="grad1" cx="50%" cy="50%" r="70%" fx="50%" fy="50%">
|
||||
<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:0.6" />
|
||||
<stop offset="100%" style={'stop-color:#00aabb;stop-opacity:1'} />
|
||||
</radialGradient>
|
||||
<filter id="blastFilter">
|
||||
<feGaussianBlur in="SourceGraphic" stdDeviation="3" />
|
||||
<feMerge>
|
||||
<feMergeNode />
|
||||
<feMergeNode in="SourceGraphic" />
|
||||
</feMerge>
|
||||
</filter>
|
||||
</defs>
|
||||
<filter id="explosion">
|
||||
<feGaussianBlur stdDeviation="4"/>
|
||||
<feTurbulence type="turbulence" baseFrequency="0.05" numOctaves="3" result="turbulence"/>
|
||||
<feDisplacementMap in2="turbulence" in="SourceGraphic" scale="1" xChannelSelector="A" yChannelSelector="A"/>
|
||||
|
||||
</filter>
|
||||
{this.charges}
|
||||
<g>
|
||||
{times(50, () => (
|
||||
<g>
|
||||
<rect filter="url(#blastFilter)" class="blue" x="150" y="200" width="3" height="5" />
|
||||
<rect filter="url(#blastFilter)" class="white" x="150" y="200" width="1" height="3" />
|
||||
</g>
|
||||
))}
|
||||
</g>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
anime.set('#blast', {
|
||||
translateX: -200 * this.props.direction.x,
|
||||
translateY: -300 * this.props.direction.y,
|
||||
});
|
||||
|
||||
this.animations.push(anime({
|
||||
targets: '#blast',
|
||||
targets: ['#blast'],
|
||||
opacity: [
|
||||
{ value: 1, delay: TIMES.TARGET_DELAY_MS, duration: TIMES.TARGET_DURATION_MS * 0.3 },
|
||||
{ value: 0, delay: TIMES.TARGET_DURATION_MS * 0.7, duration: TIMES.POST_SKILL_DURATION_MS },
|
||||
{ value: 1, delay: TIMES.TARGET_DELAY_MS, duration: TIMES.TARGET_DURATION_MS * 0.2 },
|
||||
{ value: 0, delay: TIMES.TARGET_DURATION_MS * 0.5, duration: TIMES.TARGET_DURATION_MS * 0.2 },
|
||||
],
|
||||
easing: 'easeInOutSine',
|
||||
}));
|
||||
|
||||
anime.set('#explosion feDisplacementMap', {
|
||||
scale: 1,
|
||||
});
|
||||
|
||||
this.animations.push(anime({
|
||||
targets: '#blast',
|
||||
translateY: 0,
|
||||
translateX: 0,
|
||||
loop: false,
|
||||
targets: ['#blast g'],
|
||||
transform: () => `
|
||||
translate(${anime.random(-100, 100)} ${anime.random(-100, 100)})
|
||||
`,
|
||||
style: { rotate: anime.random(-180, 180) },
|
||||
easing: 'easeOutCubic',
|
||||
delay: TIMES.TARGET_DELAY_MS,
|
||||
duration: (duration * 1 / 2),
|
||||
easing: 'easeInQuad',
|
||||
}));
|
||||
|
||||
this.animations.push(anime({
|
||||
targets: '#explosion feDisplacementMap',
|
||||
scale: 200,
|
||||
loop: false,
|
||||
delay: TIMES.TARGET_DELAY_MS + duration * 1 / 2,
|
||||
duration: duration * 1 / 2,
|
||||
easing: 'easeInQuad',
|
||||
duration: TIMES.TARGET_DURATION_MS,
|
||||
}));
|
||||
}
|
||||
|
||||
// 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();
|
||||
@@ -102,4 +74,4 @@ class AttackCharge extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = AttackCharge;
|
||||
module.exports = Blast;
|
||||
|
||||
Reference in New Issue
Block a user