@@ -8,7 +8,7 @@ import tsTailwind from '@ts-tailwind/Animations/MetallicPaint/MetallicPaint.tsx?
8
8
9
9
export const metallicPaint = {
10
10
...( generateCliCommands ( 'Animations/MetallicPaint' ) ) ,
11
- usage : `import MetallicPaint, { parseLogoImage } from "./MetallicPaint";'
11
+ usage : `import MetallicPaint, { parseLogoImage } from "./MetallicPaint";
12
12
import { useState, useEffect } from 'react';
13
13
14
14
// replace with your own SVG
@@ -17,36 +17,38 @@ import { useState, useEffect } from 'react';
17
17
import logo from '../../assets/logos/react-bits-solid-black.svg';
18
18
19
19
const Component = () => {
20
- const [imageData, setImageData] = useState(null);
20
+ const [imageData, setImageData] = useState<ImageData | null> (null);
21
21
22
22
useEffect(() => {
23
23
async function loadDefaultImage() {
24
24
try {
25
25
const response = await fetch(logo);
26
26
const blob = await response.blob();
27
27
const file = new File([blob], "default.png", { type: blob.type });
28
- const { imageData } = await parseLogoImage(file);
29
- setImageData(imageData);
28
+
29
+ const parsedData = await parseLogoImage(file);
30
+ setImageData(parsedData?.imageData ?? null);
31
+
30
32
} catch (err) {
31
33
console.error("Error loading default image:", err);
32
34
}
33
35
}
34
-
36
+
35
37
loadDefaultImage();
36
38
}, []);
37
39
38
40
return (
39
41
<div style={{ width: '100%', height: '100vh' }}>
40
42
<MetallicPaint
41
- imageData={imageData}
43
+ imageData={imageData ?? new ImageData(1, 1) }
42
44
params={{ edge: 2, patternBlur: 0.005, patternScale: 2, refraction: 0.015, speed: 0.3, liquid: 0.07 }}
43
45
/>
44
46
</div>
45
47
);
46
48
}` ,
47
- code,
48
- css,
49
- tailwind,
50
- tsCode,
51
- tsTailwind
52
- }
49
+ code,
50
+ css,
51
+ tailwind,
52
+ tsCode,
53
+ tsTailwind
54
+ } ;
0 commit comments