A React library which shows multi-colored fluid effects on cursor movements. On cursor movements or touch you can make smoke like effects. Ideal for adding dynamic, visually engaging elements to application.
npm install fluid-simulation-reactnpm install fluid-simulation-react
import React from 'react';
import FluidSimulation from 'fluid-simulation-react';
const MyComponent = () => {
return ;
};
export default MyComponent;
`
Custom Configuration and color
fluid-simulation-react allows you to customize the fluid simulation behavior through a config prop. Here is how you can use it:
`
import React from 'react';
import FluidSimulation from 'fluid-simulation-react';
const MyComponent = () => {
const customConfig = {
textureDownsample: 2,
densityDissipation: 0.80,
};
const customColors = [
[1, 1, 0], // Yellow
[0, 1, 1] // Cyan
]
return ;
};
export default MyComponent;
`
Default Configuration
The default configuration for fluid-simulation-react is as follows:
`
const defaultConfig = {
textureDownsample: 1,
densityDissipation: 0.98,
velocityDissipation: 0.99,
pressureDissipation: 0.8,
pressureIterations: 25,
curl: 30,
splatRadius: 0.005,
};
const color = [
Math.random() + 0.2,
Math.random() + 0.2,
Math.random() + 0.2,
];
``