Skip to content

Instantly share code, notes, and snippets.

@enjalot
Created July 27, 2013 22:23
Show Gist options
  • Save enjalot/6096522 to your computer and use it in GitHub Desktop.
Save enjalot/6096522 to your computer and use it in GitHub Desktop.
perlin sheets

[ Launch: perlin sheets ] 6096522 by enjalot
[ Launch: perlin sheets ] 6096507 by enjalot
[ Launch: perlin sheets ] 6096491 by enjalot
[ Launch: perlin sheets ] 6096485 by enjalot
[ Launch: perlin sheets ] 6096483 by enjalot
[ Launch: perlin sheets ] 6096476 by enjalot
[ Launch: perlin sheets ] 6096472 by enjalot
[ Launch: perlin sheets ] 6096457 by enjalot
[ Launch: perlin sheets ] 6096448 by enjalot
[ Launch: perlin sheets ] 6096440 by enjalot
[ Launch: perlin sheets ] 6096437 by enjalot
[ Launch: perlin animation ] 6096433 by enjalot
[ Launch: perlin ink ] 6096430 by enjalot
[ Launch: perlin ink ] 6096426 by enjalot
[ Launch: perlin ink ] 6096425 by enjalot
[ Launch: perlin ink ] 6096421 by enjalot
[ Launch: perlin ink ] 5087625 by enjalot
[ Launch: perlin wormsss ] 5080123 by enjalot
[ Launch: perlin worms combo ] 5080115 by enjalot
[ Launch: perlin worms tan ] 5080107 by enjalot
[ Launch: perlin noise ] 5062000 by enjalot
[ Launch: perlin noise ] 5061982 by enjalot

{"description":"perlin sheets","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/ucYIFaW.jpg"}
//playing with noise.js from Joseph Gentle
//https://github.com/josephg/noisejs
var minPeriod = 0.235176002048 / 300;
var maxPeriod = 2.97588001024 / 300;
var minHue = 130;
var maxHue = 380;
var minR = 0.624;
var maxR = 2.5;
var minRot = 0.1;
var maxRot = 0.5
var minMult = 0.1;
var maxMult = 4.256;
var pw = 1.2;
var ph = 1.26;
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: 114 + Math.random() * 512
});
}
function draw() {
};
var waves = {
"sin": Math.sin,
"cos": Math.cos,
"tan": Math.tan,
"quad": d3.ease("quad"),
"cubic": d3.ease("cubic"),
"square": function(x) { }
}
function op(t, min, max, wave) {
if(!wave) { wave = "sin" }
return min + (max - min) * (1 + waves[wave](t))/2
}
tributary.run = function(g,t) {
var period = op(t, minPeriod, maxPeriod, "quad");// * op(t, minPeriod, maxPeriod, "tan");
var r = op(t, minR, maxR, "cubic")
var hue = Math.floor(op(t, minHue, maxHue, "cos"))
var mult = op(t, minMult, maxMult, "sin")
var rot = op(t, minRot, maxRot, "tan")
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 + ", 95%, 32%, 0.02)";
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