-
Notifications
You must be signed in to change notification settings - Fork 0
A lightweight JavaScript library for adding a beautiful Sakura and Star particle background effect to your web pages.
- Sakura (cherry blossom) and Star particles.
- Night mode switch.
- Responsive and interactive with mouse and device orientation.
You can include the package directly via a script tag from the GitHub Pages link or Cloudflare Pages link.
<script type="module">
import backgroundEffect from 'https://thed0ublec.github.io/ParticleBackground/package/backgroundEffect.js';
backgroundEffect.init();
</script>
<script type="module">
import backgroundEffect from 'https://background-dhy.pages.dev/backgroundEffect.js';
backgroundEffect.init();
</script>
-
Include the script
Make sure to include the
backgroundEffect.js
script in your HTML file:<script type="module"> import backgroundEffect from 'https://thed0ublec.github.io/ParticleBackground/package/backgroundEffect.js'; backgroundEffect.init(); </script>
Or, using the Cloudflare Pages URL:
<script type="module"> import backgroundEffect from 'https://background-dhy.pages.dev/backgroundEffect.js'; backgroundEffect.init(); </script>
-
Add required images
Ensure that the required images (
sakura.png
andstar.png
) are available in the correct path (e.g.,images/
directory). If you place the images in a different directory, update thebackgroundEffect.js
accordingly.
Here is a complete example demonstrating how to use the background effect:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Test Background Effect</title>
<style>
body {
position: relative; /* Ensure the main content is correctly positioned */
z-index: 1; /* Ensure the main content is above the background layer */
}
</style>
</head>
<body>
<h1>test1</h1>
<script type="module">
import backgroundEffect from 'https://thed0ublec.github.io/ParticleBackground/package/backgroundEffect.js';
backgroundEffect.init();
</script>
<!-- Alternatively, use the Cloudflare Pages URL -->
<!-- <script type="module">
import backgroundEffect from 'https://background-dhy.pages.dev/backgroundEffect.js';
backgroundEffect.init();
</script> -->
<h1>test2</h1>
</body>
</html>
You can customize the number of particles, size, and other properties by modifying the backgroundEffect.js
file.
To change the maximum number of particles, you can update the maxParticles
variable in the backgroundEffect.js
file:
const maxParticles = 100; // Increase or decrease the number of particles
To use different images for the particles, update the createParticle
and updateParticleImages
functions in the backgroundEffect.js
file to reference your new images.
This project is licensed under the MIT License.
If you find any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request on the GitHub repository.
For any questions or inquiries, please contact TheD0ubleC.