Skip to content

Commit cd4e31f

Browse files
author
kim
committed
feat: add ocean filter
1 parent c73a7fa commit cd4e31f

File tree

3 files changed

+59
-17
lines changed

3 files changed

+59
-17
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { JSX } from 'react';
2+
3+
export const OceanFilter = (): JSX.Element => (
4+
<filter id="oceanFilter" x="-20%" y="-20%" width="140%" height="140%">
5+
<feTurbulence
6+
type="fractalNoise"
7+
baseFrequency="0.003 0.006"
8+
numOctaves="1"
9+
seed="3"
10+
result="turbulence"
11+
>
12+
<animate
13+
attributeName="baseFrequency"
14+
dur="60s"
15+
values="0.01 0.02; 0.02 0.01; 0.01 0.02"
16+
repeatCount="indefinite"
17+
/>
18+
</feTurbulence>
19+
20+
<feDisplacementMap
21+
in="SourceGraphic"
22+
in2="turbulence"
23+
scale="20"
24+
xChannelSelector="R"
25+
yChannelSelector="G"
26+
/>
27+
</filter>
28+
);
Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,34 @@
11
import { JSX } from 'react';
22

3+
import { useAnimation } from '@/utils/hooks';
4+
5+
import { OceanFilter } from './OceanFilter';
6+
37
export const Sunshine = ({
48
width,
59
height,
610
}: {
711
width: number;
812
height: number;
9-
}): JSX.Element => (
10-
<g>
11-
<defs>
12-
<linearGradient id="grad" x1="0%" y1="0%" x2="0%" y2="100%">
13-
<stop offset="0%" stopColor="rgba(190, 247, 242, 0.37)" />
14-
<stop offset="100%" stopColor="#BEF7F200" />
15-
</linearGradient>
16-
</defs>
17-
<polygon
18-
id="sunshine"
19-
x={width / 8}
20-
y={0}
21-
fill="url(#grad)"
22-
points={`320,0 900,0 1270,${height} 250,${height}`}
23-
/>
24-
</g>
25-
);
13+
}): JSX.Element => {
14+
const { data: isPlaying } = useAnimation();
15+
return (
16+
<g>
17+
<defs>
18+
<linearGradient id="grad" x1="0%" y1="0%" x2="0%" y2="100%">
19+
<stop offset="0%" stopColor="rgba(190, 247, 242, 0.57)" />
20+
<stop offset="100%" stopColor="#BEF7F200" />
21+
</linearGradient>
22+
<OceanFilter />
23+
</defs>
24+
<polygon
25+
id="sunshine"
26+
x={width / 8}
27+
y={0}
28+
fill="url(#grad)"
29+
points={`320,0 900,0 1270,${height} 250,${height}`}
30+
filter={isPlaying ? 'url(#oceanFilter)' : ''}
31+
/>
32+
</g>
33+
);
34+
};

src/modules/main/MacroView.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { PurpleCoral } from '../components/coral/PurpleCoral';
77
import { YellowCoral } from '../components/coral/YellowCoral';
88
import CoralRose from '../components/coral/corailrose.svg';
99
import { Background } from '../components/elements/Background';
10+
import { OceanFilter } from '../components/elements/OceanFilter';
1011
import { Sunshine } from '../components/elements/Sunshine';
1112

1213
// eslint-disable-next-line react/function-component-definition
@@ -22,6 +23,9 @@ export function MacroView({
2223
return (
2324
<>
2425
<svg width={width} height={height}>
26+
<defs>
27+
<OceanFilter />
28+
</defs>
2529
<Background width={width} height={height} isPlaying={isPlaying} />
2630
<path
2731
d={`
@@ -33,6 +37,7 @@ export function MacroView({
3337
Z
3438
`}
3539
fill="#f7dc6b"
40+
filter={isPlaying ? 'url(#oceanFilter)' : ''}
3641
/>
3742

3843
{isPlaying && <Sunshine width={width} height={height} />}

0 commit comments

Comments
 (0)