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

confetti-ts-canvas

v1.1.5

Published

礼花喷发

Downloads

20

Readme

:zap:Confetti-ts-canvas

canvas中奖庆祝礼花喷发/五彩纸屑/🎉/特效

请在运行Demo之前 npm i confetti-ts-canvas 安装该库

特性

  • 1.基于canvas 2d,无依赖任何第三方插件,安装简单。
  • 2.基于typescript开发,支持es6和amd与ts。
  • 3.本质就是一个jssdk支持各大浏览器H5 PC与M端,uniapp,微信小程序,uniapp app等,只要是js或者ts都支持。
  • 4.使用简单,支持自定义形状,效果显著,动画流畅60帧

效果图

Github stars 如果有帮到您,给个小星星,我会把它做得更好。 https://github.com/AK1118/Confetti-js-canvas/

cdn引入

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/index.esm.min.js"></script> 
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/index.amd.min.js"></script>
  • 2选1,建议使用npm安装

npm安装

npm i confetti-ts-canvas

一个简单的开始

import { Confetti } from 'confetti-ts-canvas';

const canvas= document.querySelector("canvas");
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
const g= canvas.getContext("2d");

new Confetti({
     paint:g,
     canvasWidth:canvas.width,
     canvasHeight:canvas.height,
  }).run();

更多的使用方法,引入

import {
	ConfettiEjector,
	CanvasRender,
	CustomShape
} from 'confetti-ts-canvas';

初始化

const g=uni.createCanvasContext("myCanvas");
const canvasRender=new CanvasRender();
canvasRender.init(
		//必填 CanvasContext
		g,
		//可选填入
		{
			width:canvas.width,
			height:canvas.height,
		},
		//以下参数全部可选填入
		{
			onFinished(){
				console.log("完成")
			},
			displayFps:true,
			grivaty:.5,
		}
	);
	

使用

const pao = new ConfettiEjector(canvasRender, {
	limitAngle: [225, 315],//喷发角度区间[-∞,+∞]
	count: 100,//喷发纸片数量
});
const boom = pao.create({
	x: Math.random()*(this.canvasSize.width*.5),
	y:Math.random()*(this.canvasSize.height*.5),//喷发位置
	clampforce: [20, 60],//喷发力度
	radius: 10,//纸片大小
});
pao.fire(boom);

可能会遇到的问题

  • 详细使用方法请参考demo:https://ext.dcloud.net.cn/plugin?id=10530