[ Launch: goop ] 65b8f9f1eeef6841e64b by rickdg
[ Launch: goop ] 5119042 by enjalot
[ Launch: turtles ] 5118992 by zeffii
[ Launch: perlin worms ] 5062100 by enjalot
[ Launch: perlin noise ] 5062000 by enjalot
[ Launch: perlin noise ] 5061982 by enjalot
-
-
Save rickdg/65b8f9f1eeef6841e64b to your computer and use it in GitHub Desktop.
goop
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":"goop","endpoint":"","display":"canvas","public":true,"require":[{"name":"p","url":"https://cdn.rawgit.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/86ReLcF.jpg","ajax-caching":true} |
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 period = 2.65573 / 200; | |
var r = 2.592; | |
var mult = 3; | |
var pw = 0.5; | |
var ph = 0.5; | |
var amult = 0.0 * Math.PI; | |
var z = 0; | |
var zspeed = 0.0009; | |
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 <= 2000; _i++) { | |
type = Math.floor(Math.random() * 2); | |
d = Math.floor(Math.random() * 118 + type * 61); | |
particles.push({ | |
x: Math.random() * w, | |
y: 113 + Math.random() * 611, | |
a: type / 0.00736 * TAU + (amult * _i) | |
}); | |
} | |
function draw() { | |
var a, p, v, _i, _len, _ref, _ref1; | |
for (_i = 0, _len = particles.length; _i < _len; _i++) { | |
p = particles[_i]; | |
v = noise.simplex3(p.x * period, p.y * period, z); | |
ctx.fillStyle = "hsla(" + (Math.floor(v/30)*30) +411 + ", 75%, 50%, 0.3)"; | |
ctx.fillRect(p.x, p.y, pw, ph); | |
a = mult * v * TAU + p.a/0.4; | |
p.x += r * Math.cos(a); | |
p.y += r * Math.sin(a); | |
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