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

@bijection/smoke

v1.0.2

Published

Tiny, fancy, javascript canvas smoke effect.

Downloads

197

Readme

Demo

You can play with a live demo here →

Installation

Basic

Copy the smoke.js file into your project and use it with a script tag:

<script src="smoke.js"></script>

That defines a SmokeMachine global that you can use to make smoke (see examples below).

Package Manager

You can also use yarn or npm:

yarn add @bijection/smoke
npm add @bijection/smoke

Thern you can import or require smoke.js like this:

import SmokeMachine from '@bijection/smoke'
var SmokeMachine = require('@bijection/smoke')

Usage

Short Example

var ctx = canvas.getContext('2d')

var party = SmokeMachine(ctx)
party.addSmoke(500,500)
party.start()

Copy-Pastable Example

<canvas id="canvas"></canvas>
<script src="smoke.js"></script>
<script>
	var canvas = document.getElementById('canvas')
	var ctx = canvas.getContext('2d')
	canvas.width = 1000
	canvas.height = 1000

	var party = SmokeMachine(ctx, [54, 16.8, 18.2])

	party.start() // start animating

	party.addSmoke(500,500,10) // wow we made smoke

	setTimeout(function(){

		party.stop() // stop animating

		party.addSmoke(600,500,100)
		party.addSmoke(500,600,20)

		for(var i=0;i<10;i++){
			party.step(10) // pretend 10 ms pass and rerender
		}

		setTimeout(function(){
			party.start()
		},1000)

	},1000)
</script>

API

SmokeMachine(context, [r,g,b])

Returns a smoke machine that makes smoke.

  • context — the context of the canvas we wanna draw smoke on
  • [r,g,b] — (optional) the color we want the smoke to be
var party = SmokeMachine(context, [1,5,253])

party.start()

Start Animating!!

party.stop()

Stop animating :(

party.addSmoke(x,y,numberofparticles)

  • x,y — the coords at which the smoke should be created in the canvas
  • numberofparticles — more makes more smoke

party.step(milliseconds)

redaws the smoke as if milliseconds milliseconds have passed