Skip to content

fix: MetallicPaint import texts, and useState management #168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions src/constants/code/Animations/metallicPaintCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import tsTailwind from '@ts-tailwind/Animations/MetallicPaint/MetallicPaint.tsx?

export const metallicPaint = {
...(generateCliCommands('Animations/MetallicPaint')),
usage: `import MetallicPaint, { parseLogoImage } from "./MetallicPaint";'
usage: `import MetallicPaint, { parseLogoImage } from "./MetallicPaint";
import { useState, useEffect } from 'react';

// replace with your own SVG
Expand All @@ -17,36 +17,38 @@ import { useState, useEffect } from 'react';
import logo from '../../assets/logos/react-bits-solid-black.svg';

const Component = () => {
const [imageData, setImageData] = useState(null);
const [imageData, setImageData] = useState<ImageData | null>(null);

useEffect(() => {
async function loadDefaultImage() {
try {
const response = await fetch(logo);
const blob = await response.blob();
const file = new File([blob], "default.png", { type: blob.type });
const { imageData } = await parseLogoImage(file);
setImageData(imageData);

const parsedData = await parseLogoImage(file);
setImageData(parsedData?.imageData ?? null);

} catch (err) {
console.error("Error loading default image:", err);
}
}

loadDefaultImage();
}, []);

return (
<div style={{ width: '100%', height: '100vh' }}>
<MetallicPaint
imageData={imageData}
imageData={imageData ?? new ImageData(1, 1)}
params={{ edge: 2, patternBlur: 0.005, patternScale: 2, refraction: 0.015, speed: 0.3, liquid: 0.07 }}
/>
</div>
);
}`,
code,
css,
tailwind,
tsCode,
tsTailwind
}
code,
css,
tailwind,
tsCode,
tsTailwind
};