[ Launch: perlin smoke ] 6096853 by enjalot
[ Launch: perlin smoke ] 6096845 by enjalot
[ Launch: perlin smoke ] 6096839 by enjalot
[ Launch: perlin smoke ] 6096829 by enjalot
[ Launch: perlin smoke ] 6096640 by enjalot
[ Launch: perlin fill ] 6096618 by enjalot
[ Launch: perlin fill ] 6096617 by enjalot
[ Launch: perlin fill ] 6096608 by enjalot
[ Launch: perlin fill ] 6096601 by enjalot
[ Launch: perlin fill ] 6096597 by enjalot
-
-
Save enjalot/6096853 to your computer and use it in GitHub Desktop.
perlin smoke
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"description":"perlin smoke","endpoint":"","display":"canvas","public":true,"require":[{"name":"perlin","url":"https://raw.github.com/josephg/noisejs/master/perlin.js"}],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":true,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"thumbnail":"http://i.imgur.com/OPecMi5.png"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//playing with noise.js from Joseph Gentle | |
//https://github.com/josephg/noisejs | |
var minPeriod = 1.573408009601449 / 300; | |
var maxPeriod = 6.5223236736615 / 300; | |
var minHue = 430; | |
var maxHue = 505; | |
var minR = 3.128; | |
var maxR = .5; | |
var theta = Math.PI*1.24 | |
var minRot = .83755; | |
var maxRot = -0.866697216 | |
var minMult = 0.9391; | |
var maxMult = 2.336928; | |
var pw = 1.8; | |
var ph = 1.6256; | |
var ctx = tributary.ctx; | |
var canvas = tributary.canvas; | |
w = canvas.width; | |
h = canvas.height; | |
ctx.fillStyle = 'white'; | |
ctx.fillRect(0, 0, w, h); | |
ctx.fillStyle = 'rgba(1,1,1,0.3)'; | |
//noise.seed(Math.random()); | |
particles = []; | |
for (_i = 1; _i <= 2000; _i++) { | |
type = Math.floor(Math.random() * 2); | |
d = Math.floor(Math.random() * 128 + type * 128); | |
particles.push({ | |
x: Math.random() * w, | |
y: 13 + Math.random() * 622 | |
}); | |
} | |
function draw() { | |
}; | |
var waves = { | |
"sin": Math.sin, | |
"cos": Math.cos, | |
"tan": Math.tan, | |
"quad": d3.ease("quad"), | |
"cubic": d3.ease("cubic"), | |
"circle": d3.ease("circle"), | |
"bounce": d3.ease("bounce"), | |
"back": d3.ease("back"), | |
"exp": d3.ease("exp"), | |
"square": function(x) { } | |
} | |
function op(t, min, max, wave) { | |
if(!theta) { | |
freq = Math.PI; | |
} else { | |
freq = theta * (Math.random() * 0.1 + 0.4); | |
} | |
if(!wave) { wave = "sin" } | |
return min * (Math.random()*0.01+0.9) + (max - min) * (1 + waves[wave](t) * freq)/2 | |
} | |
tributary.run = function(g,t) { | |
theta = op(t, 1.4*Math.PI, 1.2*Math.PI, "bounce") | |
var period = op(t, minPeriod, maxPeriod, "sin") * op(t, minPeriod, maxPeriod, "exp"); | |
var r = op(t, minR, maxR, "circle") | |
var hue = Math.floor(op(t, minHue, maxHue, "cubic")) | |
var mult = op(t, minMult, maxMult, "sin") | |
var rot = op(t, minRot, maxRot, "sin") | |
var a, p, v, _i, _len, _ref, _ref1; | |
for (_i = 0, _len = particles.length; _i < _len; _i++) { | |
p = particles[_i]; | |
v = noise.simplex2(p.x * period, p.y * period); | |
ctx.fillStyle = "hsla(" + hue + ", 5%, 32%, 0.1)"; | |
ctx.fillRect(p.x, p.y, pw, ph); | |
a = mult * v * 2 * Math.PI;// + p.a; | |
p.x += r * Math.sin(-a * rot) * Math.tan(a + rot) + Math.tan(a * rot); | |
p.y += r * Math.cos(-a * rot) * Math.tan(-a - rot) + Math.tan(a * rot) * v; | |
if ((p.x < 0 || p.x >= w) || (p.y < 0 || p.y >= h)) { | |
p.x = Math.random() * w; | |
p.y = Math.random() * h; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment