Skip to content

Instantly share code, notes, and snippets.

@notlion
Created November 14, 2011 01:53
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 notlion/1363063 to your computer and use it in GitHub Desktop.
Save notlion/1363063 to your computer and use it in GitHub Desktop.
Offset Generator for GLSL Sandbox
var size = 9;
var size_half = Math.floor(size / 2);
var offs = [];
for(var y = size; --y >= 0;){
for(var x = size; --x >= 0;){
var ox = x - size_half;
var oy = y - size_half;
var dist = Math.sqrt(ox * ox + oy * oy);
if(!(ox === 0 && oy === 0) && dist < size_half){
offs.push({ x: ox, y: oy, dist: dist });
}
}
}
offs.forEach(function(off){
console.log(" vel += getSpring(prev, pos + pixel * vec2(" + off.x + ", " + off.y + "), " + ((1 - off.dist / size_half) / offs.length) + " * power);");
});
@jonobr1
Copy link

jonobr1 commented Nov 14, 2011

Forgive my naivete, what is process?

@notlion
Copy link
Author

notlion commented Nov 14, 2011

Oh. This is meant to run in Node / Plask. process.exit() quits the app ;)

@jonobr1
Copy link

jonobr1 commented Nov 14, 2011 via email

@notlion
Copy link
Author

notlion commented Nov 14, 2011

Right on. I took out the process.exit() to make it agnostic. Node / Plask just happened to be the easier tool to reach for this time.

@jonobr1
Copy link

jonobr1 commented Nov 14, 2011 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment