npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

particles-system

v0.0.9

Published

A lightweight library to create varible particals

Downloads

15

Readme

本篇README.md面向开发者

目录

安装

npm

通过npm

npm install particals

通过yarn

yarn particals
原生

将dist中的particals.js文件放到你的项目中或者上传至cdn引用即可 js脚本会在全局注入一个Particials对象

<script src="./dist/particals.js"><script>

适用范围

目前该粒子库仅支持粒子间相互独立、和用户无交互的效果

使用

Particals.js提供了一些上手即用的Demo,调整参数即可使用

Hello Partials.js

基础的使用包括以下代码

const hurricaneEl = document.querySelector('#hurricane');
const hurricane = new Particals.Particals({
    el: hurricaneEl,
    partical: new Particals.CirclePartical({
        color: [
            { offset: 0, color: 'rgba(226,3,249, 1) ' },
            { offset: 0.4, color:  'rgba(226,3,249, 0.3) ' },
            { offset: 1, color: 'rgba(226,3,249, 0) '}
        ],
        radius: [10,20],
    }),
    particalNum: 50,
    pregnantTime: 3,
    behaviors: [
        new Particals.SizeDieBehavior({minSize: 0}),
        new Particals.PositionBornBehavior({
            bornArea: {
                x: 200,
                y: 300,
                w: 30,
                h: 10
            },
        }),
        new Particals.LinearSizeBehavoir({
            speed: [-0.1, -0.4],
        }),
        new Particals.SinPositionBehavior({
            speed: [30, 60],
            speedRate: 1,
            amplitude: 40,
            frequency: 0.5
        }),
    ]
});
hurricane.run();

其中主要参数包括partical(粒子类型)、canvas元素、粒子数、behaviors, 执行run后就会开始粒子效果

支持的粒子
  1. 圆形粒子
  2. 文字粒子
  3. Image粒子
支持的行为

behaviors针对每个粒子的生命周期,每个更新循环会按顺序执行behaviors里的更新行为 behavior可以对粒子对行为按不同的纬度进行控制

  1. 随机出生区域
  2. 粒子死亡条件
  3. 粒子位置更新
  4. 粒子大小更新
  5. 自定义行为

Api

TODO