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
/** | |
* animator factory for creating requestAnimationFrame callbacks | |
* and simplifying their cancellation. Includes Erik Moller polyfill | |
* @author Kyle Phillips | |
* @example | |
* animator(function(){ | |
* //do this every time | |
* if(Math.random() > 0.9){ | |
* this.complete(); | |
* } |
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
#!/usr/bin/env node | |
/** | |
* Watches all project .less files, | |
* automatically renders css with every change | |
* usage: $watch-less ~/Sites/myProject1 ~/Sites/myProject2 | |
*/ | |
var less = require('less'), |
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
//##console.log bubble for nested iframes | |
//##by [Kyle Phillips](http://haptic-data.com) | |
//find each iframe recursively and bubble its logs up to the current window.console | |
(function( d, w ){ | |
function bubble( doc, win, msg ){ | |
Array.prototype.forEach.call(doc.getElementsByTagName('iframe'), function( frame ){ | |
if( !sameOrigin(frame.src) || !frame.contentWindow || !frame.contentWindow.console ){ | |
w.console.log('console of iframe ', frame.src, ' is unreachable'); | |
return; | |
} |
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
//A minimal wrapper around WebGL Shaders | |
//takes the vertexShader and fragmentShader as plain-text | |
//**basic use:** | |
// | |
// shaderProgram = glsl( gl ) | |
// .createProgram(vertexShader, fragmentShader) | |
// .attributes({ | |
// "vertexPositionAttribute" : 'aVertexPosition', | |
// 'vertexColorAttribute' : 'aVertexColor' | |
// }) |
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
//RGB values for every X11 Color Name | |
//http://en.wikipedia.org/wiki/Web_colors | |
//author Kyle Phillips | |
var cssColors = { | |
indianred: [205, 92, 92], | |
lightcoral: [240, 128, 128], | |
salmon: [250, 128, 114], | |
darksalmon: [233, 150, 122], | |
lightsalmon: [255, 160, 122], | |
red: [255, 0, 0], |
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
/* | |
example: | |
new ParallaxSprite({ | |
el: $('#element'), | |
watch: { | |
fn: function(){ return $(window).scrollTop(); }, | |
from: 0, | |
to: 1000 | |
}, | |
tween: { |
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
define(function( require ){ | |
var THREE = require('three'); | |
/** | |
* take a toxiclibs.js mesh and turn it into a THREE.BufferGeometry | |
* @param {toxi.geom.mesh.TriangleMesh} mesh | |
* @type {THREE.BufferGeometry} | |
*/ | |
return function( mesh ){ | |
var geometry = new THREE.BufferGeometry(); | |
//3 points per face, 3 axis per point |
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
//load all of the Grunt NPM Tasks out of the package.json | |
Object.keys(require('./package.json').devDependencies).forEach(function(dep){ | |
if( dep.match(/grunt-/) ){ | |
grunt.loadNpmTasks(dep); | |
} | |
}); |
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
define([ | |
'three' | |
], function( THREE ){ | |
/** | |
* quickly set up all of the basics of a THREE.js canvas | |
* @param {Object} [app] the settings for the app | |
* @param {Number} [app.width] | |
* @param {Number} [app.height] | |
* @param {Number} [app.fov] |
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
# put these in your ~/.bashrc and start a new shell to receive these commands | |
# requires node-inspector, install: npm install -g node-inspector | |
# start node-inspector and debug node app | |
# example: debug-node --open app.js --port=3000 | |
function debug-node () { | |
# start node-inspector as a background-process | |
node-inspector & | |
# grab last PID to kill process later | |
INSPECTOR_PID=$! |
OlderNewer