Skip to content

Instantly share code, notes, and snippets.

@enjalot
Created March 7, 2013 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enjalot/5110582 to your computer and use it in GitHub Desktop.
Save enjalot/5110582 to your computer and use it in GitHub Desktop.
drunk doctors handwriting
{"description":"drunk doctors handwriting","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/Zz2s1Yz.png"}
//playing with noise.js from Joseph Gentle
//https://github.com/josephg/noisejs
var period = 1.40613 / 300;
var r = 0.70088;
var rot = -0.14769;
var mult = 1.96;
var pw = 1.5;
var ph = 1.5;
var amult = 0.0 * Math.PI;
var z = 0;
var zspeed = 0.003;
var TAU = 2 * Math.PI;
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 <= 350; _i++) {
type = Math.floor(Math.random() * 2);
d = Math.floor(Math.random() * 158 + type * 128);
particles.push({
x: Math.random() * w,
y: 400 + Math.random() * 2,
a: type / 2 * TAU + amult * _i
});
}
function draw() {
var a, p, v, _i, _len, _ref, _ref1;
_len = particles.length;
var seg_value = TAU/_len;
for (_i = 0; _i < _len; _i++) {
p = particles[_i];
v = noise.simplex3(p.x * period, p.y * period, z);
ctx.fillStyle = "hsla(" + (Math.random()*28+190) + ", 95%, 20%, 0.3)";
ctx.fillRect(p.x, p.y, pw, ph);
a = mult * v * 0.2 * Math.PI;// + p.a;
p.x += (Math.cos(_i*seg_value))* Math.sin(-a * rot) * Math.tan(a + rot) + Math.tan(a * rot);
p.y += (Math.sin(_i*seg_value)) * 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;
}
}
}
tributary.run = function(g,t) {
draw();
z += zspeed;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment