easy-snowfall
v1.0.0
Published
🌨️ **Easy-Snowfall** is a lightweight JavaScript library for creating beautiful snowfall animations on web pages. Highly customizable, it allows users to create different snowflake styles effortlessly, adding a touch of winter magic to your website.
Downloads
4
Readme
Easy-Snowfall
🌨️ Easy-Snowfall is a lightweight JavaScript library for creating beautiful snowfall animations on web pages. Highly customizable, it allows users to create different snowflake styles effortlessly, adding a touch of winter magic to your website.
🌨️ Easy-Snowfall 是一个轻量级的 JavaScript 库,用于在网页中生成漂亮的雪花动画效果。它支持高度定制,用户可以通过简单的配置创建不同的雪花风格,为网站增添冬日氛围。
Features | 特性
🎨 Highly Customizable: Adjust the number, size, opacity, speed, and swing amplitude of snowflakes.
🎨 高度自定义:支持调整雪花数量、大小、透明度、速度、摆动幅度等参数。
📱 Responsive Design: Automatically adapts to screen size changes, perfect for both desktop and mobile.
📱 响应式设计:自动适配屏幕尺寸变化,适用于桌面和移动端。
⚡ Great Performance: Smooth animations using native Canvas, with low resource consumption.
⚡ 性能优异:使用原生 Canvas 实现,动画流畅,占用资源少。
🚀 Easy to Use: Integrate into any webpage with just a few lines of code.
🚀 开箱即用:只需几行代码即可快速集成到任意网页中。
Quick Start | 快速开始
Installation | 安装
Download the script directly or install via npm:
直接下载脚本或通过 npm 安装:
npm install easy-snowfallExample | 示例
Add a <canvas> tag in your HTML file and initialize Snowfall:
在 HTML 文件中添加一个 <canvas> 标签,并初始化 Snowfall:
<canvas id="snow"></canvas>
<script type="module">
import Snowfall from 'easy-snowfall'
new Snowfall('#snow', {
flakeCount: 100, // Snowflake count | 雪花数量
radiusRange: [2, 5], // Radius range | 雪花半径范围
opacityRange: [0.5, 1], // Opacity range | 雪花透明度范围
speed: 0.1, // Falling speed multiplier | 雪花下落速度倍数
swingAmplitude: 0.1, // Swing amplitude | 雪花左右摆动幅度
});
</script>Configuration | 配置参数
| Parameter | Type | Default | Description |
|-----------------|-----------|---------------|-----------------------------------------|
| 参数名称 | 类型 | 默认值 | 描述 |
| flakeCount | number | 100 | Number of snowflakes | 雪花数量 |
| radiusRange | Array | [2, 5] | Snowflake radius range | 雪花半径范围 |
| opacityRange | Array | [0.5, 1] | Snowflake opacity range | 雪花透明度范围 |
| speed | number | 1 | Falling speed multiplier | 雪花下落速度倍数 |
| swingAmplitude| number | 0 | Swing amplitude | 雪花左右摆动幅度 |
Compatibility | 兼容性
Supports all major modern browsers (Chrome, Firefox, Edge, Safari).
支持主流现代浏览器(Chrome、Firefox、Edge、Safari)。
Mobile-friendly, works well on iOS and Android devices.
移动端友好,适配 iOS 和 Android 系统。
License | 许可证
This project is licensed under the AGPL-3.0 License. Contributions and forks are welcome!
本项目基于 AGPL-3.0 License 开源,欢迎贡献与分支!
