GithubHelp home page GithubHelp logo

alexxnica / smoke.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bijection/smoke.js

0.0 2.0 0.0 19 KB

Small but good javascript smoke effect ๐ŸŒฌ๐Ÿ’จ

Home Page: https://omrelli.ug/smoke.js/

JavaScript 100.00%

smoke.js's Introduction

smoke.js

tl;dr

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

var party = smokemachine(ctx)
party.addsmoke(500,500)
party.start()

DEMO

you can copy paste this

<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

smoke.js's People

Contributors

bijection avatar sturob avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.